2022-12-07 21:26:37 -06:00
|
|
|
/**
|
|
|
|
* Floating window setup
|
|
|
|
*/
|
2022-12-07 16:22:25 -06:00
|
|
|
document.querySelectorAll(".floating-window").forEach(
|
|
|
|
/**
|
|
|
|
* Runs for each floating window
|
|
|
|
*
|
|
|
|
* @param {HTMLDivElement} w
|
|
|
|
*/
|
|
|
|
(w) => {
|
|
|
|
makeDraggable(w);
|
|
|
|
w.addEventListener(
|
|
|
|
"wheel",
|
|
|
|
(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
},
|
|
|
|
{passive: false}
|
|
|
|
);
|
|
|
|
|
|
|
|
w.addEventListener(
|
|
|
|
"click",
|
|
|
|
(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
},
|
|
|
|
{passive: false}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2022-12-02 22:13:13 -06:00
|
|
|
|
2022-12-07 21:26:37 -06:00
|
|
|
/**
|
|
|
|
* Collapsible element setup
|
|
|
|
*/
|
2022-12-02 22:13:13 -06:00
|
|
|
var coll = document.getElementsByClassName("collapsible");
|
|
|
|
for (var i = 0; i < coll.length; i++) {
|
|
|
|
let active = false;
|
|
|
|
coll[i].addEventListener("click", function () {
|
|
|
|
var content = this.nextElementSibling;
|
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
this.classList.add("active");
|
|
|
|
content.classList.add("active");
|
|
|
|
} else {
|
|
|
|
this.classList.remove("active");
|
|
|
|
content.classList.remove("active");
|
|
|
|
}
|
|
|
|
|
|
|
|
const observer = new ResizeObserver(() => {
|
|
|
|
if (active) content.style.maxHeight = content.scrollHeight + "px";
|
|
|
|
});
|
|
|
|
|
|
|
|
Array.from(content.children).forEach((child) => {
|
|
|
|
observer.observe(child);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (active) {
|
|
|
|
content.style.maxHeight = null;
|
|
|
|
active = false;
|
|
|
|
} else {
|
|
|
|
content.style.maxHeight = content.scrollHeight + "px";
|
|
|
|
active = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-12-07 21:26:37 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Settings overlay setup
|
|
|
|
*/
|
|
|
|
document.getElementById("settings-btn").addEventListener("click", () => {
|
|
|
|
document.getElementById("page-overlay-wrapper").classList.toggle("invisible");
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("settings-btn-close").addEventListener("click", () => {
|
|
|
|
document.getElementById("page-overlay-wrapper").classList.toggle("invisible");
|
|
|
|
});
|