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:
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function() {
     const collapsibleHeaders = document.querySelectorAll('.infobox-header');
    // Get all toggle headers (sections)
     const toggleHeaders = document.querySelectorAll('.toggle-header');


     collapsibleHeaders.forEach(function(header) {
     toggleHeaders.forEach(function(header) {
        // Add click event listener to each header
         header.addEventListener('click', function() {
         header.addEventListener('click', function() {
             const group = header.parentElement;
            // Find the content to toggle (it's the next sibling)
             group.classList.toggle('open');
             const content = header.nextElementSibling;
             const content = group.querySelector('.infobox-content');
 
            if (content) {
             // Toggle the visibility of the content
                 content.style.display = group.classList.contains('open') ? 'block' : 'none';
             if (content && content.classList.contains('toggle-content')) {
                 content.style.display = (content.style.display === 'none' || content.style.display === '') ? 'block' : 'none';
             }
             }
         });
         });
     });
     });
});
});

Revision as of 00:59, 14 January 2025

document.addEventListener("DOMContentLoaded", function() {
    // Get all toggle headers (sections)
    const toggleHeaders = document.querySelectorAll('.toggle-header');

    toggleHeaders.forEach(function(header) {
        // Add click event listener to each header
        header.addEventListener('click', function() {
            // Find the content to toggle (it's the next sibling)
            const content = header.nextElementSibling;

            // Toggle the visibility of the content
            if (content && content.classList.contains('toggle-content')) {
                content.style.display = (content.style.display === 'none' || content.style.display === '') ? 'block' : 'none';
            }
        });
    });
});