MediaWiki:Common.js: Difference between revisions
mNo edit summary Tag: Manual revert |
mNo edit summary |
||
| Line 111: | Line 111: | ||
/* ========================================================= | /* ========================================================= | ||
OOO Browser | OOO Browser anchor activation | ||
========================================================= */ | ========================================================= */ | ||
mw.hook('wikipage.content').add(function () { | |||
const | const hash = window.location.hash.replace('#',''); | ||
if (! | if (!hash) return; | ||
const browser = item.closest( | const item = document.querySelector('.ooo-browser__item[data-target="'+hash+'"]'); | ||
const panel = document.getElementById(hash); | |||
if (!item || !panel) return; | |||
const browser = item.closest('.ooo-browser'); | |||
if (!browser) return; | if (!browser) return; | ||
browser.querySelectorAll('.ooo-browser__item') | |||
.forEach(el => el.classList.remove('is-active')); | |||
browser.querySelectorAll( | |||
.forEach(el => el.classList.remove( | |||
browser.querySelectorAll('.ooo-browser__info') | |||
browser.querySelectorAll( | .forEach(el => el.classList.remove('is-active')); | ||
.forEach(el => el.classList.remove( | |||
item.classList.add('is-active'); | |||
panel.classList.add('is-active'); | |||
setTimeout(() => { | |||
panel.scrollIntoView({ block: "start" }); | |||
.scrollIntoView({ block: "start", | }, 200); | ||
}); | }); | ||