2022-11-22 16:24:55 -06:00
|
|
|
function makeDraggable(element) {
|
2022-11-21 05:24:35 -06:00
|
|
|
const startbb = element.getBoundingClientRect();
|
|
|
|
let dragging = false;
|
|
|
|
let offset = {x: 0, y: 0};
|
|
|
|
|
|
|
|
element.style.top = startbb.y + "px";
|
|
|
|
element.style.left = startbb.x + "px";
|
|
|
|
|
|
|
|
mouse.listen.window.left.onpaintstart.on((evn) => {
|
|
|
|
if (
|
|
|
|
element.contains(evn.target) &&
|
|
|
|
evn.target.classList.contains("draggable")
|
|
|
|
) {
|
|
|
|
const bb = element.getBoundingClientRect();
|
|
|
|
offset.x = evn.x - bb.x;
|
|
|
|
offset.y = evn.y - bb.y;
|
|
|
|
dragging = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mouse.listen.window.left.onpaint.on((evn) => {
|
|
|
|
if (dragging) {
|
|
|
|
element.style.top = evn.y - offset.y + "px";
|
|
|
|
element.style.left = evn.x - offset.x + "px";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mouse.listen.window.left.onpaintend.on((evn) => {
|
|
|
|
dragging = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-22 16:24:55 -06:00
|
|
|
document.querySelectorAll(".floating-window").forEach((w) => {
|
|
|
|
makeDraggable(w);
|
|
|
|
});
|
2022-11-21 05:24:35 -06:00
|
|
|
|
2022-11-19 15:48:12 -06:00
|
|
|
var coll = document.getElementsByClassName("collapsible");
|
|
|
|
for (var i = 0; i < coll.length; i++) {
|
2022-11-20 17:10:03 -06:00
|
|
|
coll[i].addEventListener("click", function () {
|
|
|
|
this.classList.toggle("active");
|
|
|
|
var content = this.nextElementSibling;
|
|
|
|
if (content.style.maxHeight) {
|
|
|
|
content.style.maxHeight = null;
|
|
|
|
} else {
|
|
|
|
content.style.maxHeight = content.scrollHeight + "px";
|
|
|
|
}
|
|
|
|
});
|
2022-11-20 15:39:24 -06:00
|
|
|
}
|