http://www.mediawiki.org/wiki/Special:Code/MediaWiki/58423
Revision: 58423 Author: catrope Date: 2009-11-02 10:04:35 +0000 (Mon, 02 Nov 2009) Log Message: ----------- EditToolbar: (bug 21363) API for adding dialogs is broken. Also make open/closeDialog less ugly Modified Paths: -------------- trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js trunk/extensions/UsabilityInitiative/js/plugins.combined.js trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js Modified: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php =================================================================== --- trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php 2009-11-02 09:42:33 UTC (rev 58422) +++ trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php 2009-11-02 10:04:35 UTC (rev 58423) @@ -70,15 +70,15 @@ array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ), array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ), array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ), - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 17 ), - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 7 ), + array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 18 ), + array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 8 ), array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 24 ), ), 'combined' => array( - array( 'src' => 'js/plugins.combined.js', 'version' => 55 ), + array( 'src' => 'js/plugins.combined.js', 'version' => 56 ), ), 'minified' => array( - array( 'src' => 'js/plugins.combined.min.js', 'version' => 55 ), + array( 'src' => 'js/plugins.combined.min.js', 'version' => 56 ), ), ), ); Modified: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js 2009-11-02 09:42:33 UTC (rev 58422) +++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js 2009-11-02 10:04:35 UTC (rev 58423) @@ -14,16 +14,16 @@ */ api: { addDialog: function( context, data ) { - $.wikiEditor.modules.dialogs.fn.create( context, { 'modules': data } ) + $.wikiEditor.modules.dialogs.fn.create( context, data ) }, - openDialog: function( context, data ) { - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) { - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'open' ); + openDialog: function( context, module ) { + if ( module in $.wikiEditor.modules.dialogs.modules ) { + $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'open' ); } }, closeDialog: function( context, data ) { - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) { - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'close' ); + if ( module in $.wikiEditor.modules.dialogs.modules ) { + $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'close' ); } } }, Modified: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js 2009-11-02 09:42:33 UTC (rev 58422) +++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js 2009-11-02 10:04:35 UTC (rev 58423) @@ -239,7 +239,7 @@ } break; case 'dialog': - context.$textarea.wikiEditor( 'openDialog', { 'dialog': action.module } ); + context.$textarea.wikiEditor( 'openDialog', action.module ); break; default: break; } Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2009-11-02 09:42:33 UTC (rev 58422) +++ trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2009-11-02 10:04:35 UTC (rev 58423) @@ -1492,16 +1492,16 @@ */ api: { addDialog: function( context, data ) { - $.wikiEditor.modules.dialogs.fn.create( context, { 'modules': data } ) + $.wikiEditor.modules.dialogs.fn.create( context, data ) }, - openDialog: function( context, data ) { - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) { - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'open' ); + openDialog: function( context, module ) { + if ( module in $.wikiEditor.modules.dialogs.modules ) { + $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'open' ); } }, closeDialog: function( context, data ) { - if ( data.dialog in $.wikiEditor.modules.dialogs.modules ) { - $( '#' + $.wikiEditor.modules.dialogs.modules[data.dialog].id ).dialog( 'close' ); + if ( module in $.wikiEditor.modules.dialogs.modules ) { + $( '#' + $.wikiEditor.modules.dialogs.modules[module].id ).dialog( 'close' ); } } }, @@ -1878,7 +1878,7 @@ } break; case 'dialog': - context.$textarea.wikiEditor( 'openDialog', { 'dialog': action.module } ); + context.$textarea.wikiEditor( 'openDialog', action.module ); break; default: break; } Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js 2009-11-02 09:42:33 UTC (rev 58422) +++ trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js 2009-11-02 10:04:35 UTC (rev 58423) @@ -88,7 +88,7 @@ $(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);}} 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];}}}}} 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]);}}} -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];} +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];} 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) 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) 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 @@ 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]||'')}} 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);}} 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);} -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>')} +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>')} if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}} return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}} 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;} _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs