MediaWiki:Common.js: Difference between revisions
Appearance
Changed "collapsible" to "custom-collapsible" to avoid potential conflicts |
Allows different style (e.g., a border) while visible. |
||
| Line 11: | Line 11: | ||
if (content.style.maxHeight){ | if (content.style.maxHeight){ | ||
content.style.maxHeight = null; | content.style.maxHeight = null; | ||
content.classList.remove("custom-collapsible-content-visible"); | |||
} else { | } else { | ||
content.style.maxHeight = content.scrollHeight + "px"; | content.style.maxHeight = content.scrollHeight + "px"; | ||
content.classList.add("custom-collapsible-content-visible"); | |||
} | } | ||
}); | }); | ||
} | } | ||
Revision as of 13:54, 19 November 2023
/* Any JavaScript here will be loaded for all users on every page load. */
/* Custom animated hints: */
var coll = document.getElementsByClassName("custom-collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
content.classList.remove("custom-collapsible-content-visible");
} else {
content.style.maxHeight = content.scrollHeight + "px";
content.classList.add("custom-collapsible-content-visible");
}
});
}