r63797 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63796‎ | r63797 | r63798 >
Date:03:14, 16 March 2010
Author:nimishg
Status:ok
Tags:
Comment:
slightly less intellgent but functional way to force template markers to not update when editing, resolving cursor moving issues
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -73,19 +73,19 @@
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 172 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 44 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 45 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 61 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 62 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 342 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 343 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 342 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 343 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -36,6 +36,7 @@
3737 * Event handlers
3838 */
3939 evt: {
 40+
4041 mark: function( context, event ) {
4142 // Get references to the markers and tokens from the current context
4243 var markers = context.modules.highlight.markers;
@@ -117,7 +118,8 @@
118119 return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ?
119120 ca1.parentNode : null;
120121 },
121 - context: context
 122+ context: context,
 123+ skipDivision: "realchange"
122124 } );
123125 } else { //else this was an unmatched opening
124126 tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN';
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -154,6 +154,7 @@
155155
156156 var markers = context.modules.highlight.markers = [];
157157 // Get all markers
 158+
158159 context.fn.trigger( 'mark' );
159160 markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
160161
@@ -169,14 +170,14 @@
170171 }
171172 context.modules.highlight.markersStr = markersStr;
172173
173 - var oldStarts = [];
174 - if(!context.modules.highlight.markersOldStarts){
175 - context.modules.highlight.markersOldStarts = [];
176 - }
177174 // Traverse the iframe DOM, inserting markers where they're needed.
178175 // Store visited markers here so we know which markers should be removed
179176 var visited = [], v = 0;
180177 for ( var i = 0; i < markers.length; i++ ) {
 178+ if(markers[i].skipDivision && (division == markers[i].skipDivision)){
 179+ continue;
 180+ }
 181+
181182 // We want to isolate each marker, so we may need to split textNodes
182183 // if a marker starts or ends halfway one.
183184 var start = markers[i].start;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -8688,6 +8688,7 @@
86898689
86908690 var markers = context.modules.highlight.markers = [];
86918691 // Get all markers
 8692+
86928693 context.fn.trigger( 'mark' );
86938694 markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
86948695
@@ -8703,14 +8704,14 @@
87048705 }
87058706 context.modules.highlight.markersStr = markersStr;
87068707
8707 - var oldStarts = [];
8708 - if(!context.modules.highlight.markersOldStarts){
8709 - context.modules.highlight.markersOldStarts = [];
8710 - }
87118708 // Traverse the iframe DOM, inserting markers where they're needed.
87128709 // Store visited markers here so we know which markers should be removed
87138710 var visited = [], v = 0;
87148711 for ( var i = 0; i < markers.length; i++ ) {
 8712+ if(markers[i].skipDivision && (division == markers[i].skipDivision)){
 8713+ continue;
 8714+ }
 8715+
87158716 // We want to isolate each marker, so we may need to split textNodes
87168717 // if a marker starts or ends halfway one.
87178718 var start = markers[i].start;
@@ -9229,6 +9230,7 @@
92309231 * Event handlers
92319232 */
92329233 evt: {
 9234+
92339235 mark: function( context, event ) {
92349236 // Get references to the markers and tokens from the current context
92359237 var markers = context.modules.highlight.markers;
@@ -9310,7 +9312,8 @@
93119313 return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ?
93129314 ca1.parentNode : null;
93139315 },
9314 - context: context
 9316+ context: context,
 9317+ skipDivision: "realchange"
93159318 } );
93169319 } else { //else this was an unmatched opening
93179320 tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN';
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -590,8 +590,8 @@
591591 tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
592592 tokenArray.sort(function(a,b){return a.offset-b.offset||a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=context.modules.highlight.markers=[];context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var markersStr='';for(var i=0;i<markers.length;i++){markersStr+=markers[i].start+','+markers[i].end+','+markers[i].type+',';}
593593 if(context.modules.highlight.markersStr==markersStr){return;}
594 -context.modules.highlight.markersStr=markersStr;var oldStarts=[];if(!context.modules.highlight.markersOldStarts){context.modules.highlight.markersOldStarts=[];}
595 -var visited=[],v=0;for(var i=0;i<markers.length;i++){var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;}
 594+context.modules.highlight.markersStr=markersStr;var visited=[],v=0;for(var i=0;i<markers.length;i++){if(markers[i].skipDivision&&(division==markers[i].skipDivision)){continue;}
 595+var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;}
596596 var startNode=s.node;while(startNode.nodeName=='BR'||s.offset==startNode.nodeValue.length){start++;s=context.fn.getOffset(start);startNode=s.node;}
597597 if(s.offset>0&&s.node.nodeName=='#text'){startNode=startNode.splitText(s.offset<s.node.nodeValue.length?s.offset:s.node.nodeValue.length-1);context.fn.purgeOffsets();}
598598 var end=markers[i].end;var e=context.fn.getOffset(end-1);if(!e){continue;}
@@ -644,7 +644,7 @@
645645 if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length-1&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}}
646646 if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:function(node){var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}else{$(node).addClass('wikiEditor-template-text');}},beforeUnwrap:function(node){if($(node).parent().hasClass('wikiEditor-template')){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}},onSkip:function(node){if($(node).html()==$(node).data('oldHTML')){return;}
647647 var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if($(node).parent().hasClass('wikiEditor-template')){var $label=$(node).parent().find('.wikiEditor-template-label');var displayName=$.wikiEditor.modules.templateEditor.fn.getTemplateDisplayName(model);if($label.text()!=displayName){$label.text(displayName);}}
648 -if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}},keydown:function(context,event){if(context.$iframe.data('ignoreKeypress')){context.$iframe.data('ignoreKeypress',false);}
 648+if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context,skipDivision:"realchange"});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}},keydown:function(context,event){if(context.$iframe.data('ignoreKeypress')){context.$iframe.data('ignoreKeypress',false);}
649649 var $evtElem=event.jQueryNode;if($evtElem.hasClass('wikiEditor-template-label')){if(event.ctrlKey||event.metaKey)return true;switch(event.which){case 13:$evtElem.click();return false;case 32:$evtElem.parent().siblings('.wikiEditor-template-expand').click();return false;case 37:case 38:case 39:case 40:return true;default:context.$iframe.data('ignoreKeypress',true);return false;}}else if($evtElem.hasClass('wikiEditor-template-text')){switch(event.which){case 13:context.$iframe.data('ignoreKeypress',true);context.fn.encapsulateSelection({'pre':'\n','peri':'','post':''});return false;default:return true;}}},keyup:function(context,event){if(context.$iframe.data('ignoreKeypress')){context.$iframe.data('ignoreKeypress',false);}
650650 return true;},keypress:function(context,event){return(context.$iframe.data('ignoreKeypress')?false:true);}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('model');var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').prepend($('<span class="wikiEditor-template-expand wikiEditor-noinclude"></span>'+'<span class="wikiEditor-template-name wikiEditor-noinclude">'+'<span class="wikiEditor-template-label wikiEditor-noinclude">'+
651651 $.wikiEditor.modules.templateEditor.fn.getTemplateDisplayName(model)+'</span>'+'<span class="wikiEditor-template-dialog wikiEditor-noinclude"></span>'+'</span>'));},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},bindTemplateEvents:function($wrapper){var $template=$wrapper.parent('.wikiEditor-template');$template.find('.wikiEditor-template-name').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-expand').click(function(){$.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor($wrapper);return false;}).mousedown(function(){return false;});},toggleWikiTextEditor:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');context.fn.purgeOffsets();$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('.wikiEditor-template-text').toggleClass('wikiEditor-nodisplay');},createDialog:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\

Follow-up revisions

RevisionCommit summaryAuthorDate
r63822UsabilityInitiative: Style changes for r63789, r63797catrope18:33, 16 March 2010

Status & tagging log