Main Page:mediawiki:common.js

From Ekatra Wiki
Revision as of 16:41, 26 August 2025 by Jayprakash12345 (talk | contribs)
Jump to navigation Jump to search

/* --- Initialize sortable tables (desktop + mobile) --- */ function initSortable($root) {

 mw.loader.using(['jquery.tablesorter', 'jquery.tablesorter.styles']).then(function () {
   // Use MediaWiki's built-in sortTables() if available
   if (typeof window.sortTables === 'function') {
     $root.find('table.sortable').each(function () {
       var $t = $(this);
       if (!$t.hasClass('sortable-initialized')) {
         window.sortTables(this);
         $t.addClass('sortable-initialized');
       }
     });
   } else {
     // Fallback: tablesorter
     $root.find('table.sortable').each(function () {
       var $t = $(this);
       if (!$t.hasClass('tablesorter-processed')) {
         $t.tablesorter();
       }
     });
   }
 });

}