r58423 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58422‎ | r58423 | r58424 >
Date:10:04, 2 November 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditToolbar: (bug 21363) API for adding dialogs is broken. Also make open/closeDialog less ugly
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.dialogs.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -70,15 +70,15 @@
7171 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7272 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ),
7373 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
74 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 17 ),
75 - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 7 ),
 74+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 18 ),
 75+ array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 8 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 24 ),
7777 ),
7878 'combined' => array(
79 - array( 'src' => 'js/plugins.combined.js', 'version' => 55 ),
 79+ array( 'src' => 'js/plugins.combined.js', 'version' => 56 ),
8080 ),
8181 'minified' => array(
82 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 55 ),
 82+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 56 ),
8383 ),
8484 ),
8585 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js
@@ -14,16 +14,16 @@
1515 */
1616 api: {
1717 addDialog: function( context, data ) {
18 - $.wikiEditor.modules.dialogs.fn.create( context, { 'modules': data } )
 18+ $.wikiEditor.modules.dialogs.fn.create( context, data )
1919 },
20 - openDialog: function( context, data ) {
21 - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) {
22 - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'open' );
 20+ openDialog: function( context, module ) {
 21+ if ( module in $.wikiEditor.modules.dialogs.modules ) {
 22+ $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'open' );
2323 }
2424 },
2525 closeDialog: function( context, data ) {
26 - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) {
27 - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'close' );
 26+ if ( module in $.wikiEditor.modules.dialogs.modules ) {
 27+ $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'close' );
2828 }
2929 }
3030 },
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -239,7 +239,7 @@
240240 }
241241 break;
242242 case 'dialog':
243 - context.$textarea.wikiEditor( 'openDialog', { 'dialog': action.module } );
 243+ context.$textarea.wikiEditor( 'openDialog', action.module );
244244 break;
245245 default: break;
246246 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1492,16 +1492,16 @@
14931493 */
14941494 api: {
14951495 addDialog: function( context, data ) {
1496 - $.wikiEditor.modules.dialogs.fn.create( context, { 'modules': data } )
 1496+ $.wikiEditor.modules.dialogs.fn.create( context, data )
14971497 },
1498 - openDialog: function( context, data ) {
1499 - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) {
1500 - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'open' );
 1498+ openDialog: function( context, module ) {
 1499+ if ( module in $.wikiEditor.modules.dialogs.modules ) {
 1500+ $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'open' );
15011501 }
15021502 },
15031503 closeDialog: function( context, data ) {
1504 - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) {
1505 - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'close' );
 1504+ if ( module in $.wikiEditor.modules.dialogs.modules ) {
 1505+ $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'close' );
15061506 }
15071507 }
15081508 },
@@ -1878,7 +1878,7 @@
18791879 }
18801880 break;
18811881 case 'dialog':
1882 - context.$textarea.wikiEditor( 'openDialog', { 'dialog': action.module } );
 1882+ context.$textarea.wikiEditor( 'openDialog', action.module );
18831883 break;
18841884 default: break;
18851885 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -88,7 +88,7 @@
8989 $(this).setSelection(pos[0],pos[1]);$(this).data('wikiEditor-cursor',false);}).blur(function(){$(this).data('wikiEditor-cursor',$(this).getCaretPosition(true));});context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}}
9090 if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}}}
9191 if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}}}
92 -return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
 92+return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
9393 mvJsLoader.doLoad(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons)
9494 configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration).bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
9595 maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},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'))-
@@ -114,7 +114,7 @@
115115 switch(action.type){case'replace':case'encapsulate':var parts={'pre':'','peri':'','post':''};for(part in parts){if(part+'Msg'in action.options){parts[part]=gM(action.options[part+'Msg'],(action.options[part]||null));}else{parts[part]=(action.options[part]||'')}}
116116 if('periRegex'in action.options&&'periRegexReplace'in action.options){var selection=context.$textarea.getSelection();if(selection!=''){parts.peri=selection.replace(action.options.periRegex,action.options.periRegexReplace);}}
117117 context.$textarea.encapsulateSelection(parts.pre,parts.peri,parts.post,action.options.ownline,action.type=='replace');break;case'callback':if(typeof action.execute=='function'){action.execute(context);}
118 -break;case'dialog':context.$textarea.wikiEditor('openDialog',{'dialog':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>')}
 118+break;case'dialog':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>')}
119119 if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}}
120120 return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
121121 var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=tool.icon;if(src.indexOf('http://')!==0&&src.indexOf('https://')!==0){src=$.wikiEditor.imgPath+'toolbar/'+src;}

Status & tagging log