Index: trunk/phase3/resources/jquery/jquery.makeCollapsible.js |
— | — | @@ -152,9 +152,8 @@ |
153 | 153 | return; |
154 | 154 | }, |
155 | 155 | // Toggles collapsible and togglelink class |
156 | | - toggleLinkPremade = function( that, e ) { |
157 | | - var $that = $(that), |
158 | | - $collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' ); |
| 156 | + toggleLinkPremade = function( $that, e ) { |
| 157 | + var $collapsible = $that.eq(0).closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' ); |
159 | 158 | e.preventDefault(); |
160 | 159 | |
161 | 160 | // It's expanded right now |
— | — | @@ -245,7 +244,7 @@ |
246 | 245 | $firstRowCells.eq(-1).prepend( $toggleLink ); |
247 | 246 | } else { |
248 | 247 | $toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){ |
249 | | - toggleLinkPremade( this, e ); |
| 248 | + toggleLinkPremade( $toggle, e ); |
250 | 249 | } ); |
251 | 250 | } |
252 | 251 | |
— | — | @@ -264,7 +263,7 @@ |
265 | 264 | $that.prepend( $toggleLink.wrap( '<li class="mw-collapsible-toggle-li">' ).parent() ); |
266 | 265 | } else { |
267 | 266 | $toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){ |
268 | | - toggleLinkPremade( this, e ); |
| 267 | + toggleLinkPremade( $toggle, e ); |
269 | 268 | } ); |
270 | 269 | } |
271 | 270 | |
— | — | @@ -282,7 +281,7 @@ |
283 | 282 | $that.prepend( $toggleLink ); |
284 | 283 | } else { |
285 | 284 | $toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){ |
286 | | - toggleLinkPremade( this, e ); |
| 285 | + toggleLinkPremade( $toggle, e ); |
287 | 286 | } ); |
288 | 287 | } |
289 | 288 | } |
— | — | @@ -291,7 +290,10 @@ |
292 | 291 | // Initial state (only for those that are not custom) |
293 | 292 | if ( $that.hasClass( 'mw-collapsed' ) && $that.attr( 'id' ).indexOf( 'mw-customcollapsible-' ) !== 0 ) { |
294 | 293 | $that.removeClass( 'mw-collapsed' ); |
295 | | - $toggleLink.click(); |
| 294 | + // The collapsible element could have multiple togglers |
| 295 | + // To toggle the initial state only click one of them (ie. the first one, eq(0) ) |
| 296 | + // Else it would go like: hide,show,hide,show for each toggle link. |
| 297 | + $toggleLink.eq(0).click(); |
296 | 298 | } |
297 | 299 | } ); |
298 | 300 | }; |