MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 115: Line 115:


/* ======================================= Template:Drawer ======================================= */
/* ======================================= Template:Drawer ======================================= */
for (i = 1; i < 100; i++) {
var drawerButtonsArray = document.querySelectorAll(".drawer-button");
if (document.getElementById('drawer-button-'+i)) {
 
document.getElementById('drawer-button-'+i).addEventListener('click', function(){  
drawerButtonsArray.forEach(function(x){
var content = document.getElementById("drawer-"+i); //outputs something like document.getElementById("drawer-1")
var i = 1;
var button = document.getElementById("drawer-button-"+i); //outputs something like document.getElementById("drawer-button-1")
x.addEventListener("click", function(i){
if (content.style.display == "block") {
    content.style.display = "none";
var content = document.getElementById("drawer-"+i); //outputs something like document.getElementById("drawer-1")
button.innerHTML = "Expand";
var button = document.getElementById("drawer-button-"+i); //outputs something like document.getElementById("drawer-button-1")
} else {
if (content.style.display == "block") {
    content.style.display = "block";
    content.style.display = "none";
    button.innerHTML = "Collapse";
button.innerHTML = "Expand";
}
} else {
} );
    content.style.display = "block";
console.log("aggiunto eventListener per drawer-button-"+i);
    button.innerHTML = "Collapse";
}
}
}
});
i++;
});


/* ======================================= Matomo tracking code ======================================= */
/* ======================================= Matomo tracking code ======================================= */