r64724 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64723‎ | r64724 | r64725 >
Date:21:32, 7 April 2010
Author:adam
Status:ok
Tags:
Comment:
Fixing a Toolbar issue where certain configurations could cause dropdowns to expand to incorrect heights.
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' => 30 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 181 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 52 ),
78 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 56 ),
 78+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 57 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 23 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 98 ),
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' => 5 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 378 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 379 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 378 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 379 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -178,7 +178,7 @@
179179 */
180180 evt: {
181181 resize: function( context, event ) {
182 - context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section:visible' ).outerHeight() );
 182+ context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section-visible' ).outerHeight() );
183183 },
184184 tocCollapse: function( context, event ) {
185185 $.wikiEditor.modules.toolbar.evt.resize( context, event );
@@ -573,12 +573,14 @@
574574 var $section =
575575 $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
576576 var show = $section.css( 'display' ) == 'none';
577 - $previousSections = $section.parent().find( '.section:visible' );
 577+ $previousSections = $section.parent().find( '.section-visible' );
578578 $previousSections.css( 'position', 'absolute' );
 579+ $previousSections.removeClass( 'section-visible' );
579580 $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
580581 $(this).parent().parent().find( 'a' ).removeClass( 'current' );
581582 $sections.css( 'overflow', 'hidden' );
582583 if ( show ) {
 584+ $section.addClass( 'section-visible' );
583585 $section.fadeIn( 'fast' );
584586 $sections
585587 .css( 'display', 'block' )
@@ -646,6 +648,7 @@
647649 if ( $section !== null && id !== 'main' ) {
648650 var show = selected == id;
649651 $section.css( 'display', show ? 'block' : 'none' );
 652+ if ( show ) $section.addClass( 'section-visible' );
650653 }
651654 return $section;
652655 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -11021,7 +11021,7 @@
1102211022 */
1102311023 evt: {
1102411024 resize: function( context, event ) {
11025 - context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section:visible' ).outerHeight() );
 11025+ context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section-visible' ).outerHeight() );
1102611026 },
1102711027 tocCollapse: function( context, event ) {
1102811028 $.wikiEditor.modules.toolbar.evt.resize( context, event );
@@ -11416,12 +11416,14 @@
1141711417 var $section =
1141811418 $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
1141911419 var show = $section.css( 'display' ) == 'none';
11420 - $previousSections = $section.parent().find( '.section:visible' );
 11420+ $previousSections = $section.parent().find( '.section-visible' );
1142111421 $previousSections.css( 'position', 'absolute' );
 11422+ $previousSections.removeClass( 'section-visible' );
1142211423 $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
1142311424 $(this).parent().parent().find( 'a' ).removeClass( 'current' );
1142411425 $sections.css( 'overflow', 'hidden' );
1142511426 if ( show ) {
 11427+ $section.addClass( 'section-visible' );
1142611428 $section.fadeIn( 'fast' );
1142711429 $sections
1142811430 .css( 'display', 'block' )
@@ -11489,6 +11491,7 @@
1149011492 if ( $section !== null && id !== 'main' ) {
1149111493 var show = selected == id;
1149211494 $section.css( 'display', show ? 'block' : 'none' );
 11495+ if ( show ) $section.addClass( 'section-visible' );
1149311496 }
1149411497 return $section;
1149511498 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -750,7 +750,7 @@
751751 break;case'characters':if(!('section'in data&&'page'in data)){continue;}
752752 $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(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);e.preventDefault();return false;}));}
753753 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();}
754 -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;}
 754+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;}
755755 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;}
756756 i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));}
757757 step=step.parent();}
@@ -778,12 +778,12 @@
779779 return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+
780780 $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';}
781781 html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'encapsulate','options':{'pre':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'encapsulate','options':{'pre':character[1]}}};}
782 -if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).mouseup(function(e){$(this).blur();}).mousedown(function(e){e.preventDefault();return false;}).click(function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.fadeIn('fast');$sections.css('display','block').animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');context.fn.trigger('resize');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':'hide'},$section.outerHeight()*2,function(){$(this).css({'overflow':'visible','height':0});context.fn.trigger('resize');});}
 782+if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).mouseup(function(e){$(this).blur();}).mousedown(function(e){e.preventDefault();return false;}).click(function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section-visible');$previousSections.css('position','absolute');$previousSections.removeClass('section-visible');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.addClass('section-visible');$section.fadeIn('fast');$sections.css('display','block').animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');context.fn.trigger('resize');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':'hide'},$section.outerHeight()*2,function(){$(this).css({'overflow':'visible','height':0});context.fn.trigger('resize');});}
783783 if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));}
784784 $.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);e.preventDefault();return false;}));},buildSection:function(context,id,section){context.$textarea.trigger('wikiEditor-toolbar-buildSection-'+id,[section]);var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div />').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}}
785785 break;case'booklet':var $pages=$('<div />').addClass('pages');var $index=$('<div />').addClass('index');if('pages'in section){for(page in section.pages){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,section.pages[page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,section.pages[page]));}}
786786 $section=$('<div />').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;}
787 -if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');}
 787+if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');if(show)$section.addClass('section-visible');}
788788 return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);}
789789 $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.toolbar.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.toolbar.$toolbar);context.modules.toolbar.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.toolbar.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}}
790790 $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));var $section=s.$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){context.fn.trigger('resize');});}}});}}};})(jQuery);
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r65959Merge Vector and UsabilityInitiative fixes from trunk: r64724, r65064, r65379...catrope19:03, 5 May 2010

Status & tagging log