MediaWiki:Common.js: Difference between revisions

mNo edit summary
Tag: Reverted
mNo edit summary
Tag: Manual revert
Line 143: Line 143:
   browser.querySelector(".ooo-browser__panel")
   browser.querySelector(".ooo-browser__panel")
     .scrollIntoView({ block: "start", behavior: "instant" });
     .scrollIntoView({ block: "start", behavior: "instant" });
});
/* =========================================================
  OOO Browser anchor activation (for wiki links)
  ========================================================= */
document.addEventListener("DOMContentLoaded", function () {
  const hash = window.location.hash.replace("#", "");
  if (!hash) return;
  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;
  // activate item
  browser.querySelectorAll(".ooo-browser__item")
    .forEach(el => el.classList.remove("is-active"));
  item.classList.add("is-active");
  // activate panel
  browser.querySelectorAll(".ooo-browser__info")
    .forEach(el => el.classList.remove("is-active"));
  panel.classList.add("is-active");


});
});