Jump to content

MediaWiki:Common.js: Difference between revisions

From nUSA Wiki
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1: Line 1:
$(function() {
document.addEventListener("DOMContentLoaded", function() {
    const collapsibleHeaders = document.querySelectorAll('.infobox-header');


     if (mw.config.get('wgRestrictions') && mw.config.get('wgRestrictions').edit) {
     collapsibleHeaders.forEach(function(header) {
        var protectionBanner = '{{ProtectionBanner}}';  
        header.addEventListener('click', function() {
       
            const group = header.parentElement;
        // Prepend the banner to the content
            group.classList.toggle('open');
        $('#content').before(protectionBanner);
            const content = group.querySelector('.infobox-content');
     }
            if (content) {
                content.style.display = group.classList.contains('open') ? 'block' : 'none';
            }
        });
     });
});
});

Revision as of 00:57, 14 January 2025

document.addEventListener("DOMContentLoaded", function() {
    const collapsibleHeaders = document.querySelectorAll('.infobox-header');

    collapsibleHeaders.forEach(function(header) {
        header.addEventListener('click', function() {
            const group = header.parentElement;
            group.classList.toggle('open');
            const content = group.querySelector('.infobox-content');
            if (content) {
                content.style.display = group.classList.contains('open') ? 'block' : 'none';
            }
        });
    });
});