mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-25 06:47:16 +00:00
Attempt to convert to ES5
This commit is contained in:
parent
333385feb5
commit
14600612bb
|
@ -7,8 +7,8 @@
|
|||
// Hide header on scroll down
|
||||
var didScroll,
|
||||
lastScrollTop = 0,
|
||||
navbarHeight = 0;
|
||||
var delta = 0,
|
||||
navbarHeight = 0,
|
||||
delta = 0,
|
||||
header = document.getElementsByTagName('header')[0],
|
||||
headerContainer = document.querySelector('.mw-header-container');
|
||||
|
||||
|
@ -21,7 +21,10 @@
|
|||
});
|
||||
|
||||
function hasScrolled() {
|
||||
var st = window.scrollY; // Make scroll more than delta
|
||||
var st = window.scrollY,
|
||||
body,
|
||||
html,
|
||||
documentHeight;
|
||||
|
||||
if (Math.abs(lastScrollTop - st) <= delta) {
|
||||
return;
|
||||
|
@ -34,8 +37,8 @@
|
|||
header.classList.add('nav-up');
|
||||
} else {
|
||||
// Scroll Up
|
||||
var body = document.body,
|
||||
html = document.documentElement,
|
||||
body = document.body;
|
||||
html = document.documentElement;
|
||||
documentHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
||||
|
||||
if (st + window.innerHeight < documentHeight) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Lazyloading images with Native API or IntersectionObserver
|
||||
*/
|
||||
|
||||
var observer;
|
||||
|
||||
// Native API
|
||||
if ('loading' in HTMLImageElement.prototype) {
|
||||
document.querySelectorAll('img.lazy').forEach(function(img) {
|
||||
|
@ -19,7 +21,7 @@ if ('loading' in HTMLImageElement.prototype) {
|
|||
} else {
|
||||
// IntersectionObserver API
|
||||
if (typeof IntersectionObserver !== 'undefined' && 'forEach' in NodeList.prototype) {
|
||||
var observer = new IntersectionObserver(function(changes) {
|
||||
observer = new IntersectionObserver(function(changes) {
|
||||
if ('connection' in navigator && navigator.connection.saveData === true) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,16 +28,15 @@ function ScrollSpy() {
|
|||
var sections = document.querySelectorAll(".mw-headline");
|
||||
window.addEventListener("scroll", function() {
|
||||
var scrollPos = document.documentElement.scrollTop || document.body.scrollTop,
|
||||
section, id;
|
||||
section, id, node, active;
|
||||
|
||||
for (section in sections) {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(sections, section) &&
|
||||
sections[section].offsetTop <= scrollPos
|
||||
) {
|
||||
id = mw.util.escapeIdForAttribute(sections[section].id),
|
||||
node = document.querySelector('a[href * = "'.concat(id, '"]'))
|
||||
.parentNode,
|
||||
id = mw.util.escapeIdForAttribute(sections[section].id);
|
||||
node = document.querySelector('a[href * = "'.concat(id, '"]')).parentNode;
|
||||
active = document.querySelector(".active");
|
||||
if (active !== null) {
|
||||
active.classList.remove("active");
|
||||
|
|
Loading…
Reference in a new issue