MediaWiki:Common.js: Difference between revisions

From ANZUS Wiki
Jump to navigation Jump to search
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: →‎Collapsible Icon Menu: document.addEventListener("DOMContentLoaded", function() { var icons = document.querySelectorAll('.collapsible-icon'); var contents = document.querySelectorAll('.collapsible-content'); icons.forEach(function(icon, index) { icon.addEventListener('click', function() { // Hide all content sections contents.forEach(function(conten...")
 
mNo edit summary
Line 7: Line 7:


     icons.forEach(function(icon, index) {
     icons.forEach(function(icon, index) {
         icon.addEventListener('click', function() {
         function toggleContent() {
             // Hide all content sections
             // Hide all content sections
             contents.forEach(function(content) {
             contents.forEach(function(content) {
Line 15: Line 15:
             // Show the clicked content section
             // Show the clicked content section
             contents[index].classList.add('active');
             contents[index].classList.add('active');
         });
         }
 
        icon.addEventListener('click', toggleContent);
        icon.addEventListener('touchstart', toggleContent);
     });
     });
});
});

Revision as of 11:25, 18 May 2024

/* Any JavaScript here will be loaded for all users on every page load. */

/*Collapsible Icon Menu*/
document.addEventListener("DOMContentLoaded", function() {
    var icons = document.querySelectorAll('.collapsible-icon');
    var contents = document.querySelectorAll('.collapsible-content');

    icons.forEach(function(icon, index) {
        function toggleContent() {
            // Hide all content sections
            contents.forEach(function(content) {
                content.classList.remove('active');
            });

            // Show the clicked content section
            contents[index].classList.add('active');
        }

        icon.addEventListener('click', toggleContent);
        icon.addEventListener('touchstart', toggleContent);
    });
});