Index: trunk/extensions/Translate/SpecialLanguageStats.php |
— | — | @@ -31,6 +31,9 @@ |
32 | 32 | $this->setHeaders(); |
33 | 33 | $this->outputHeader(); |
34 | 34 | |
| 35 | + if ( MW_SUPPORTS_RESOURCE_MODULES ) { |
| 36 | + $wgOut->addModules( 'ext.translate.langstats' ); |
| 37 | + } |
35 | 38 | $wgOut->addExtensionStyle( TranslateUtils::assetPath( 'Translate.css' ) ); |
36 | 39 | |
37 | 40 | // no UI when including() |
Index: trunk/extensions/Translate/js/translate.langstats.css |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +.mw-sp-langstats-toggleall { |
| 3 | + text-align: right; |
| 4 | +} |
| 5 | + |
| 6 | +.mw-sp-langstats-toggle { |
| 7 | + float: right; |
| 8 | +} |
| 9 | + |
| 10 | +.mw-sp-langstats-collapser, |
| 11 | +.mw-sp-langstats-collapser a { |
| 12 | + cursor: n-resize; |
| 13 | +} |
| 14 | + |
| 15 | +.mw-sp-langstats-expander, |
| 16 | +.mw-sp-langstats-expander a { |
| 17 | + cursor: s-resize; |
| 18 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Translate/js/translate.langstats.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |
Index: trunk/extensions/Translate/js/translate.langstats.js |
— | — | @@ -0,0 +1,75 @@ |
| 2 | +/** |
| 3 | + * Collapsing script for Special:LanguageStats in MediaWiki Extension:Translate |
| 4 | + * @author Krinkle <krinklemail (at) gmail (dot) com> |
| 5 | + * @created January 3, 2011 |
| 6 | + * @license GPL v2, CC-BY-SA-3.0 |
| 7 | + */ |
| 8 | +var MSGexpand = 'expand', MSGcollapse = 'collapse', MSGexpandall = 'expand all', MSGcollapseall = 'collapse all'; |
| 9 | +jQuery( document ).ready( function() { |
| 10 | + if ( mw.config.get( 'wgPageName' ) == 'Special:LanguageStats' ) { |
| 11 | + |
| 12 | + var $translateTable = $( '.mw-sp-translate-table' ), |
| 13 | + $metaRows = $( 'tr[data-ismeta=1]', $translateTable ); |
| 14 | + |
| 15 | + // Only do stuff if there are any meta group rows on this pages |
| 16 | + if ( $metaRows.size() ) { |
| 17 | + |
| 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 ); |
| 22 | + // Switch the state and toggle the rows |
| 23 | + // and update the local toggles too |
| 24 | + 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 ); |
| 29 | + } 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 ); |
| 34 | + } |
| 35 | + } ); |
| 36 | + |
| 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 | + } |
| 72 | + } |
| 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 |
Property changes on: trunk/extensions/Translate/js/translate.langstats.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 77 | + native |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -125,6 +125,12 @@ |
126 | 126 | 'localBasePath' => dirname( __FILE__ ), |
127 | 127 | 'remoteExtPath' => 'Translate' |
128 | 128 | ); |
| 129 | +$wgResourceModules['ext.translate.langstats'] = array( |
| 130 | + 'scripts' => 'js/translate.langstats.js', |
| 131 | + 'styles' => 'js/translate.langstats.css', |
| 132 | + 'localBasePath' => dirname( __FILE__ ), |
| 133 | + 'remoteExtPath' => 'Translate', |
| 134 | +); |
129 | 135 | |
130 | 136 | /** @endcond */ |
131 | 137 | |