r58926 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58925‎ | r58926 | r58927 >
Date:20:26, 11 November 2009
Author:catrope
Status:ok
Tags:
Comment:
UsabilityInitiative: Toolbar: Don't add empty sections resulting in a double line
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
@@ -71,16 +71,16 @@
7272 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7373 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 20 ),
7474 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 15 ),
75 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 24 ),
 75+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 25 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 35 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 3 ),
7979 ),
8080 'combined' => array(
81 - array( 'src' => 'js/plugins.combined.js', 'version' => 72 ),
 81+ array( 'src' => 'js/plugins.combined.js', 'version' => 73 ),
8282 ),
8383 'minified' => array(
84 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 72 ),
 84+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 73 ),
8585 ),
8686 ),
8787 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -250,12 +250,18 @@
251251 if ( label ) {
252252 $group.append( '<div class="label">' + label + '</div>' )
253253 }
 254+
 255+ var empty = true;
254256 if ( 'tools' in group ) {
255257 for ( tool in group.tools ) {
256 - $group.append( $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] ) );
 258+ var tool = $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] );
 259+ if ( tool ) {
 260+ empty = false;
 261+ $group.append( tool );
 262+ }
257263 }
258264 }
259 - return $group;
 265+ return empty ? null : $group;
260266 },
261267 buildTool : function( context, id, tool ) {
262268 if ( 'filters' in tool ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2159,12 +2159,18 @@
21602160 if ( label ) {
21612161 $group.append( '<div class="label">' + label + '</div>' )
21622162 }
 2163+
 2164+ var empty = true;
21632165 if ( 'tools' in group ) {
21642166 for ( tool in group.tools ) {
2165 - $group.append( $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] ) );
 2167+ var tool = $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] );
 2168+ if ( tool ) {
 2169+ empty = false;
 2170+ $group.append( tool );
 2171+ }
21662172 }
21672173 }
2168 - return $group;
 2174+ return empty ? null : $group;
21692175 },
21702176 buildTool : function( context, id, tool ) {
21712177 if ( 'filters' in tool ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -127,8 +127,8 @@
128128 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='';}}
129129 context.$textarea.textSelection('encapsulateSelection',$.extend(action.options,parts,{'replace':action.type=='replace'}));break;case'callback':if(typeof action.execute=='function'){action.execute(context);}
130130 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>')}
131 -if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}}
132 -return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
 131+var empty=true;if('tools'in group){for(tool in group.tools){var tool=$.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]);if(tool){empty=false;$group.append(tool);}}}
 132+return empty?null:$group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
133133 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;}
134134 $button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});}
135135 return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'}).click(function(){var $options=$(this).find('.options');$options.animate({'opacity':'toggle'},'fast');});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));}).text(optionLabel).addClass('option').attr('rel',option));}}

Follow-up revisions

RevisionCommit summaryAuthorDate
r58927usability: Merge r58926 (double line in toolbar fix) to acaifixcatrope20:29, 11 November 2009
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009

Status & tagging log