Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js |
— | — | @@ -8,6 +8,9 @@ |
9 | 9 | */ |
10 | 10 | api : { |
11 | 11 | addToToolbar : function( context, data ) { |
| 12 | + |
| 13 | + var smooth = true; |
| 14 | + |
12 | 15 | for ( type in data ) { |
13 | 16 | switch ( type ) { |
14 | 17 | case 'sections': |
— | — | @@ -31,11 +34,6 @@ |
32 | 35 | $tabs.append( |
33 | 36 | $.wikiEditor.modules.toolbar.fn.buildTab( context, section, data[type][section] ) |
34 | 37 | ); |
35 | | - // Update visibility of section |
36 | | - $section = $sections.find( '.section:visible' ); |
37 | | - if ( $section.size() ) { |
38 | | - $sections.animate( { 'height': $section.outerHeight() }, 'fast' ); |
39 | | - } |
40 | 38 | } |
41 | 39 | break; |
42 | 40 | case 'groups': |
— | — | @@ -49,6 +47,7 @@ |
50 | 48 | $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] ) |
51 | 49 | ); |
52 | 50 | } |
| 51 | + smooth = false; |
53 | 52 | break; |
54 | 53 | case 'tools': |
55 | 54 | if ( ! ( 'section' in data && 'group' in data ) ) { |
— | — | @@ -64,6 +63,7 @@ |
65 | 64 | if ( $group.children().length ) { |
66 | 65 | $group.show(); |
67 | 66 | } |
| 67 | + smooth = false; |
68 | 68 | break; |
69 | 69 | case 'pages': |
70 | 70 | if ( ! ( 'section' in data ) ) { |
— | — | @@ -84,6 +84,7 @@ |
85 | 85 | ); |
86 | 86 | } |
87 | 87 | $.wikiEditor.modules.toolbar.fn.updateBookletSelection( context, page, $pages, $index ); |
| 88 | + smooth = false; |
88 | 89 | break; |
89 | 90 | case 'rows': |
90 | 91 | if ( ! ( 'section' in data && 'page' in data ) ) { |
— | — | @@ -96,6 +97,7 @@ |
97 | 98 | // Row |
98 | 99 | $table.append( $.wikiEditor.modules.toolbar.fn.buildRow( context, data[type][row] ) ); |
99 | 100 | } |
| 101 | + smooth = false; |
100 | 102 | break; |
101 | 103 | case 'characters': |
102 | 104 | if ( ! ( 'section' in data && 'page' in data ) ) { |
— | — | @@ -124,10 +126,23 @@ |
125 | 127 | } ) |
126 | 128 | ); |
127 | 129 | } |
| 130 | + smooth = false; |
128 | 131 | break; |
129 | 132 | default: break; |
130 | 133 | } |
131 | 134 | } |
| 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 | + } |
132 | 147 | }, |
133 | 148 | removeFromToolbar : function( context, data ) { |
134 | 149 | if ( typeof data.section == 'string' ) { |