Index: trunk/extensions/Translate/js/translate.langstats.js |
— | — | @@ -12,31 +12,6 @@ |
13 | 13 | // Only do stuff if there are any meta group rows on this pages |
14 | 14 | if ( $metaRows.size() ) { |
15 | 15 | |
16 | | - var $allChildRows = $( 'tr[data-parentgroups]', $translateTable ), |
17 | | - $allToggles = $( '.mw-sp-langstats-toggle', $translateTable ), |
18 | | - $toggleAllButton = $( '<span class="mw-sp-langstats-expander">[</span>' ).append( $( '<a href="#" onclick="return false;">' ).text( mw.msg( 'translate-langstats-expandall' ) ) ).append( ']' ).click( function() { |
19 | | - var $el = $( this ); |
20 | | - // Switch the state and toggle the rows |
21 | | - // and update the local toggles too |
22 | | - if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) { |
23 | | - $allChildRows.show(); |
24 | | - $el.add( $allToggles ).removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' ) |
25 | | - $el.find( '> a' ).text( mw.msg( 'translate-langstats-collapseall' ) ); |
26 | | - $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-collapse' ) ); |
27 | | - } else { |
28 | | - $allChildRows.hide(); |
29 | | - $el.add( $allToggles ).addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' ) |
30 | | - $el.find( '> a' ).text( mw.msg( 'translate-langstats-expandall' ) ); |
31 | | - $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-expand' ) ); |
32 | | - } |
33 | | - } ); |
34 | | - |
35 | | - // Initially hide them |
36 | | - $allChildRows.hide(); |
37 | | - |
38 | | - // Add the toggle-all button above the table |
39 | | - $( '<p class="mw-sp-langstats-toggleall"></p>' ).append( $toggleAllButton ).insertBefore( $translateTable ); |
40 | | - |
41 | 16 | $metaRows.each( function() { |
42 | 17 | // Get info and cache selectors |
43 | 18 | var $thisGroup = $(this), |
— | — | @@ -65,5 +40,32 @@ |
66 | 41 | $thisGroup.find( ' > td:first' ).append( $toggler ); |
67 | 42 | } |
68 | 43 | } ); |
| 44 | + |
| 45 | + // Create, bind and append the toggle-all button |
| 46 | + var $allChildRows = $( 'tr[data-parentgroups]', $translateTable ), |
| 47 | + $allToggles_cache = null, |
| 48 | + $toggleAllButton = $( '<span class="mw-sp-langstats-expander">[</span>' ).append( $( '<a href="#" onclick="return false;">' ).text( mw.msg( 'translate-langstats-expandall' ) ) ).append( ']' ).click( function() { |
| 49 | + var $el = $( this ), |
| 50 | + $allToggles = !!$allToggles_cache ? $allToggles_cache : $( '.mw-sp-langstats-toggle', $translateTable ), |
| 51 | + // Switch the state and toggle the rows |
| 52 | + // and update the local toggles too |
| 53 | + if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) { |
| 54 | + $allChildRows.show(); |
| 55 | + $el.add( $allToggles ).removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' ) |
| 56 | + $el.find( '> a' ).text( mw.msg( 'translate-langstats-collapseall' ) ); |
| 57 | + $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-collapse' ) ); |
| 58 | + } else { |
| 59 | + $allChildRows.hide(); |
| 60 | + $el.add( $allToggles ).addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' ) |
| 61 | + $el.find( '> a' ).text( mw.msg( 'translate-langstats-expandall' ) ); |
| 62 | + $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-expand' ) ); |
| 63 | + } |
| 64 | + } ); |
| 65 | + |
| 66 | + // Initially hide them |
| 67 | + $allChildRows.hide(); |
| 68 | + |
| 69 | + // Add the toggle-all button above the table |
| 70 | + $( '<p class="mw-sp-langstats-toggleall"></p>' ).append( $toggleAllButton ).insertBefore( $translateTable ); |
69 | 71 | } |
70 | 72 | } ); |
\ No newline at end of file |