MediaWiki:Common.js: Difference between revisions

From Midgard Tales Wiki

No edit summary
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. */
// Make sidebar sections collapsible
$(document).ready(function() {
    $('#mw-panel div.portal h3').each(function() {
        var $heading = $(this);
        var $content = $heading.next('div.body');
        // Add a toggle button
        $heading.append('<span class="collapsible-arrow">▼</span>');
        // Collapse/expand on click
        $heading.on('click', function() {
            $content.toggle();
            $heading.find('.collapsible-arrow').text(function(_, text) {
                return text === '▼' ? '▶' : '▼';
            });
        });
        // Collapse all sections by default (optional)
        $content.hide();
        $heading.find('.collapsible-arrow').text('▶');
    });
});

Revision as of 06:57, 31 January 2025

/* Any JavaScript here will be loaded for all users on every page load. */
// Make sidebar sections collapsible
$(document).ready(function() {
    $('#mw-panel div.portal h3').each(function() {
        var $heading = $(this);
        var $content = $heading.next('div.body');

        // Add a toggle button
        $heading.append('<span class="collapsible-arrow">▼</span>');

        // Collapse/expand on click
        $heading.on('click', function() {
            $content.toggle();
            $heading.find('.collapsible-arrow').text(function(_, text) {
                return text === '▼' ? '▶' : '▼';
            });
        });

        // Collapse all sections by default (optional)
        $content.hide();
        $heading.find('.collapsible-arrow').text('▶');
    });
});