Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js: Difference between revisions

MediaWiki interface page
No edit summary
Tag: Manual revert
No edit summary
Line 86: Line 86:
       };
       };
     });
     });
  }
});
// === Safely intercept TOC clicks directly to fix expand timing ===
mw.hook('wikipage.content').add(function() {
  if (window.innerWidth >= 768) {
    setTimeout(() => { // Small delay to let TOC fully render
      document.querySelectorAll('#mw-panel-toc a[href^="#"]').forEach(function(anchor) {
        anchor.addEventListener('click', function(e) {
          const hash = decodeURIComponent(this.getAttribute('href')).substring(1);
          const heading = document.getElementById(hash);
          if (heading) {
            e.preventDefault(); // Prevent default browser jump
            expandCitizenSectionFromHeading(heading);
            setTimeout(() => {
              heading.scrollIntoView({ behavior: 'smooth', block: 'start' });
            }, 50);
          }
        });
      });
    }, 200);
   }
   }
});
});