Github CI lint - phpcbf

This commit is contained in:
github-actions 2020-02-15 22:32:59 +00:00
parent ed22023fce
commit 97f8846a44

View file

@ -6,66 +6,66 @@
*/ */
var SmoothScroll = function SmoothScroll() { var SmoothScroll = function SmoothScroll() {
if (!("scrollBehavior" in document.documentElement.style)) { if (!("scrollBehavior" in document.documentElement.style)) {
var navLinks = document.querySelectorAll("#toc a"), var navLinks = document.querySelectorAll("#toc a"),
eventListener = function eventListener(e) { eventListener = function eventListener(e) {
e.preventDefault(); e.preventDefault();
e.target.scrollIntoView({ e.target.scrollIntoView({
behavior: "smooth" behavior: "smooth"
}); });
}; };
for (var link in navLinks) { for (var 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() { 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 =
document.documentElement.scrollTop || document.body.scrollTop; document.documentElement.scrollTop || document.body.scrollTop;
for (var section in sections) { for (var section in sections) {
if ( if (
Object.prototype.hasOwnProperty.call(sections, section) && Object.prototype.hasOwnProperty.call(sections, section) &&
sections[section].offsetTop <= scrollPos sections[section].offsetTop <= scrollPos
) { ) {
var id = mw.util.escapeIdForAttribute(sections[section].id), var id = mw.util.escapeIdForAttribute(sections[section].id),
node = document.querySelector('a[href * = "'.concat(id, '"]')) node = document.querySelector('a[href * = "'.concat(id, '"]'))
.parentNode, .parentNode,
active = document.querySelector(".active"); active = document.querySelector(".active");
if (active !== null) { if (active !== null) {
active.classList.remove("active"); active.classList.remove("active");
} }
if (node !== null) { if (node !== null) {
node.classList.add("active"); node.classList.add("active");
} }
} }
} }
}); });
}, },
CheckToC = function CheckToC() { 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();
} else if (document.addEventListener) { } else if (document.addEventListener) {
// All modern browsers to register DOMContentLoaded // All modern browsers to register DOMContentLoaded
document.addEventListener("DOMContentLoaded", CheckToC); document.addEventListener("DOMContentLoaded", CheckToC);
} else { } else {
// Old IE browsers // Old IE browsers
document.attachEvent("onreadystatechange", function() { document.attachEvent("onreadystatechange", function() {
if (document.readyState === "complete") { if (document.readyState === "complete") {
CheckToC(); CheckToC();
} }
}); });
} }