36 lines
977 B
JavaScript
36 lines
977 B
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
// Support for Mobile Devices
|
|
document.querySelector("#navigation-toggle").addEventListener("click", (ev) => {
|
|
document.querySelector("#header #navigation").classList.toggle("open");
|
|
});
|
|
|
|
{ // Lazily load Media
|
|
let info = {}
|
|
new Promise((resolve, reject) => {
|
|
// Figure out what to load.
|
|
info.elements = document.querySelectorAll(".block-media > [data-lazyload]");
|
|
info.stack = Array.from(info.elements);
|
|
console.debug("Lazily loading " + info.stack.length + " elements...");
|
|
|
|
// Begin processing at 1ms intervals.
|
|
info.cbid = 0;
|
|
info.cbid = window.setInterval(() => {
|
|
let el = info.stack.pop();
|
|
let lazycontent = el.querySelector("noscript");
|
|
el.innerHTML = lazycontent.innerHTML;
|
|
|
|
if (info.stack.length == 0) {
|
|
window.clearInterval(info.cbid);
|
|
resolve();
|
|
}
|
|
}, 1);
|
|
}).finally(() => {
|
|
console.debug("Lazy loading complete.");
|
|
window.clearInterval(info.cbid);
|
|
});
|
|
}
|
|
|
|
})();
|