MediaWiki:Common.js: Difference between revisions

From ANZUS Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
document.addEventListener("DOMContentLoaded", function() {
/* Any JavaScript here will be loaded for all users on every page load. */
    var icons = document.querySelectorAll('.collapsible-icon');
    var contents = document.querySelectorAll('.collapsible-content');


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


            // Add 'active' class to the clicked icon and its corresponding content
/*Accordions*/
            icons[index].classList.add('active');
mw.loader.using(['jquery'], function() {
            contents[index].classList.add('active');
$(document).ready(function(){
        }
$('.accordion-button').click(function(e){
 
$(this).toggleClass('active-accordion');
        icon.addEventListener('click', toggleContent);
var panel = $(this).next();
        icon.addEventListener('touchstart', toggleContent);
$(panel).toggle();
    });
});
});
});
});

Latest revision as of 14:51, 12 June 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();
		}); 
	});
});

/*Accordions*/
mw.loader.using(['jquery'], function() {
	$(document).ready(function(){
		$('.accordion-button').click(function(e){
			$(this).toggleClass('active-accordion');
				var panel = $(this).next();
			$(panel).toggle();
		}); 
	});
});