openOutpaint/js/initalize/ui.populate.js
Victor Seiji Hariki ec59cf5538 Very crude settings interface
Very crude settings interface with only canvas size for now. Canvas size
only affects canvas on next page load. Dynamic resizing in the horizon,
but will take a while.

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
2022-12-08 18:38:55 -03:00

74 lines
1.5 KiB
JavaScript

/**
* Floating window setup
*/
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}
);
}
);
/**
* Collapsible element setup
*/
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;
}
});
}
/**
* 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");
});