mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-25 14:57:31 +00:00
Attempt to convert to ES5
This commit is contained in:
parent
ed22023fce
commit
a40547ec1b
|
@ -5,9 +5,10 @@
|
||||||
* Smooth scroll fallback and Scrollspy
|
* Smooth scroll fallback and Scrollspy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var SmoothScroll = function SmoothScroll() {
|
function SmoothScroll() {
|
||||||
|
var navLinks, eventListener, link;
|
||||||
if (!("scrollBehavior" in document.documentElement.style)) {
|
if (!("scrollBehavior" in document.documentElement.style)) {
|
||||||
var navLinks = document.querySelectorAll("#toc a"),
|
navLinks = document.querySelectorAll("#toc a"),
|
||||||
eventListener = function eventListener(e) {
|
eventListener = function eventListener(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.target.scrollIntoView({
|
e.target.scrollIntoView({
|
||||||
|
@ -15,14 +16,14 @@ var SmoothScroll = function SmoothScroll() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var link in navLinks) {
|
for (link in navLinks) {
|
||||||
if (Object.prototype.hasOwnProperty.call(navLinks, link)) {
|
if (Object.prototype.hasOwnProperty.call(navLinks, link)) {
|
||||||
navLinks[link].addEventListener("click", eventListener);
|
navLinks[link].addEventListener("click", eventListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ScrollSpy = function ScrollSpy() {
|
function ScrollSpy() {
|
||||||
var sections = document.querySelectorAll(".mw-headline");
|
var sections = document.querySelectorAll(".mw-headline");
|
||||||
window.addEventListener("scroll", function() {
|
window.addEventListener("scroll", function() {
|
||||||
var scrollPos =
|
var scrollPos =
|
||||||
|
@ -48,13 +49,13 @@ var SmoothScroll = function SmoothScroll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
CheckToC = function CheckToC() {
|
function CheckToC() {
|
||||||
if (document.getElementById("toc")) {
|
if (document.getElementById("toc")) {
|
||||||
SmoothScroll();
|
SmoothScroll();
|
||||||
ScrollSpy();
|
ScrollSpy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (document.readyState !== "loading") {
|
if (document.readyState !== "loading") {
|
||||||
CheckToC();
|
CheckToC();
|
||||||
|
|
Loading…
Reference in a new issue