MediaWiki:Common.js: Difference between revisions
From Midgard Tales Wiki
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
// Add Expand/Collapse All button | |||
$(document).ready(function() { | $(document).ready(function() { | ||
// | // Create the button | ||
$(' | var $toggleButton = $('<button>', { | ||
text: 'Collapse All', | |||
class: 'toggle-all-button', | |||
click: function() { | |||
var $button = $(this); | |||
var isCollapsed = $button.text() === 'Expand All'; | |||
// Toggle all sections | |||
$('#mw-navigation .mw-portlet .mw-portlet-body').toggle(!isCollapsed); | |||
$('#mw-navigation .mw-portlet .collapsible-arrow').text(isCollapsed ? '▼' : '▶'); | |||
// Update button text | |||
$button.text(isCollapsed ? 'Collapse All' : 'Expand All'); | |||
} | |||
$ | }); | ||
// Add the button to the sidebar | |||
$('#mw-navigation').prepend($toggleButton); | |||
}); | }); | ||
Revision as of 07:07, 31 January 2025
/* Any JavaScript here will be loaded for all users on every page load. */
// Add Expand/Collapse All button
$(document).ready(function() {
// Create the button
var $toggleButton = $('<button>', {
text: 'Collapse All',
class: 'toggle-all-button',
click: function() {
var $button = $(this);
var isCollapsed = $button.text() === 'Expand All';
// Toggle all sections
$('#mw-navigation .mw-portlet .mw-portlet-body').toggle(!isCollapsed);
$('#mw-navigation .mw-portlet .collapsible-arrow').text(isCollapsed ? '▼' : '▶');
// Update button text
$button.text(isCollapsed ? 'Collapse All' : 'Expand All');
}
});
// Add the button to the sidebar
$('#mw-navigation').prepend($toggleButton);
});