r87979 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87978‎ | r87979 | r87980 >
Date:14:34, 13 May 2011
Author:catrope
Status:ok
Tags:
Comment:
WikiEditor: (bug 27698) Toolbar height isn't updated in all code paths of addToToolbar(), causes toolbar to overlap part of the edit box if certain race conditions happen. Patch by Salvatore Ingala
Modified paths:
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js
@@ -8,6 +8,9 @@
99 */
1010 api : {
1111 addToToolbar : function( context, data ) {
 12+
 13+ var smooth = true;
 14+
1215 for ( type in data ) {
1316 switch ( type ) {
1417 case 'sections':
@@ -31,11 +34,6 @@
3235 $tabs.append(
3336 $.wikiEditor.modules.toolbar.fn.buildTab( context, section, data[type][section] )
3437 );
35 - // Update visibility of section
36 - $section = $sections.find( '.section:visible' );
37 - if ( $section.size() ) {
38 - $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
39 - }
4038 }
4139 break;
4240 case 'groups':
@@ -49,6 +47,7 @@
5048 $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] )
5149 );
5250 }
 51+ smooth = false;
5352 break;
5453 case 'tools':
5554 if ( ! ( 'section' in data && 'group' in data ) ) {
@@ -64,6 +63,7 @@
6564 if ( $group.children().length ) {
6665 $group.show();
6766 }
 67+ smooth = false;
6868 break;
6969 case 'pages':
7070 if ( ! ( 'section' in data ) ) {
@@ -84,6 +84,7 @@
8585 );
8686 }
8787 $.wikiEditor.modules.toolbar.fn.updateBookletSelection( context, page, $pages, $index );
 88+ smooth = false;
8889 break;
8990 case 'rows':
9091 if ( ! ( 'section' in data && 'page' in data ) ) {
@@ -96,6 +97,7 @@
9798 // Row
9899 $table.append( $.wikiEditor.modules.toolbar.fn.buildRow( context, data[type][row] ) );
99100 }
 101+ smooth = false;
100102 break;
101103 case 'characters':
102104 if ( ! ( 'section' in data && 'page' in data ) ) {
@@ -124,10 +126,23 @@
125127 } )
126128 );
127129 }
 130+ smooth = false;
128131 break;
129132 default: break;
130133 }
131134 }
 135+
 136+ // Fix div.section size after adding things; if smooth is true uses a smooth
 137+ // animation, otherwise just change height (breaking any ongoing animation)
 138+ var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' );
 139+ $section = $sections.find( '.section:visible' );
 140+ if ( $section.size() ) {
 141+ if ( smooth ) {
 142+ $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
 143+ } else {
 144+ $sections.height( $section.outerHeight() );
 145+ }
 146+ }
132147 },
133148 removeFromToolbar : function( context, data ) {
134149 if ( typeof data.section == 'string' ) {

Status & tagging log