MediaWiki:Common.js

From Hazeron Wiki
Revision as of 09:46, 7 April 2019 by Deantwo (talk | contribs) (Can't use the class that hides things. Duh.)
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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

/* Implements section-collapse and stop-section-collapse */
var collapsing = document.querySelectorAll(".section-collapse");
if (collapsing.length>0) {
    for (var i = 0; i < collapsing.length ; i++) {
        collapsing.item(i).addEventListener('click',collapseHandler,false);
        if (collapsing.item(i).contains("collapsed")) {
            collapseHandler(collapsing.item(i));
        }
    }
}

function collapseHandler() {
   var c = this.parentNode.parentNode.nextSibling;
   collapseHandlerThis(c);
}
function collapseHandlerThis(c) {
   while (c) {
      if (c.classList) {
        if (c.classList.contains("section-collapse") || c.classList.contains("stop-section-collapse"))
           break;
        c.classList.toggle('section-collapsed');
      }
      c = c.nextSibling;
   }
   this.classList.toggle('collapsed-icon');
}