MediaWiki

Common.js: Difference between revisions

From Redrock Wiki

No edit summary
Tag: Manual revert
No edit summary
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


/* collapsible categories */
$(function () {
$(function () {
   var coll = document.getElementsByClassName("collapsibleList");
   var coll = document.getElementsByClassName("collapsibleList");
Line 6: Line 7:
   for (var i = 0; i < coll.length; i++) {
   for (var i = 0; i < coll.length; i++) {
     coll[i].addEventListener("click", function () {
     coll[i].addEventListener("click", function () {
     
       var content = this.nextElementSibling
       var content = document.getElementById('list');
 
       if (content.style.display === "block") {
      if (this.closest('.collapsedDefault') && !content.classList.contains("overridden")) {
         content.style.display = "none";
        content.style.cssText = 'display: inline !important';
         this.innerHTML = this.innerHTML.replace('-', '+');
        content.classList.add("overridden");
        return;
      }
 
       if (content.style.display === "inline") {
         content.style.cssText = 'display: none !important';
         this.innerHTML = this.innerHTML.replace('-down', '-up');
       } else {
       } else {
         content.style.display = "block";
         content.style.cssText = 'display: inline !important';
         this.innerHTML = this.innerHTML.replace('+', '-');
         this.innerHTML = this.innerHTML.replace('-up', '-down');
       }
       }
     });
     });
   }
   }
});
});

Latest revision as of 18:36, 9 April 2026

/* Any JavaScript here will be loaded for all users on every page load. */

/* collapsible categories */
$(function () {
  var coll = document.getElementsByClassName("collapsibleList");

  for (var i = 0; i < coll.length; i++) {
    coll[i].addEventListener("click", function () {
      var content = this.nextElementSibling

      if (this.closest('.collapsedDefault') && !content.classList.contains("overridden")) {
        content.style.cssText = 'display: inline !important';
        content.classList.add("overridden");
        return;
      }

      if (content.style.display === "inline") {
        content.style.cssText = 'display: none !important';
        this.innerHTML = this.innerHTML.replace('-down', '-up');
      } else {
        content.style.cssText = 'display: inline !important';
        this.innerHTML = this.innerHTML.replace('-up', '-down');
      }
    });
  }
});