Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js: Difference between revisions

MediaWiki interface page
Created page with "All JavaScript here will be loaded for users of the Citizen skin: mw.hook('wikipage.content').add(function($content) { $content.find('.mw-headline').each(function() { var $header = $(this); var $section = $header.nextUntil('h2, h3, h4, h5, h6'); if ($section.length) { // Wrap section content in a div $section.wrapAll('<div class="citizen-collapsed-section" style="display: none;"></div>'); // Add togg..."
 
Tag: Replaced
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Citizen skin */
/* All JavaScript here will be loaded for users of the Citizen skin */
mw.hook('wikipage.content').add(function($content) {
    $content.find('.mw-headline').each(function() {
        var $header = $(this);
        var $section = $header.nextUntil('h2, h3, h4, h5, h6');
        if ($section.length) {
            // Wrap section content in a div
            $section.wrapAll('<div class="citizen-collapsed-section" style="display: none;"></div>');
            // Add toggle button
            var $toggle = $('<span class="citizen-toggle-button" style="cursor: pointer; margin-left: 10px;">[+]</span>');
            $header.append($toggle);
            // Toggle visibility on click
            $toggle.on('click', function() {
                var $wrapper = $(this).parent().next('.citizen-collapsed-section');
                $wrapper.toggle();
                $(this).text($wrapper.is(':visible') ? '[-]' : '[+]');
            });
        }
    });
});

Revision as of 04:02, 2 April 2025

/* All JavaScript here will be loaded for users of the Citizen skin */