Difference between revisions of "MediaWiki:Common.js"

From the Linux and Unix Users Group at Virginia Teck Wiki
Jump to: navigation, search
imported>Pew
imported>Pew
Line 7: Line 7:
 
     // wrapped in "mw.loader.using" so this doesn't execute until Tablesorter has loaded
 
     // wrapped in "mw.loader.using" so this doesn't execute until Tablesorter has loaded
 
     mw.loader.using( 'jquery.tablesorter', function() {
 
     mw.loader.using( 'jquery.tablesorter', function() {
         if( isSortedTablePage() ) $('table.sortable').tablesorter( {sortList: [ { 0: 'desc'} ]} )
+
         // if( isSortedTablePage() ) $('table.sortable').tablesorter( {sortList: [ { 0: 'desc'} ]} )
 
         // or look for tables with an ID attribute of "sortMe" on any page
 
         // or look for tables with an ID attribute of "sortMe" on any page
 
         $( '#sortMe' ).tablesorter( {sortList: [ { 0: 'desc'} ]} )
 
         $( '#sortMe' ).tablesorter( {sortList: [ { 0: 'desc'} ]} )
 
     } );
 
     } );
 
} );
 
} );

Revision as of 21:48, 1 April 2017

/* Any JavaScript here will be loaded for all users on every page load. */
function isSortedTablePage() {
    return ( wgPageName == "Project_list"  || wgPageName == "Roadmap" );
}

jQuery( document ).ready( function( $ ) {
    // wrapped in "mw.loader.using" so this doesn't execute until Tablesorter has loaded
    mw.loader.using( 'jquery.tablesorter', function() {
        // if( isSortedTablePage() ) $('table.sortable').tablesorter( {sortList: [ { 0: 'desc'} ]} )
        // or look for tables with an ID attribute of "sortMe" on any page
        $( '#sortMe' ).tablesorter( {sortList: [ { 0: 'desc'} ]} )
    } );
} );