MediaWiki:Common.js: Difference between revisions
Content deleted Content added
No edit summary Tag: Manual revert |
No edit summary |
||
Line 234:
// Navigate and try to ensure mobile-collapsed sections are visible
// Navigate and try to ensure mobile-collapsed sections are visible
list.addEventListener('click', function (e) {
var a = e.target.closest('a');
Line 240 ⟶ 241:
var targetId = a.getAttribute('href').slice(1);
// === NEW LOGIC START: Scroll to Top for "Contents" ===
// If the user clicks the "Contents" header (id="mw-toc-heading"), scroll to top (0,0)
if (targetId === 'mw-toc-heading') {
closeOverlay();
window.scrollTo({ top: 0, behavior: 'smooth' });
// Optional: Remove the hash (#) from the URL bar for a clean look
if (history.replaceState) {
history.replaceState(null, '', window.location.pathname + window.location.search);
}
return;
}
// === NEW LOGIC END ===
var target = document.getElementById(targetId);
closeOverlay();
| |||