Index: trunk/extensions/Translate/js/translate.langstats.js |
— | — | @@ -4,72 +4,66 @@ |
5 | 5 | * @created January 3, 2011 |
6 | 6 | * @license GPL v2, CC-BY-SA-3.0 |
7 | 7 | */ |
8 | | -var MSGexpand = 'expand', MSGcollapse = 'collapse', MSGexpandall = 'expand all', MSGcollapseall = 'collapse all'; |
9 | 8 | jQuery( document ).ready( function() { |
10 | | - if ( mw.config.get( 'wgPageName' ) == 'Special:LanguageStats' ) { |
11 | 9 | |
12 | | - var $translateTable = $( '.mw-sp-translate-table' ), |
13 | | - $metaRows = $( 'tr[data-ismeta=1]', $translateTable ); |
| 10 | + var $translateTable = $( '.mw-sp-translate-table' ), |
| 11 | + $metaRows = $( 'tr[data-ismeta=1]', $translateTable ), |
14 | 12 | |
15 | | - // Only do stuff if there are any meta group rows on this pages |
16 | | - if ( $metaRows.size() ) { |
| 13 | + // Only do stuff if there are any meta group rows on this pages |
| 14 | + if ( $metaRows.size() ) { |
17 | 15 | |
18 | | - var $allChildRows = $( 'tr[data-parentgroups]', $translateTable ), |
19 | | - $toggleAllButton = $( '<span class="mw-sp-langstats-expander">[<a href="#" onclick="return false;">' + MSGexpandall + '</a>]</span>' ).click( function() { |
20 | | - var $el = $( this ), |
21 | | - $allToggles = $( '.mw-sp-langstats-toggle', $translateTable ); |
| 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 | + $metaRows.each( function() { |
| 42 | + // Get info and cache selectors |
| 43 | + var $thisGroup = $(this), |
| 44 | + thisGroupId = $thisGroup.attr( 'data-groupid' ), |
| 45 | + $thisChildRows = $( 'tr[data-parentgroups~="' + thisGroupId + '"]', $translateTable ); |
| 46 | + |
| 47 | + // Only do the collapse stuff if this Meta-group actually has children on this page |
| 48 | + if ( $thisChildRows.size() ) { |
| 49 | + |
| 50 | + // Build toggle link |
| 51 | + var $toggler = $( '<span class="mw-sp-langstats-toggle mw-sp-langstats-expander">[</span>' ).append( $( '<a href="#" onclick="return false;">' ).text( mw.msg( 'translate-langstats-expand' ) ) ).append( ']' ).click( function() { |
| 52 | + var $el = $( this ); |
22 | 53 | // Switch the state and toggle the rows |
23 | | - // and update the local toggles too |
24 | 54 | if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) { |
25 | | - $allChildRows.fadeIn(); |
26 | | - $el.add( $allToggles ).removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' ) |
27 | | - $el.find( '> a' ).text( MSGcollapseall ); |
28 | | - $allToggles.find( '> a' ).text( MSGcollapse ); |
| 55 | + $thisChildRows.fadeIn(); |
| 56 | + $el.removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' ) |
| 57 | + .find( '> a' ).text( mw.msg( 'translate-langstats-collapse' ) ); |
29 | 58 | } else { |
30 | | - $allChildRows.fadeOut(); |
31 | | - $el.add( $allToggles ).addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' ) |
32 | | - $el.find( '> a' ).text( MSGexpandall ); |
33 | | - $allToggles.find( '> a' ).text( MSGexpand ); |
| 59 | + $thisChildRows.fadeOut(); |
| 60 | + $el.addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' ) |
| 61 | + .find( '> a' ).text( mw.msg( 'translate-langstats-expand' ) ); |
34 | 62 | } |
35 | 63 | } ); |
36 | 64 | |
37 | | - // Initially hide them |
38 | | - $allChildRows.hide(); |
39 | | - |
40 | | - // Add the toggle-all button above the table |
41 | | - $( '<p class="mw-sp-langstats-toggleall"></p>' ).append( $toggleAllButton ).insertBefore( $translateTable ); |
42 | | - |
43 | | - $metaRows.each( function() { |
44 | | - // Get info and cache selectors |
45 | | - var $thisGroup = $(this), |
46 | | - thisGroupId = $thisGroup.attr( 'data-groupid' ), |
47 | | - $thisChildRows = $( 'tr[data-parentgroups~="' + thisGroupId + '"]', $translateTable ); |
48 | | - |
49 | | - // Only do the collapse stuff if this Meta-group actually has children on this page |
50 | | - if ( $thisChildRows.size() ) { |
51 | | - |
52 | | - // Build toggle link |
53 | | - var $toggler = $( '<span class="mw-sp-langstats-toggle mw-sp-langstats-expander">[<a href="#" onclick="return false;">' + MSGexpand + '</a>]</span>' ).click( function() { |
54 | | - var $el = $( this ); |
55 | | - // Switch the state and toggle the rows |
56 | | - if ( $el.hasClass( 'mw-sp-langstats-expander' ) ) { |
57 | | - $thisChildRows.fadeIn(); |
58 | | - $el.removeClass( 'mw-sp-langstats-expander' ).addClass( 'mw-sp-langstats-collapser' ) |
59 | | - .find( '> a' ).text( MSGcollapse ); |
60 | | - } else { |
61 | | - $thisChildRows.fadeOut(); |
62 | | - $el.addClass( 'mw-sp-langstats-expander' ).removeClass( 'mw-sp-langstats-collapser' ) |
63 | | - .find( '> a' ).text( MSGexpand ); |
64 | | - } |
65 | | - } ); |
66 | | - |
67 | | - // Add the toggle link to the first cell of the meta group table-row |
68 | | - $thisGroup.find( ' > td:first' ).append( $toggler ); |
69 | | - } |
70 | | - } ); |
71 | | - } |
| 65 | + // Add the toggle link to the first cell of the meta group table-row |
| 66 | + $thisGroup.find( ' > td:first' ).append( $toggler ); |
| 67 | + } |
| 68 | + } ); |
72 | 69 | } |
73 | | -} ); |
74 | | -// @TODO: Create the following messages "translate-expand-all" (new), "translate-collapse-all" (new), "translate-expand" ({{Identical|collapsible-expand}}) and "translate-collapse" ({{Identical|collapsible-collapse}}) |
75 | | -// @TODO: Load this script via ResourceLoader and pass the those 4 messages |
76 | | -// @TODO: Replace hardcoded messages with mw.msg(''); |
\ No newline at end of file |
| 70 | +} ); |
\ No newline at end of file |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -128,6 +128,7 @@ |
129 | 129 | $wgResourceModules['ext.translate.langstats'] = array( |
130 | 130 | 'scripts' => 'js/translate.langstats.js', |
131 | 131 | 'styles' => 'js/translate.langstats.css', |
| 132 | + 'messages' => array( 'translate-langstats-expandall', 'translate-langstats-collapseall', 'translate-langstats-expand', 'translate-langstats-collapse' ), |
132 | 133 | 'localBasePath' => dirname( __FILE__ ), |
133 | 134 | 'remoteExtPath' => 'Translate', |
134 | 135 | ); |
Index: trunk/extensions/Translate/Translate.i18n.php |
— | — | @@ -219,6 +219,10 @@ |
220 | 220 | 'languagestats-summary' => 'This page shows translation statistics for all message groups for a language.', |
221 | 221 | 'languagestats-stats-for' => 'Translation statistics for $1 ($2).', |
222 | 222 | 'languagestats-recenttranslations' => 'recent translations', |
| 223 | + 'translate-langstats-expand' => 'expand', |
| 224 | + 'translate-langstats-collapse' => 'collapse', |
| 225 | + 'translate-langstats-expandall' => 'expand all', |
| 226 | + 'translate-langstats-collapseall' => 'collapse all', |
223 | 227 | 'translate-language-code' => 'Language code', |
224 | 228 | 'translate-language-code-field-name' => 'Language code:', |
225 | 229 | 'translate-suppress-complete' => 'Suppress completely translated message groups', |
— | — | @@ -470,6 +474,10 @@ |
471 | 475 | 'translate-language-code-field-name' => 'Used in [[Special:LanguageStats]]. |
472 | 476 | |
473 | 477 | {{Identical|Language code}}', |
| 478 | + 'translate-langstats-expand' => 'Used in [[Special:LanguageStats]] to expand subgroups {{Identical/Expand}}', |
| 479 | + 'translate-langstats-collapse' => 'Used in [[Special:LanguageStats]] to collapse subgroups {{Identical/Collapse}}', |
| 480 | + 'translate-langstats-expandall' => 'Used in [[Special:LanguageStats]] to expand all subgroups', |
| 481 | + 'translate-langstats-collapseall' => 'Used in [[Special:LanguageStats]] to collapse all subgroups', |
474 | 482 | 'translate-suppress-complete' => 'Used in [[Special:LanguageStats]].', |
475 | 483 | 'translate-language' => '{{Identical|Language}}', |
476 | 484 | 'translate-untranslated' => 'Column header in [[Special:LanguageStats]] for number of untranslated messages in a message group.', |