MediaWiki

Common.js: Difference between revisions

From Redrock Wiki

No edit summary
No edit summary
 
(18 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 7: Line 8:
     coll[i].addEventListener("click", function () {
     coll[i].addEventListener("click", function () {
       var content = this.nextElementSibling
       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") {
       if (content.style.display === "inline") {
         content.style.display = "none";
         content.style.cssText = 'display: none !important';
         this.innerHTML = this.innerHTML.replace('{{#fas:angle-down}}', '{{#fas:angle-up}}');
         this.innerHTML = this.innerHTML.replace('-down', '-up');
        console.log('changing' + this.innerHTML + ' to ' + this.innerHTML.replace('-', '+'));
       } else {
       } else {
         content.style.display = "inline";
         content.style.cssText = 'display: inline !important';
         this.innerHTML = this.innerHTML.replace('{{#fas:angle-up}}', '{{#fas:angle-down}}');
         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');
      }
    });
  }
});