MediaWiki:Common.js: відмінності між версіями
Country main pages: collapse all Minerva sections by default
(Banner JS: kicker + brand-name spans) |
(Country main pages: collapse all Minerva sections by default) |
||
| Рядок 97: | Рядок 97: | ||
hero.appendChild(toolbar); | hero.appendChild(toolbar); | ||
} | } | ||
}); | |||
// Country main pages — collapse all sections by default on Minerva | |||
// (page name starts with regional indicator emoji pair = flag, no subpage separator) | |||
function isCountryMainPage() { | |||
var pageName = mw.config.get("wgPageName") || ""; | |||
if (pageName.indexOf("/") !== -1) return false; | |||
return /^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/.test(pageName); | |||
} | |||
mw.hook("wikipage.content").add(function () { | |||
if (mw.config.get("skin") !== "minerva") return; | |||
if (!isCountryMainPage()) return; | |||
// Run after Minerva's section toggler has expanded sections | |||
setTimeout(function () { | |||
var nodes = document.querySelectorAll( | |||
".collapsible-block.open-block, .section-heading.open-block, .collapsible-heading.open-block" | |||
); | |||
nodes.forEach(function (el) { el.classList.remove("open-block"); }); | |||
}, 0); | |||
}); | }); | ||