r63840 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63839‎ | r63840 | r63841 >
Date:22:20, 16 March 2010
Author:nimishg
Status:ok (Comments)
Tags:
Comment:
mark called less and things less broken
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' => 173 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 47 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 48 ),
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' => 64 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 65 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 347 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 348 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 347 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 348 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -39,6 +39,9 @@
4040
4141 mark: function( context, event ) {
4242 // Get references to the markers and tokens from the current context
 43+ if(context.modules.highlight.currentScope == "realchange"){
 44+ return; //do nothing on realchange
 45+ }
4346 var markers = context.modules.highlight.markers;
4447 var tokenArray = context.modules.highlight.tokenArray;
4548 // Collect matching level 0 template call boundaries from the tokenArray
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -38,6 +38,7 @@
3939 * ; Definition
4040 * : Definition
4141 */
 42+ $.wikiEditor.modules.highlight.currentScope = event.data.scope;
4243 if ( event.data.scope == 'realchange' ) {
4344 $.wikiEditor.modules.highlight.fn.scan( context, "" );
4445 $.wikiEditor.modules.highlight.fn.mark( context, "realchange", "" );
@@ -45,6 +46,7 @@
4647 },
4748 ready: function( context, event ) {
4849 // Highlight stuff for the first time
 50+ $.wikiEditor.modules.highlight.currentScope = "ready";
4951 $.wikiEditor.modules.highlight.fn.scan( context, "" );
5052 $.wikiEditor.modules.highlight.fn.mark( context, "", "" );
5153 }
@@ -150,11 +152,19 @@
151153 // FIXME: What do division and tokens do?
152154 // TODO: Document the scan() and mark() APIs somewhere
153155 mark: function( context, division, tokens ) {
 156+
154157 // Reset markers
155 -
156 - var markers = context.modules.highlight.markers = [];
 158+ var markers = [];
 159+ if(context.modules.highlight.markers && division !=""){
 160+ for(var i = 0; i < markers.length; i++){
 161+ if(context.modules.highlight.markers[i].skipDivision == division){
 162+ markers.push(context.modules.highlight.markers[i]);
 163+ }
 164+ }
 165+ }
 166+ context.modules.highlight.markers = markers;
 167+
157168 // Get all markers
158 -
159169 context.fn.trigger( 'mark' );
160170 markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
161171
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -8573,6 +8573,7 @@
85748574 * ; Definition
85758575 * : Definition
85768576 */
 8577+ $.wikiEditor.modules.highlight.currentScope = event.data.scope;
85778578 if ( event.data.scope == 'realchange' ) {
85788579 $.wikiEditor.modules.highlight.fn.scan( context, "" );
85798580 $.wikiEditor.modules.highlight.fn.mark( context, "realchange", "" );
@@ -8580,6 +8581,7 @@
85818582 },
85828583 ready: function( context, event ) {
85838584 // Highlight stuff for the first time
 8585+ $.wikiEditor.modules.highlight.currentScope = "ready";
85848586 $.wikiEditor.modules.highlight.fn.scan( context, "" );
85858587 $.wikiEditor.modules.highlight.fn.mark( context, "", "" );
85868588 }
@@ -8685,11 +8687,19 @@
86868688 // FIXME: What do division and tokens do?
86878689 // TODO: Document the scan() and mark() APIs somewhere
86888690 mark: function( context, division, tokens ) {
 8691+
86898692 // Reset markers
8690 -
8691 - var markers = context.modules.highlight.markers = [];
 8693+ var markers = [];
 8694+ if(context.modules.highlight.markers && division !=""){
 8695+ for(var i = 0; i < markers.length; i++){
 8696+ if(context.modules.highlight.markers[i].skipDivision == division){
 8697+ markers.push(context.modules.highlight.markers[i]);
 8698+ }
 8699+ }
 8700+ }
 8701+ context.modules.highlight.markers = markers;
 8702+
86928703 // Get all markers
8693 -
86948704 context.fn.trigger( 'mark' );
86958705 markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
86968706
@@ -9253,6 +9263,9 @@
92549264
92559265 mark: function( context, event ) {
92569266 // Get references to the markers and tokens from the current context
 9267+ if(context.modules.highlight.currentScope == "realchange"){
 9268+ return; //do nothing on realchange
 9269+ }
92579270 var markers = context.modules.highlight.markers;
92589271 var tokenArray = context.modules.highlight.tokenArray;
92599272 // Collect matching level 0 template call boundaries from the tokenArray
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -584,11 +584,12 @@
585585 configuration.newButtons[mw.usability.getMsg(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});}
586586 dialogDiv.bind('dialogclose',function(){context.fn.restoreSelection();});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
587587 maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});context.$textarea.trigger('wikiEditor-dialogs-loaded-'+mod);}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);}
588 -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"realchange","");}},ready:function(context,event){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){context.modules.highlight.markersStr='';},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;}
 588+$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){$.wikiEditor.modules.highlight.currentScope=event.data.scope;if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"realchange","");}},ready:function(context,event){$.wikiEditor.modules.highlight.currentScope="ready";$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){context.modules.highlight.markersStr='';},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;}
589589 var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
590590 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;}
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);}}}}
592 -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+',';}
 592+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=[];if(context.modules.highlight.markers&&division!=""){for(var i=0;i<markers.length;i++){if(context.modules.highlight.markers[i].skipDivision==division){markers.push(context.modules.highlight.markers[i]);}}}
 593+context.modules.highlight.markers=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+',';}
593594 if(context.modules.highlight.markersStr==markersStr){return;}
594595 context.modules.highlight.markersStr=markersStr;var visited=[],v=0;for(var i=0;i<markers.length;i++){if(typeof markers[i].skipDivision!=='undefined'&&(division==markers[i].skipDivision)){continue;}
595596 var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;}
@@ -642,7 +643,8 @@
643644 $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked'))
644645 $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0)
645646 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
646 -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'nameMappings':{"Infobox skyscraper":"building_name","Infobox settlement":"official_name"},'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],evt:{mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;}
 647+$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'nameMappings':{"Infobox skyscraper":"building_name","Infobox settlement":"official_name"},'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],evt:{mark:function(context,event){if(context.modules.highlight.currentScope=="realchange"){return;}
 648+var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;}
647649 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;}}}
648650 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;}
649651 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);}}

Follow-up revisions

RevisionCommit summaryAuthorDate
r63859UsabilityInitiative: Followup to r63840: add some comments to explain what's ...catrope11:37, 17 March 2010

Comments

#Comment by Nimish Gautam (talk | contribs)   22:34, 16 March 2010

admittedly a somewhat dirty way to make it so mark does nothing for templates if the scope is a realchange

Status & tagging log