MediaWiki:Common.js: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 111: | Line 111: | ||
/* ========================================================= | /* ========================================================= | ||
OOO | OOO Anchor navigation (tabs + browser) | ||
========================================================= */ | ========================================================= */ | ||
mw.hook('wikipage.content').add(function () { | mw.hook('wikipage.content').add(function () { | ||
const hash = | const hash = location.hash.replace('#',''); | ||
if (!hash) return; | if (!hash) return; | ||
setTimeout(function(){ | |||
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'); | |||
browser.querySelectorAll('.ooo-browser__item') | |||
.forEach(el => el.classList.remove('is-active')); | |||
browser.querySelectorAll('.ooo-browser__info') | |||
panel.scrollIntoView({ block: | .forEach(el => el.classList.remove('is-active')); | ||
}, | |||
item.classList.add('is-active'); | |||
panel.classList.add('is-active'); | |||
panel.scrollIntoView({block:'start'}); | |||
},300); | |||
}); | }); | ||