MediaWiki:Common.js: Unterschied zwischen den Versionen
LB (Diskussion | Beiträge) |
LB (Diskussion | Beiträge) |
||
Zeile 2: | Zeile 2: | ||
− | /* back to top-button */ | + | /* ==== back to top-button ==== */ |
document.getElementById("btt").addEventListener("mouseenter",function(){ this.style.opacity="1.0", this.style.transition="0.5s" }); | document.getElementById("btt").addEventListener("mouseenter",function(){ this.style.opacity="1.0", this.style.transition="0.5s" }); | ||
document.getElementById("btt").addEventListener("mouseleave",function(){ this.style.opacity="0.7", this.style.transition="0.5s" }); | document.getElementById("btt").addEventListener("mouseleave",function(){ this.style.opacity="0.7", this.style.transition="0.5s" }); | ||
− | /* accordion */ | + | /* ==== accordion ==== */ |
var acc = document.getElementsByClassName("accordion"); | var acc = document.getElementsByClassName("accordion"); | ||
var i; | var i; | ||
Zeile 22: | Zeile 22: | ||
}); | }); | ||
} | } | ||
+ | |||
+ | |||
+ | /* ===== Scroll to Top ==== */ | ||
+ | $(window).scroll(function() { | ||
+ | if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px | ||
+ | $('#return-to-top').fadeIn(200); // Fade in the arrow | ||
+ | } else { | ||
+ | $('#return-to-top').fadeOut(200); // Else fade out the arrow | ||
+ | } | ||
+ | }); | ||
+ | $('#return-to-top').click(function() { // When arrow is clicked | ||
+ | $('body,html').animate({ | ||
+ | scrollTop : 0 // Scroll to top of body | ||
+ | }, 500); | ||
+ | }); |
Version vom 1. Juni 2018, 16:13 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* ==== back to top-button ==== */
document.getElementById("btt").addEventListener("mouseenter",function(){ this.style.opacity="1.0", this.style.transition="0.5s" });
document.getElementById("btt").addEventListener("mouseleave",function(){ this.style.opacity="0.7", this.style.transition="0.5s" });
/* ==== accordion ==== */
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}
/* ===== Scroll to Top ==== */
$(window).scroll(function() {
if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px
$('#return-to-top').fadeIn(200); // Fade in the arrow
} else {
$('#return-to-top').fadeOut(200); // Else fade out the arrow
}
});
$('#return-to-top').click(function() { // When arrow is clicked
$('body,html').animate({
scrollTop : 0 // Scroll to top of body
}, 500);
});