31 lines
820 B
JavaScript
31 lines
820 B
JavaScript
async function xmr_media_lazyload_perform(element) {
|
|
let content = element.querySelector("noscript");
|
|
if (content) {
|
|
element.innerHTML = content.innerText;
|
|
}
|
|
}
|
|
|
|
async function xmr_media_lazyload_initialize() {
|
|
// Figure out what to load.
|
|
let elements = document.querySelectorAll(".block-media > [data-lazyload]");
|
|
let stack = Array.from(elements);
|
|
console.debug("Lazily loading " + stack.length + " elements...");
|
|
|
|
// Add a lazyloading handler to all entries.
|
|
for (let el of stack) {
|
|
xmr_media_lazyload_perform(el);
|
|
}
|
|
}
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
// Support for Mobile Devices
|
|
document.querySelector("#navigation-toggle").addEventListener("click", (ev) => {
|
|
document.querySelector("#header #navigation").classList.toggle("open");
|
|
});
|
|
|
|
// Lazily load Media
|
|
xmr_media_lazyload_initialize();
|
|
})();
|