mirror of
https://github.com/Kugelschieber/schnittfest.git
synced 2026-11-12 09:02:01 +01:00
New design.
This commit is contained in:
+38
-1
@@ -1 +1,38 @@
|
||||
console.log("Hi!");
|
||||
import { initNav } from "./nav.js";
|
||||
import { initReveal } from "./reveal.js";
|
||||
import { initTimecode } from "./timecode.js";
|
||||
|
||||
document.documentElement.classList.add("js");
|
||||
|
||||
const components = {
|
||||
nav: initNav,
|
||||
reveal: initReveal,
|
||||
timecode: initTimecode,
|
||||
};
|
||||
|
||||
function init(root = document) {
|
||||
root.querySelectorAll("[data-component]").forEach((el) => {
|
||||
if (el.dataset.componentReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fn = components[el.dataset.component];
|
||||
|
||||
if (fn) {
|
||||
fn(el);
|
||||
el.dataset.componentReady = "true";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", start);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
|
||||
function start() {
|
||||
init();
|
||||
// the admin UI swaps element HTML in place after edits
|
||||
new MutationObserver(() => init()).observe(document.body, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user