MediaWiki:Common.js: Difference between revisions

From The Talos Principle Wiki
Custom animated hints
 
Changed "collapsible" to "custom-collapsible" to avoid potential conflicts
Line 2: Line 2:


/* Custom animated hints: */
/* Custom animated hints: */
   var coll = document.getElementsByClassName("collapsible");
   var coll = document.getElementsByClassName("custom-collapsible");
   var i;
   var i;
    
    

Revision as of 12:38, 19 November 2023

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

/* Custom animated hints: */
  var coll = document.getElementsByClassName("custom-collapsible");
  var i;
  
  for (i = 0; i < coll.length; i++) {
    coll[i].addEventListener("click", function() {
      this.classList.toggle("active");
      var content = this.nextElementSibling;
      if (content.style.maxHeight){
        content.style.maxHeight = null;
      } else {
        content.style.maxHeight = content.scrollHeight + "px";
      } 
    });
  }