Main Page:mediawiki:common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
/* | /* --- 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'); | |||
$root.find('. | |||
var $ | |||
if (!$ | |||
$ | |||
} | } | ||
}); | }); | ||
} | } else { | ||
// Fallback: tablesorter | |||
$root.find('table.sortable').each(function () { | $root.find('table.sortable').each(function () { | ||
var $t = $(this); | var $t = $(this); | ||
| Line 65: | Line 19: | ||
} | } | ||
}); | }); | ||
} | } | ||
} | }); | ||
} | |||
Revision as of 16:41, 26 August 2025
/* --- 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();
}
});
}
});
}