feat(share): allow viewing directories

This commit is contained in:
Elian Doran 2025-06-09 14:54:04 +03:00
parent 0b3846fc35
commit 091ffdeb59
No known key found for this signature in database

View File

@ -12,16 +12,21 @@
// } // }
export default function setupExpanders() { export default function setupExpanders() {
const expanders = Array.from(document.querySelectorAll("#menu .submenu-item")); const expanders = Array.from(document.querySelectorAll("#menu .submenu-item .collapse-button"));
for (const ex of expanders) { for (const expander of expanders) {
ex.addEventListener("click", e => { const li = expander.parentElement?.parentElement;
if ((e.target as Element).closest(".submenu-item,.item") !== ex) return; if (!li) {
continue;
}
expander.addEventListener("click", e => {
if ((e.target as Element).closest(".submenu-item,.item") !== li) return;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
const ul = ex.querySelector("ul")!; const ul = li.querySelector("ul")!;
ul.style.height = `${ul.scrollHeight}px`; ul.style.height = `${ul.scrollHeight}px`;
setTimeout(() => ex.classList.toggle("expanded"), 1); setTimeout(() => li.classList.toggle("expanded"), 1);
setTimeout(() => ul.style.height = ``, 200); setTimeout(() => ul.style.height = ``, 200);
}); });
} }
} }