MediaWiki:Common.js: Difference between revisions

From Wizards and Warlords
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
/* Spellbook bottom collapse controls */
/* Bottom collapse controls */
mw.loader.using('jquery.makeCollapsible').then(function () {
mw.loader.using('jquery.makeCollapsible').then(function () {
function collapseFromBottom(toggleClass, collapsibleId) {
function collapseFromBottom(toggleClass, collapsibleId) {
Line 16: Line 16:
collapseFromBottom('.wizlords-spellbook-collapse-arcane', 'wizlords-arcane-spellbook');
collapseFromBottom('.wizlords-spellbook-collapse-arcane', 'wizlords-arcane-spellbook');
collapseFromBottom('.wizlords-spellbook-collapse-divine', 'wizlords-divine-spellbook');
collapseFromBottom('.wizlords-spellbook-collapse-divine', 'wizlords-divine-spellbook');
collapseFromBottom('.wizlords-multiple-characters-collapse', 'wizlords-multiple-characters-section');
 
$(document).on('click', '.wizlords-collapsible-section-bottom-toggle', function (event) {
event.preventDefault();
 
var $collapsible = $(this).closest('.wizlords-collapsible-section');
var $topToggle = $collapsible.children('.mw-collapsible-toggle').first();
 
if ($topToggle.length) {
$topToggle.trigger('click');
}
});
});
});

Revision as of 20:48, 29 June 2026

/* Bottom collapse controls */
mw.loader.using('jquery.makeCollapsible').then(function () {
	function collapseFromBottom(toggleClass, collapsibleId) {
		$(document).on('click', toggleClass, function (event) {
			event.preventDefault();

			var $collapsible = $('#' + collapsibleId);
			var $topToggle = $collapsible.children('.mw-collapsible-toggle').first();

			if ($topToggle.length) {
				$topToggle.trigger('click');
			}
		});
	}

	collapseFromBottom('.wizlords-spellbook-collapse-arcane', 'wizlords-arcane-spellbook');
	collapseFromBottom('.wizlords-spellbook-collapse-divine', 'wizlords-divine-spellbook');

	$(document).on('click', '.wizlords-collapsible-section-bottom-toggle', function (event) {
		event.preventDefault();

		var $collapsible = $(this).closest('.wizlords-collapsible-section');
		var $topToggle = $collapsible.children('.mw-collapsible-toggle').first();

		if ($topToggle.length) {
			$topToggle.trigger('click');
		}
	});
});