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 4: Line 4:
     $content.find('.citizen-section').each(function() {
     $content.find('.citizen-section').each(function() {
         var $section = $(this);
         var $section = $(this);
         $section.addClass('collapsed'); // Collapse all sections by default
         var $contentWrapper = $section.find('.citizen-section-content');
        var $title = $section.find('.citizen-section-title');


         // Find the section title and make it toggle on click
         if ($contentWrapper.length && $title.length) {
        var $title = $section.find('.citizen-section-title');
            // Collapse by default
        $title.css('cursor', 'pointer').on('click', function() {
            $contentWrapper.hide();
            $section.toggleClass('collapsed');
            $section.addClass('collapsed');
        });
 
            // Make the title clickable to toggle the section
            $title.css('cursor', 'pointer').on('click', function() {
                $contentWrapper.slideToggle();
                $section.toggleClass('collapsed');
            });
        }
     });
     });
});
});

Revision as of 04:07, 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) {
            // Collapse by default
            $contentWrapper.hide();
            $section.addClass('collapsed');

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