r57440 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57439‎ | r57440 | r57441 >
Date:21:44, 6 October 2009
Author:tparscal
Status:ok
Tags:
Comment:
Fixed the strange animation behavior on the toolbar - finally!
Modified paths:
  • /trunk/extensions/UsabilityInitiative/css/combined.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.min.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/wikiEditor.toolbar.css (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/css/wikiEditor.toolbar.css
@@ -10,6 +10,8 @@
1111 float: left;
1212 width: 100%;
1313 clear: both;
 14+ height: 0;
 15+ overflow: hidden;
1416 }
1517 body.rtl .wikiEditor-ui-toolbar .sections {
1618 float: right;
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -167,6 +167,8 @@
168168 float: left;
169169 width: 100%;
170170 clear: both;
 171+ height: 0;
 172+ overflow: hidden;
171173 }
172174 body.rtl .wikiEditor-ui-toolbar .sections {
173175 float: right;
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -151,6 +151,8 @@
152152 float:left;
153153 width:100%;
154154 clear:both;
 155+height:0;
 156+overflow:hidden;
155157 }
156158 body.rtl .wikiEditor-ui-toolbar .sections{
157159 float:right;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -440,44 +440,47 @@
441441 }
442442 },
443443 buildTab : function( context, id, section ) {
444 - var selected = $
445 - .cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
 444+ var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
446445 return $( '<span />' )
447 - .attr( { 'class' : 'tab tab-' + id, 'rel' : id } )
448 - .append(
449 - $( '<a />' )
450 - .addClass( selected == id ? 'current' : null )
451 - .attr( 'href', '#' )
452 - .text( $.wikiEditor.autoMsg( section, 'label' ) )
453 - .data( 'context', context )
454 - .click( function() {
455 - var $section =
456 - $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
457 - $(this).blur();
458 - var show = $section.css( 'display' ) == 'none';
459 - $section.parent().children().hide("fast");
460 - $(this).parent().parent().find( 'a' ).removeClass( 'current' );
461 - if ( show ) {
462 - $section.show("fast");
463 - $(this).addClass( 'current' );
464 - }
465 -
466 - //click tracking
467 - if($.trackAction != undefined){
468 - $.trackAction($section.attr('rel') + '.' + ( show ? 'show': 'hide' ) );
469 - }
470 -
471 - $.cookie(
472 - 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
473 - show ? $section.attr( 'rel' ) : null
474 - );
475 - return false;
476 - } )
477 - );
 446+ .attr( { 'class' : 'tab tab-' + id, 'rel' : id } )
 447+ .append(
 448+ $( '<a />' )
 449+ .addClass( selected == id ? 'current' : null )
 450+ .attr( 'href', '#' )
 451+ .text( $.wikiEditor.autoMsg( section, 'label' ) )
 452+ .data( 'context', context )
 453+ .click( function() {
 454+ var $sections = $(this).data( 'context' ).$ui.find( '.sections' );
 455+ var $section =
 456+ $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
 457+ $(this).blur();
 458+ var show = $section.css( 'display' ) == 'none';
 459+ $previousSections = $section.parent().find( '.section:visible' );
 460+ $previousSections.css( 'position', 'absolute' );
 461+ $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
 462+ $(this).parent().parent().find( 'a' ).removeClass( 'current' );
 463+ if ( show ) {
 464+ $section.fadeIn( 'fast' );
 465+ $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
 466+ $(this).addClass( 'current' );
 467+ } else {
 468+ $sections.animate( { 'height': 0 } );
 469+ }
 470+ // Click tracking
 471+ if($.trackAction != undefined){
 472+ $.trackAction($section.attr('rel') + '.' + ( show ? 'show': 'hide' ) );
 473+ }
 474+ //
 475+ $.cookie(
 476+ 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
 477+ show ? $section.attr( 'rel' ) : null
 478+ );
 479+ return false;
 480+ } )
 481+ );
478482 },
479483 buildSection : function( context, id, section ) {
480 - var selected = $
481 - .cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
 484+ var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
482485 var $section;
483486 switch ( section.type ) {
484487 case 'toolbar':
@@ -510,7 +513,8 @@
511514 break;
512515 }
513516 if ( $section !== null && id !== 'main' ) {
514 - $section.css( 'display', selected == id ? 'block' : 'none' );
 517+ var show = selected == id;
 518+ $section.css( 'display', show ? 'block' : 'none' );
515519 }
516520 return $section;
517521 },
@@ -558,6 +562,10 @@
559563 },
560564 'loop' : function( i, s ) {
561565 s.$sections.append( $.wikiEditor.modules.toolbar.fn.buildSection( s.context, s.id, s.config ) );
 566+ var $section = s.$sections.find( '.section:visible' );
 567+ if ( $section.size() ) {
 568+ $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
 569+ }
562570 }
563571 } );
564572 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1960,44 +1960,47 @@
19611961 }
19621962 },
19631963 buildTab : function( context, id, section ) {
1964 - var selected = $
1965 - .cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
 1964+ var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
19661965 return $( '<span />' )
1967 - .attr( { 'class' : 'tab tab-' + id, 'rel' : id } )
1968 - .append(
1969 - $( '<a />' )
1970 - .addClass( selected == id ? 'current' : null )
1971 - .attr( 'href', '#' )
1972 - .text( $.wikiEditor.autoMsg( section, 'label' ) )
1973 - .data( 'context', context )
1974 - .click( function() {
1975 - var $section =
1976 - $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
1977 - $(this).blur();
1978 - var show = $section.css( 'display' ) == 'none';
1979 - $section.parent().children().hide("fast");
1980 - $(this).parent().parent().find( 'a' ).removeClass( 'current' );
1981 - if ( show ) {
1982 - $section.show("fast");
1983 - $(this).addClass( 'current' );
1984 - }
1985 -
1986 - //click tracking
1987 - if($.trackAction != undefined){
1988 - $.trackAction($section.attr('rel') + '.' + ( show ? 'show': 'hide' ) );
1989 - }
1990 -
1991 - $.cookie(
1992 - 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
1993 - show ? $section.attr( 'rel' ) : null
1994 - );
1995 - return false;
1996 - } )
1997 - );
 1966+ .attr( { 'class' : 'tab tab-' + id, 'rel' : id } )
 1967+ .append(
 1968+ $( '<a />' )
 1969+ .addClass( selected == id ? 'current' : null )
 1970+ .attr( 'href', '#' )
 1971+ .text( $.wikiEditor.autoMsg( section, 'label' ) )
 1972+ .data( 'context', context )
 1973+ .click( function() {
 1974+ var $sections = $(this).data( 'context' ).$ui.find( '.sections' );
 1975+ var $section =
 1976+ $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
 1977+ $(this).blur();
 1978+ var show = $section.css( 'display' ) == 'none';
 1979+ $previousSections = $section.parent().find( '.section:visible' );
 1980+ $previousSections.css( 'position', 'absolute' );
 1981+ $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
 1982+ $(this).parent().parent().find( 'a' ).removeClass( 'current' );
 1983+ if ( show ) {
 1984+ $section.fadeIn( 'fast' );
 1985+ $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
 1986+ $(this).addClass( 'current' );
 1987+ } else {
 1988+ $sections.animate( { 'height': 0 } );
 1989+ }
 1990+ // Click tracking
 1991+ if($.trackAction != undefined){
 1992+ $.trackAction($section.attr('rel') + '.' + ( show ? 'show': 'hide' ) );
 1993+ }
 1994+ //
 1995+ $.cookie(
 1996+ 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
 1997+ show ? $section.attr( 'rel' ) : null
 1998+ );
 1999+ return false;
 2000+ } )
 2001+ );
19982002 },
19992003 buildSection : function( context, id, section ) {
2000 - var selected = $
2001 - .cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
 2004+ var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
20022005 var $section;
20032006 switch ( section.type ) {
20042007 case 'toolbar':
@@ -2030,7 +2033,8 @@
20312034 break;
20322035 }
20332036 if ( $section !== null && id !== 'main' ) {
2034 - $section.css( 'display', selected == id ? 'block' : 'none' );
 2037+ var show = selected == id;
 2038+ $section.css( 'display', show ? 'block' : 'none' );
20352039 }
20362040 return $section;
20372041 },
@@ -2078,6 +2082,10 @@
20792083 },
20802084 'loop' : function( i, s ) {
20812085 s.$sections.append( $.wikiEditor.modules.toolbar.fn.buildSection( s.context, s.id, s.config ) );
 2086+ var $section = s.$sections.find( '.section:visible' );
 2087+ if ( $section.size() ) {
 2088+ $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
 2089+ }
20822090 }
20832091 } );
20842092 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -132,15 +132,15 @@
133133 return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+
134134 $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';}
135135 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]}}};}
136 -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).click(function(){var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));$(this).blur();var show=$section.css('display')=='none';$section.parent().children().hide("fast");$(this).parent().parent().find('a').removeClass('current');if(show){$section.show("fast");$(this).addClass('current');}
 136+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).click(function(){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));$(this).blur();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');if(show){$section.fadeIn('fast');$sections.animate({'height':$section.outerHeight()},'fast');$(this).addClass('current');}else{$sections.animate({'height':0});}
137137 if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));}
138138 $.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;}));},buildSection:function(context,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]));}}
139139 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]));}}
140140 $section=$('<div />').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;}
141 -if($section!==null&&id!=='main'){$section.css('display',selected==id?'block':'none');}
 141+if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');}
142142 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);}
143143 $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);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$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]));}}
144 -$.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));}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;}
 144+$.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()},'fast');}}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;}
145145 context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');var height=context.$ui.find('.wikiEditor-ui-bottom').height()
146146 context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css({'width':'12em','marginTop':-(height)});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(1000,'keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
147147 section=Math.max(0,section);}

Follow-up revisions

RevisionCommit summaryAuthorDate
r57446Updated version numbers for r57440, r57442 and r57443tparscal23:13, 6 October 2009
r57719wmf-deployment: Merge babaco fixes from trunk...catrope20:20, 14 October 2009

Status & tagging log