r64215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64214‎ | r64215 | r64216 >
Date:12:57, 26 March 2010
Author:catrope
Status:deferred
Tags:
Comment:
wmf-deployment: Fix UsabilityInitiative live hack
Modified paths:
  • /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)
  • /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -86,7 +86,7 @@
8787 // Fallback to the wikiEditor browser map if no special map is provided in the module
8888 var mod = module && 'browsers' in module ? module : $.wikiEditor;
8989 // HORRIBLE LIVE HACK
90 - if ( typeof mod.name != 'undefined' && mod.name == 'toc' && typeof wgReallyGiveMeTOC == 'undefined' ) {
 90+ if ( typeof mod.name != 'undefined' && ( mod.name == 'toc' || mod.name == 'highlight' ) && typeof wgReallyGiveMeTOC == 'undefined' ) {
9191 return mod.supported = false;
9292 }
9393 // Check for and make use of cached value and early opportunities to bail
Index: branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -5,6 +5,7 @@
66 * Core Requirements
77 */
88 'req': [ 'iframe' ],
 9+'name': 'highlight',
910 /**
1011 * Configuration
1112 */
Index: branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6629,7 +6629,7 @@
66306630 // Fallback to the wikiEditor browser map if no special map is provided in the module
66316631 var mod = module && 'browsers' in module ? module : $.wikiEditor;
66326632 // HORRIBLE LIVE HACK
6633 - if ( typeof mod.name != 'undefined' && mod.name == 'toc' && typeof wgReallyGiveMeTOC == 'undefined' ) {
 6633+ if ( typeof mod.name != 'undefined' && ( mod.name == 'toc' || mod.name == 'highlight' ) && typeof wgReallyGiveMeTOC == 'undefined' ) {
66346634 return mod.supported = false;
66356635 }
66366636 // Check for and make use of cached value and early opportunities to bail
@@ -8574,6 +8574,7 @@
85758575 * Core Requirements
85768576 */
85778577 'req': [ 'iframe' ],
 8578+'name': 'highlight',
85788579 /**
85798580 * Configuration
85808581 */
Index: branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -443,7 +443,7 @@
444444 options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;}
445445 var context=$(this).data('wikiEditor-context');var hasIframe=context!==undefined&&context.$iframe!==undefined;var needSave=false;if(hasIframe&&context.savedSelection!==null){context.fn.restoreSelection();needSave=true;}
446446 retval=(hasIframe?context.fn:fn)[command].call(this,options);if(hasIframe&&needSave){context.fn.saveSelection();}
447 -return retval;};})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false},'rtl':{'msie':[['>=',8]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(module){var mod=module&&'browsers'in module?module:$.wikiEditor;if(typeof mod.name!='undefined'&&mod.name=='toc'&&typeof wgReallyGiveMeTOC=='undefined'){return mod.supported=false;}
 447+return retval;};})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false},'rtl':{'msie':[['>=',8]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(module){var mod=module&&'browsers'in module?module:$.wikiEditor;if(typeof mod.name!='undefined'&&(mod.name=='toc'||mod.name=='highlight')&&typeof wgReallyGiveMeTOC=='undefined'){return mod.supported=false;}
448448 if(typeof mod.supported!=='undefined'){return mod.supported;}
449449 if(!($.browser.name in mod.browsers[$('body').is('.rtl')?'rtl':'ltr'])){return mod.supported=true;}
450450 var browser=mod.browsers[$('body').is('.rtl')?'rtl':'ltr'][$.browser.name];if(typeof browser!='object'){return mod.supported=false;}
@@ -584,7 +584,7 @@
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);$.wikiEditor.modules.dialogs.fn.setTabindexes(dialogDiv.closest('.ui-dialog').find('button').not('[tabindex]'));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();});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);}
587587 $(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});},setTabindexes:function($elements){var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
588 -maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},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;}
 588+maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},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'],'name':'highlight',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);}}}}

Status & tagging log