MediaWiki:Common.js: Difference between revisions

From ANZUS Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


/*Collapsible Icon Menu*/
/*Upgrade Icon Menu*/
window.onload = function() {
mw.loader.using(['jquery'], function() {
    var icons = document.querySelectorAll('.collapsible-icon');
$(document).ready(function(){
    var contents = document.querySelectorAll('.collapsible-content');
$('.upgrade-icon').click(function(e){
 
$('.upgrade-icon').removeClass('active-icon');
    icons.forEach(function(icon, index) {
$(this).toggleClass('active-icon');
        function toggleContent() {
var id = $(this).attr('id');
            // Remove 'active' class from all icons and content sections
$('.upgrade-content').hide();
            icons.forEach(function(icon) {
$('#' + id + '.upgrade-content').show();
                icon.classList.remove('active');
});  
            });
});
            contents.forEach(function(content) {
});
                content.classList.remove('active');
            });
 
            // Add 'active' class to the clicked icon and its corresponding content
            icons[index].classList.add('active');
            contents[index].classList.add('active');
        }
 
        icon.addEventListener('click', toggleContent);
    });
};

Revision as of 23:54, 19 May 2024

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

/*Upgrade Icon Menu*/
mw.loader.using(['jquery'], function() {
	$(document).ready(function(){
		$('.upgrade-icon').click(function(e){
			$('.upgrade-icon').removeClass('active-icon');
			$(this).toggleClass('active-icon');
				var id = $(this).attr('id');
			$('.upgrade-content').hide();
			$('#' + id + '.upgrade-content').show();
		}); 
	});
});