r62966 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62965‎ | r62966 | r62967 >
Date:17:44, 25 February 2010
Author:catrope
Status:ok
Tags:
Comment:
UsabilityInitiative: Reduce code duplication by implementing some code in terms of $.wikiEditor.autoMsg()
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.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -74,7 +74,7 @@
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 154 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 34 ),
78 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 51 ),
 78+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 19 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 94 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
@@ -82,10 +82,10 @@
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 289 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 290 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 289 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 290 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -239,15 +239,11 @@
240240 switch ( action.type ) {
241241 case 'replace':
242242 case 'encapsulate':
243 - var parts = { 'pre' : '', 'peri' : '', 'post' : '' };
244 - for ( part in parts ) {
245 - if ( part + 'Msg' in action.options ) {
246 - parts[part] = mw.usability.getMsg(
247 - action.options[part + 'Msg'], ( action.options[part] || null ) );
248 - } else {
249 - parts[part] = ( action.options[part] || '' )
250 - }
251 - }
 243+ var parts = {
 244+ 'pre' : $.wikiEditor.autoMsg( action.options, 'pre' ),
 245+ 'peri' : $.wikiEditor.autoMsg( action.options, 'peri' ),
 246+ 'post' : $.wikiEditor.autoMsg( action.options, 'post' )
 247+ };
252248 if ( 'regex' in action.options && 'regexReplace' in action.options ) {
253249 var selection = context.$textarea.textSelection( 'getSelection' );
254250 if ( selection != '' && selection.match( action.options.regex ) ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -10544,15 +10544,11 @@
1054510545 switch ( action.type ) {
1054610546 case 'replace':
1054710547 case 'encapsulate':
10548 - var parts = { 'pre' : '', 'peri' : '', 'post' : '' };
10549 - for ( part in parts ) {
10550 - if ( part + 'Msg' in action.options ) {
10551 - parts[part] = mw.usability.getMsg(
10552 - action.options[part + 'Msg'], ( action.options[part] || null ) );
10553 - } else {
10554 - parts[part] = ( action.options[part] || '' )
10555 - }
10556 - }
 10548+ var parts = {
 10549+ 'pre' : $.wikiEditor.autoMsg( action.options, 'pre' ),
 10550+ 'peri' : $.wikiEditor.autoMsg( action.options, 'peri' ),
 10551+ 'post' : $.wikiEditor.autoMsg( action.options, 'post' )
 10552+ };
1055710553 if ( 'regex' in action.options && 'regexReplace' in action.options ) {
1055810554 var selection = context.$textarea.textSelection( 'getSelection' );
1055910555 if ( selection != '' && selection.match( action.options.regex ) ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -723,8 +723,7 @@
724724 i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));}
725725 step=step.parent();}
726726 rels.reverse();var id=rels.join('.');$.trackAction(id);}
727 -switch(action.type){case'replace':case'encapsulate':var parts={'pre':'','peri':'','post':''};for(part in parts){if(part+'Msg'in action.options){parts[part]=mw.usability.getMsg(action.options[part+'Msg'],(action.options[part]||null));}else{parts[part]=(action.options[part]||'')}}
728 -if('regex'in action.options&&'regexReplace'in action.options){var selection=context.$textarea.textSelection('getSelection');if(selection!=''&&selection.match(action.options.regex)){parts.peri=selection.replace(action.options.regex,action.options.regexReplace);parts.pre=parts.post='';}}
 727+switch(action.type){case'replace':case'encapsulate':var parts={'pre':$.wikiEditor.autoMsg(action.options,'pre'),'peri':$.wikiEditor.autoMsg(action.options,'peri'),'post':$.wikiEditor.autoMsg(action.options,'post')};if('regex'in action.options&&'regexReplace'in action.options){var selection=context.$textarea.textSelection('getSelection');if(selection!=''&&selection.match(action.options.regex)){parts.peri=selection.replace(action.options.regex,action.options.regexReplace);parts.pre=parts.post='';}}
729728 context.$textarea.textSelection('encapsulateSelection',$.extend({},action.options,parts,{'replace':action.type=='replace'}));if(typeof context.$iframe!=='undefined'){context.$iframe[0].contentWindow.focus();}
730729 break;case'callback':if(typeof action.execute=='function'){action.execute(context);}
731730 break;case'dialog':context.fn.saveSelection();context.$textarea.wikiEditor('openDialog',action.module);break;default:break;}},buildGroup:function(context,id,group){var $group=$('<div />').attr({'class':'group group-'+id,'rel':id});var label=$.wikiEditor.autoMsg(group,'label');if(label){$group.append('<div class="label">'+label+'</div>')}

Follow-up revisions

RevisionCommit summaryAuthorDate
r64222UsabilityInitiative: (bug 22964) Fix regression from r62966 causing image but...catrope20:38, 26 March 2010

Status & tagging log