MediaWiki

Foreground.js: Difference between revisions

From Grouse House Wiki

No edit summary
No edit summary
 
(56 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Collapsible Headers on Desktop */
/* Scroll to top and sidebar logo */


var coll = document.getElementsByTagName('h2');
var scrollbutton = document.getElementById("scrollToTop");
var i;
var sidebarlogo = document.getElementById("sidebarlogo");


for (i = 0; i < coll.length; i++) {
window.onscroll = function() {scrollFunction()};
   coll[i].addEventListener("click", function() {
 
     this.classList.toggle("active");
function scrollFunction() {
     var content = this.nextElementSibling;
   if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    if (content.style.display === "block") {
     scrollbutton.style.display = "block";
      content.style.display = "none";
     sidebarlogo.style.display = "block";
     } else {
  } else {
      content.style.display = "block";
    scrollbutton.style.display = "none";
    }
     sidebarlogo.style.display = "none";
   });
   }
}
}


var coll2 = document.getElementsByClassName('coll-header');
function topFunction() {
var i2;
   document.body.scrollTop = 0;  
 
  document.documentElement.scrollTop = 0;
for (i2 = 0; i2 < coll2.length; i2++) {
   coll2[i2].addEventListener("click", function() {
    this.classList.toggle("active");
    var content = this.nextElementSibling;
    if (content.style.display === "block") {
      content.style.display = "none";
    } else {
      content.style.display = "block";
    }
  });
}
}

Latest revision as of 01:43, 1 April 2024

/* Scroll to top and sidebar logo */

var scrollbutton = document.getElementById("scrollToTop");
var sidebarlogo = document.getElementById("sidebarlogo");

window.onscroll = function() {scrollFunction()};

function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    scrollbutton.style.display = "block";
    sidebarlogo.style.display = "block";
  } else {
    scrollbutton.style.display = "none";
    sidebarlogo.style.display = "none";
  }
}

function topFunction() {
  document.body.scrollTop = 0; 
  document.documentElement.scrollTop = 0;
}