Merge branch 'dev' of github.com:StarCitizenTools/mediawiki-skins-Citizen into dev

This commit is contained in:
alistair3149 2020-02-15 19:25:56 -05:00
commit 14b5ba8e51
3 changed files with 71 additions and 71 deletions

View file

@ -56,4 +56,4 @@
didScroll = false;
}
}, 250 );
})();
}() );

View file

@ -7,26 +7,26 @@
function SmoothScroll() {
var navLinks, eventListener, link;
if (!("scrollBehavior" in document.documentElement.style)) {
navLinks = document.querySelectorAll("#toc a");
if ( !( 'scrollBehavior' in document.documentElement.style ) ) {
navLinks = document.querySelectorAll( '#toc a' );
eventListener = function eventListener( e ) {
e.preventDefault();
e.target.scrollIntoView( {
behavior: "smooth"
behavior: 'smooth'
} );
};
for ( link in navLinks ) {
if ( Object.prototype.hasOwnProperty.call( navLinks, link ) ) {
navLinks[link].addEventListener("click", eventListener);
navLinks[ link ].addEventListener( 'click', eventListener );
}
}
}
}
function ScrollSpy() {
var sections = document.querySelectorAll(".mw-headline");
window.addEventListener("scroll", function() {
var sections = document.querySelectorAll( '.mw-headline' );
window.addEventListener( 'scroll', function () {
var scrollPos = document.documentElement.scrollTop || document.body.scrollTop,
section, id, node, active;
@ -37,12 +37,12 @@ function ScrollSpy() {
) {
id = mw.util.escapeIdForAttribute( sections[ section ].id );
node = document.querySelector( "a[href='#" + id + "']" ).parentNode;
active = document.querySelector(".active");
active = document.querySelector( '.active' );
if ( active !== null ) {
active.classList.remove("active");
active.classList.remove( 'active' );
}
if ( node !== null ) {
node.classList.add("active");
node.classList.add( 'active' );
}
}
}
@ -50,21 +50,21 @@ function ScrollSpy() {
}
function CheckToC() {
if (document.getElementById("toc")) {
if ( document.getElementById( 'toc' ) ) {
SmoothScroll();
ScrollSpy();
}
}
if (document.readyState !== "loading") {
if ( document.readyState !== 'loading' ) {
CheckToC();
} else if ( document.addEventListener ) {
// All modern browsers to register DOMContentLoaded
document.addEventListener("DOMContentLoaded", CheckToC);
document.addEventListener( 'DOMContentLoaded', CheckToC );
} else {
// Old IE browsers
document.attachEvent("onreadystatechange", function() {
if (document.readyState === "complete") {
document.attachEvent( 'onreadystatechange', function () {
if ( document.readyState === 'complete' ) {
CheckToC();
}
} );