MediaWiki:Common.js

From SZ
Revision as of 14:59, 24 August 2025 by Test2 (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using(['mediawiki.util']).then(function () {
  function initCollapsiblePortlet(name) {
    var portal = document.getElementById('p-' + name);
    if (!portal) return;

    var heading = portal.querySelector('.vector-menu-heading, h3');
    var content = portal.querySelector('.vector-menu-content, .body');
    if (!heading || !content) return;

    // Debugging: confirm elements
    console.log('Found portal:', name, heading, content);

    // Rest of your code unchanged...
  }

  function bootCollapsibleSidebars() {
    COLLAPSIBLE_SECTIONS.forEach(initCollapsiblePortlet);
  }

  mw.hook('wikipage.content').add(bootCollapsibleSidebars);
  $(bootCollapsibleSidebars);
});