MediaWiki:Common.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 724:
});
}
// After hiding nested h6 entries, a parent whose children were ALL h6 keeps a
// dangling expand/collapse chevron with nothing left to reveal — hide those
// toggles (and restore any that still have a visible child, on a re-run).
function hideEmptyToggles() {
var items = document.querySelectorAll('.vector-toc .vector-toc-list-item');
Array.prototype.forEach.call(items, function (li) {
var toggle = li.querySelector(':scope > .vector-toc-toggle');
if (!toggle) { return; }
var childList = li.querySelector(':scope > .vector-toc-list');
var visible = false;
if (childList) {
Array.prototype.forEach.call(
childList.querySelectorAll(':scope > .vector-toc-list-item'),
function (k) { if (k.style.display !== 'none') { visible = true; } }
);
}
toggle.style.display = visible ? '' : 'none';
});
}
function run() { pruneTocH6(); hideEmptyToggles(); }
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded',
} else {
}
// Vector can lazily (re)build the pinned TOC; re-run on its content hook.
if (window.mw && mw.hook) { mw.hook('wikipage.content').add(
})();
| |||