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
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 8: Line 8:


         if ($contentWrapper.length && $title.length) {
         if ($contentWrapper.length && $title.length) {
             // Collapse by default
             // Force collapse by default
             $contentWrapper.hide();
             $contentWrapper.hide();
             $section.addClass('collapsed');
             $section.addClass('collapsed');


             // Make the title clickable to toggle the section
             // Ensure clicking the title toggles the section
             $title.css('cursor', 'pointer').on('click', function() {
             $title.css('cursor', 'pointer').off('click').on('click', function() {
                 $contentWrapper.slideToggle();
                 $contentWrapper.slideToggle();
                 $section.toggleClass('collapsed');
                 $section.toggleClass('collapsed');

Revision as of 04:08, 2 April 2025

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

mw.hook('wikipage.content').add(function($content) {
    $content.find('.citizen-section').each(function() {
        var $section = $(this);
        var $contentWrapper = $section.find('.citizen-section-content');
        var $title = $section.find('.citizen-section-title');

        if ($contentWrapper.length && $title.length) {
            // Force collapse by default
            $contentWrapper.hide();
            $section.addClass('collapsed');

            // Ensure clicking the title toggles the section
            $title.css('cursor', 'pointer').off('click').on('click', function() {
                $contentWrapper.slideToggle();
                $section.toggleClass('collapsed');
            });
        }
    });
});