Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ), |
76 | 76 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 144 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 34 ), |
78 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 49 ), |
| 78 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 50 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 18 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 93 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 272 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 273 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 272 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 273 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -11,15 +11,12 @@ |
12 | 12 | for ( type in data ) { |
13 | 13 | switch ( type ) { |
14 | 14 | case 'sections': |
15 | | - var $sections = context.modules.toolbar.$toolbar |
16 | | - .find( 'div.sections' ); |
17 | | - var $tabs = context.modules.toolbar.$toolbar |
18 | | - .find( 'div.tabs' ); |
| 15 | + var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' ); |
| 16 | + var $tabs = context.modules.toolbar.$toolbar.find( 'div.tabs' ); |
19 | 17 | for ( section in data[type] ) { |
20 | 18 | if ( section == 'main' ) { |
21 | 19 | // Section |
22 | | - context.modules.toolbar.$toolbar |
23 | | - .prepend( |
| 20 | + context.modules.toolbar.$toolbar.prepend( |
24 | 21 | $.wikiEditor.modules.toolbar.fn.buildSection( |
25 | 22 | context, section, data[type][section] |
26 | 23 | ) |
— | — | @@ -45,33 +42,39 @@ |
46 | 43 | if ( ! ( 'section' in data ) ) { |
47 | 44 | continue; |
48 | 45 | } |
49 | | - var $section = context.modules.toolbar.$toolbar |
50 | | - .find( 'div[rel=' + data.section + '].section' ); |
| 46 | + var $section = context.modules.toolbar.$toolbar.find( 'div[rel=' + data.section + '].section' ); |
51 | 47 | for ( group in data[type] ) { |
52 | 48 | // Group |
53 | | - $section |
54 | | - .append( $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] ) ); |
| 49 | + $section.append( |
| 50 | + $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] ) |
| 51 | + ); |
55 | 52 | } |
56 | 53 | break; |
57 | 54 | case 'tools': |
58 | 55 | if ( ! ( 'section' in data && 'group' in data ) ) { |
59 | 56 | continue; |
60 | 57 | } |
61 | | - var $group = context.modules.toolbar.$toolbar |
62 | | - .find( 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group' ); |
| 58 | + var $group = context.modules.toolbar.$toolbar.find( |
| 59 | + 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group' |
| 60 | + ); |
63 | 61 | for ( tool in data[type] ) { |
64 | 62 | // Tool |
65 | 63 | $group.append( $.wikiEditor.modules.toolbar.fn.buildTool( context, tool,data[type][tool] ) ); |
66 | 64 | } |
| 65 | + if ( $group.children().length ) { |
| 66 | + $group.show(); |
| 67 | + } |
67 | 68 | break; |
68 | 69 | case 'pages': |
69 | 70 | if ( ! ( 'section' in data ) ) { |
70 | 71 | continue; |
71 | 72 | } |
72 | | - var $pages = context.modules.toolbar.$toolbar |
73 | | - .find( 'div[rel=' + data.section + '].section .pages' ); |
74 | | - var $index = context.modules.toolbar.$toolbar |
75 | | - .find( 'div[rel=' + data.section + '].section .index' ); |
| 73 | + var $pages = context.modules.toolbar.$toolbar.find( |
| 74 | + 'div[rel=' + data.section + '].section .pages' |
| 75 | + ); |
| 76 | + var $index = context.modules.toolbar.$toolbar.find( |
| 77 | + 'div[rel=' + data.section + '].section .index' |
| 78 | + ); |
76 | 79 | for ( page in data[type] ) { |
77 | 80 | // Page |
78 | 81 | $pages.append( $.wikiEditor.modules.toolbar.fn.buildPage( context, page, data[type][page] ) ); |
— | — | @@ -120,15 +123,17 @@ |
121 | 124 | } |
122 | 125 | }, |
123 | 126 | removeFromToolbar : function( context, data ) { |
124 | | - js_log("f:removeFromToolbar"); |
125 | 127 | if ( typeof data.section == 'string' ) { |
126 | 128 | // Section |
127 | 129 | var tab = 'div.tabs span[rel=' + data.section + '].tab'; |
128 | 130 | var target = 'div[rel=' + data.section + '].section'; |
| 131 | + var group = null; |
129 | 132 | if ( typeof data.group == 'string' ) { |
130 | 133 | // Toolbar group |
131 | 134 | target += ' div[rel=' + data.group + '].group'; |
132 | 135 | if ( typeof data.tool == 'string' ) { |
| 136 | + // Save for later checking if empty |
| 137 | + group = target; |
133 | 138 | // Tool |
134 | 139 | target += ' div[rel=' + data.tool + '].tool'; |
135 | 140 | } |
— | — | @@ -156,8 +161,14 @@ |
157 | 162 | // Just a section, remove the tab too! |
158 | 163 | context.modules.toolbar.$toolbar.find( tab ).remove(); |
159 | 164 | } |
160 | | - js_log('target is: ' + target); |
161 | 165 | context.modules.toolbar.$toolbar.find( target ).remove(); |
| 166 | + // Hide empty groups |
| 167 | + if ( group ) { |
| 168 | + $group = context.modules.toolbar.$toolbar.find( group ); |
| 169 | + if ( $group.children().length == 0 ) { |
| 170 | + $group.hide(); |
| 171 | + } |
| 172 | + } |
162 | 173 | } |
163 | 174 | } |
164 | 175 | }, |
— | — | @@ -271,7 +282,6 @@ |
272 | 283 | if ( label ) { |
273 | 284 | $group.append( '<div class="label">' + label + '</div>' ) |
274 | 285 | } |
275 | | - |
276 | 286 | var empty = true; |
277 | 287 | if ( 'tools' in group ) { |
278 | 288 | for ( tool in group.tools ) { |
— | — | @@ -282,7 +292,10 @@ |
283 | 293 | } |
284 | 294 | } |
285 | 295 | } |
286 | | - return empty ? null : $group; |
| 296 | + if ( empty ) { |
| 297 | + $group.hide(); |
| 298 | + } |
| 299 | + return $group; |
287 | 300 | }, |
288 | 301 | buildTool : function( context, id, tool ) { |
289 | 302 | if ( 'filters' in tool ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -10272,15 +10272,12 @@ |
10273 | 10273 | for ( type in data ) { |
10274 | 10274 | switch ( type ) { |
10275 | 10275 | case 'sections': |
10276 | | - var $sections = context.modules.toolbar.$toolbar |
10277 | | - .find( 'div.sections' ); |
10278 | | - var $tabs = context.modules.toolbar.$toolbar |
10279 | | - .find( 'div.tabs' ); |
| 10276 | + var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' ); |
| 10277 | + var $tabs = context.modules.toolbar.$toolbar.find( 'div.tabs' ); |
10280 | 10278 | for ( section in data[type] ) { |
10281 | 10279 | if ( section == 'main' ) { |
10282 | 10280 | // Section |
10283 | | - context.modules.toolbar.$toolbar |
10284 | | - .prepend( |
| 10281 | + context.modules.toolbar.$toolbar.prepend( |
10285 | 10282 | $.wikiEditor.modules.toolbar.fn.buildSection( |
10286 | 10283 | context, section, data[type][section] |
10287 | 10284 | ) |
— | — | @@ -10306,33 +10303,39 @@ |
10307 | 10304 | if ( ! ( 'section' in data ) ) { |
10308 | 10305 | continue; |
10309 | 10306 | } |
10310 | | - var $section = context.modules.toolbar.$toolbar |
10311 | | - .find( 'div[rel=' + data.section + '].section' ); |
| 10307 | + var $section = context.modules.toolbar.$toolbar.find( 'div[rel=' + data.section + '].section' ); |
10312 | 10308 | for ( group in data[type] ) { |
10313 | 10309 | // Group |
10314 | | - $section |
10315 | | - .append( $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] ) ); |
| 10310 | + $section.append( |
| 10311 | + $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] ) |
| 10312 | + ); |
10316 | 10313 | } |
10317 | 10314 | break; |
10318 | 10315 | case 'tools': |
10319 | 10316 | if ( ! ( 'section' in data && 'group' in data ) ) { |
10320 | 10317 | continue; |
10321 | 10318 | } |
10322 | | - var $group = context.modules.toolbar.$toolbar |
10323 | | - .find( 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group' ); |
| 10319 | + var $group = context.modules.toolbar.$toolbar.find( |
| 10320 | + 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group' |
| 10321 | + ); |
10324 | 10322 | for ( tool in data[type] ) { |
10325 | 10323 | // Tool |
10326 | 10324 | $group.append( $.wikiEditor.modules.toolbar.fn.buildTool( context, tool,data[type][tool] ) ); |
10327 | 10325 | } |
| 10326 | + if ( $group.children().length ) { |
| 10327 | + $group.show(); |
| 10328 | + } |
10328 | 10329 | break; |
10329 | 10330 | case 'pages': |
10330 | 10331 | if ( ! ( 'section' in data ) ) { |
10331 | 10332 | continue; |
10332 | 10333 | } |
10333 | | - var $pages = context.modules.toolbar.$toolbar |
10334 | | - .find( 'div[rel=' + data.section + '].section .pages' ); |
10335 | | - var $index = context.modules.toolbar.$toolbar |
10336 | | - .find( 'div[rel=' + data.section + '].section .index' ); |
| 10334 | + var $pages = context.modules.toolbar.$toolbar.find( |
| 10335 | + 'div[rel=' + data.section + '].section .pages' |
| 10336 | + ); |
| 10337 | + var $index = context.modules.toolbar.$toolbar.find( |
| 10338 | + 'div[rel=' + data.section + '].section .index' |
| 10339 | + ); |
10337 | 10340 | for ( page in data[type] ) { |
10338 | 10341 | // Page |
10339 | 10342 | $pages.append( $.wikiEditor.modules.toolbar.fn.buildPage( context, page, data[type][page] ) ); |
— | — | @@ -10381,15 +10384,17 @@ |
10382 | 10385 | } |
10383 | 10386 | }, |
10384 | 10387 | removeFromToolbar : function( context, data ) { |
10385 | | - js_log("f:removeFromToolbar"); |
10386 | 10388 | if ( typeof data.section == 'string' ) { |
10387 | 10389 | // Section |
10388 | 10390 | var tab = 'div.tabs span[rel=' + data.section + '].tab'; |
10389 | 10391 | var target = 'div[rel=' + data.section + '].section'; |
| 10392 | + var group = null; |
10390 | 10393 | if ( typeof data.group == 'string' ) { |
10391 | 10394 | // Toolbar group |
10392 | 10395 | target += ' div[rel=' + data.group + '].group'; |
10393 | 10396 | if ( typeof data.tool == 'string' ) { |
| 10397 | + // Save for later checking if empty |
| 10398 | + group = target; |
10394 | 10399 | // Tool |
10395 | 10400 | target += ' div[rel=' + data.tool + '].tool'; |
10396 | 10401 | } |
— | — | @@ -10417,8 +10422,14 @@ |
10418 | 10423 | // Just a section, remove the tab too! |
10419 | 10424 | context.modules.toolbar.$toolbar.find( tab ).remove(); |
10420 | 10425 | } |
10421 | | - js_log('target is: ' + target); |
10422 | 10426 | context.modules.toolbar.$toolbar.find( target ).remove(); |
| 10427 | + // Hide empty groups |
| 10428 | + if ( group ) { |
| 10429 | + $group = context.modules.toolbar.$toolbar.find( group ); |
| 10430 | + if ( $group.children().length == 0 ) { |
| 10431 | + $group.hide(); |
| 10432 | + } |
| 10433 | + } |
10423 | 10434 | } |
10424 | 10435 | } |
10425 | 10436 | }, |
— | — | @@ -10532,7 +10543,6 @@ |
10533 | 10544 | if ( label ) { |
10534 | 10545 | $group.append( '<div class="label">' + label + '</div>' ) |
10535 | 10546 | } |
10536 | | - |
10537 | 10547 | var empty = true; |
10538 | 10548 | if ( 'tools' in group ) { |
10539 | 10549 | for ( tool in group.tools ) { |
— | — | @@ -10543,7 +10553,10 @@ |
10544 | 10554 | } |
10545 | 10555 | } |
10546 | 10556 | } |
10547 | | - return empty ? null : $group; |
| 10557 | + if ( empty ) { |
| 10558 | + $group.hide(); |
| 10559 | + } |
| 10560 | + return $group; |
10548 | 10561 | }, |
10549 | 10562 | buildTool : function( context, id, tool ) { |
10550 | 10563 | if ( 'filters' in tool ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -705,14 +705,15 @@ |
706 | 706 | var $section=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section');for(group in data[type]){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,data[type][group]));} |
707 | 707 | break;case'tools':if(!('section'in data&&'group'in data)){continue;} |
708 | 708 | var $group=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.group+'].group');for(tool in data[type]){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,data[type][tool]));} |
| 709 | +if($group.children().length){$group.show();} |
709 | 710 | break;case'pages':if(!('section'in data)){continue;} |
710 | 711 | var $pages=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section .pages');var $index=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section .index');for(page in data[type]){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,data[type][page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,data[type][page]));} |
711 | 712 | $.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;case'rows':if(!('section'in data&&'page'in data)){continue;} |
712 | 713 | var $table=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page table');for(row in data[type]){$table.append($.wikiEditor.modules.toolbar.fn.buildRow(context,data[type][row]));} |
713 | 714 | break;case'characters':if(!('section'in data&&'page'in data)){continue;} |
714 | 715 | $characters=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;}));} |
715 | | -break;default:break;}}},removeFromToolbar:function(context,data){js_log("f:removeFromToolbar");if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.toolbar.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.toolbar.$toolbar.find(target),context.modules.toolbar.$toolbar.find(index));}}else{context.modules.toolbar.$toolbar.find(tab).remove();} |
716 | | -js_log('target is: '+target);context.modules.toolbar.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());},tocCollapse:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);},tocExpand:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;} |
| 716 | +break;default:break;}}},removeFromToolbar:function(context,data){if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';var group=null;if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){group=target;target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.toolbar.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.toolbar.$toolbar.find(target),context.modules.toolbar.$toolbar.find(index));}}else{context.modules.toolbar.$toolbar.find(tab).remove();} |
| 717 | +context.modules.toolbar.$toolbar.find(target).remove();if(group){$group=context.modules.toolbar.$toolbar.find(group);if($group.children().length==0){$group.hide();}}}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());},tocCollapse:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);},tocExpand:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;} |
717 | 718 | context.modules.toolbar.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.toolbar.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;} |
718 | 719 | i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));} |
719 | 720 | step=step.parent();} |
— | — | @@ -723,7 +724,8 @@ |
724 | 725 | break;case'callback':if(typeof action.execute=='function'){action.execute(context);} |
725 | 726 | 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>')} |
726 | 727 | 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);}}} |
727 | | -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;}}} |
| 728 | +if(empty){$group.hide();} |
| 729 | +return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}} |
728 | 730 | var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=$.wikiEditor.autoIcon(tool.icon,$.wikiEditor.imgPath+'toolbar/');$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).mousedown(function(){return false;}).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});} |
729 | 731 | return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'});$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).mousedown(function(){return false;}).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));if($(this).parent().is(':visible')){$(this).parent().animate({'opacity':'toggle'},'fast');} |
730 | 732 | return false;}).text(optionLabel).addClass('option').attr({'rel':option,'href':'#'}));}} |