MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Can't use the class that hides things. Duh.) |
(Removed temporary dark mode fix) |
||
(32 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
for (var i = 0; i < collapsing.length ; i++) { | for (var i = 0; i < collapsing.length ; i++) { | ||
collapsing.item(i).addEventListener('click',collapseHandler,false); | collapsing.item(i).addEventListener('click',collapseHandler,false); | ||
if (collapsing.item(i).contains("collapsed")) | if (collapsing.item(i).classList.contains("collapsed")) | ||
collapseHandlerThis(collapsing.item(i)); | |||
} | } | ||
} | } | ||
function collapseHandler() { | function collapseHandler() { | ||
collapseHandlerThis(this); | |||
collapseHandlerThis( | |||
} | } | ||
function collapseHandlerThis( | function collapseHandlerThis(t) { | ||
var c = t.parentNode.parentNode.nextSibling; | |||
while (c) { | while (c) { | ||
if (c.classList) { | if (c.classList) { | ||
Line 25: | Line 24: | ||
c = c.nextSibling; | c = c.nextSibling; | ||
} | } | ||
t.classList.toggle('collapsed-icon'); | |||
} | } |
Latest revision as of 15:08, 16 April 2024
/* Any JavaScript here will be loaded for all users on every page load. */ /* Implements section-collapse and stop-section-collapse */ var collapsing = document.querySelectorAll(".section-collapse"); if (collapsing.length>0) { for (var i = 0; i < collapsing.length ; i++) { collapsing.item(i).addEventListener('click',collapseHandler,false); if (collapsing.item(i).classList.contains("collapsed")) collapseHandlerThis(collapsing.item(i)); } } function collapseHandler() { collapseHandlerThis(this); } function collapseHandlerThis(t) { var c = t.parentNode.parentNode.nextSibling; while (c) { if (c.classList) { if (c.classList.contains("section-collapse") || c.classList.contains("stop-section-collapse")) break; c.classList.toggle('section-collapsed'); } c = c.nextSibling; } t.classList.toggle('collapsed-icon'); }