MediaWiki:Common.js: Difference between revisions

mNo edit summary
mNo edit summary
Line 111: Line 111:


/* =========================================================
/* =========================================================
   OOO Browser anchor activation
   OOO Anchor navigation (tabs + browser)
   ========================================================= */
   ========================================================= */


mw.hook('wikipage.content').add(function () {
mw.hook('wikipage.content').add(function () {


   const hash = window.location.hash.replace('#','');
   const hash = location.hash.replace('#','');
   if (!hash) return;
   if (!hash) return;


   const item = document.querySelector('.ooo-browser__item[data-target="'+hash+'"]');
   setTimeout(function(){
  const panel = document.getElementById(hash);
  if (!item || !panel) return;


  const browser = item.closest('.ooo-browser');
    const item = document.querySelector('.ooo-browser__item[data-target="'+hash+'"]');
  if (!browser) return;
    const panel = document.getElementById(hash);


  browser.querySelectorAll('.ooo-browser__item')
     if (!item || !panel) return;
     .forEach(el => el.classList.remove('is-active'));


  browser.querySelectorAll('.ooo-browser__info')
    const browser = item.closest('.ooo-browser');
    .forEach(el => el.classList.remove('is-active'));


  item.classList.add('is-active');
    browser.querySelectorAll('.ooo-browser__item')
  panel.classList.add('is-active');
      .forEach(el => el.classList.remove('is-active'));


  setTimeout(() => {
    browser.querySelectorAll('.ooo-browser__info')
     panel.scrollIntoView({ block: "start" });
      .forEach(el => el.classList.remove('is-active'));
   }, 200);
 
    item.classList.add('is-active');
    panel.classList.add('is-active');
 
     panel.scrollIntoView({block:'start'});
 
   },300);


});
});