diff --git a/airlock/templates/file_browser/index.html b/airlock/templates/file_browser/index.html index 99abe8a8..ab118c22 100644 --- a/airlock/templates/file_browser/index.html +++ b/airlock/templates/file_browser/index.html @@ -39,4 +39,5 @@ {% django_htmx_script %} + {% vite_asset "assets/src/scripts/resizer.js" %} {% endblock %} diff --git a/assets/src/scripts/resizer.js b/assets/src/scripts/resizer.js new file mode 100644 index 00000000..1ea814c8 --- /dev/null +++ b/assets/src/scripts/resizer.js @@ -0,0 +1,40 @@ +function setBrowserHeight() { + const iframe = document.querySelector("iframe"); + if (iframe) { + const iframeTop = iframe.getBoundingClientRect()["top"]; + iframe.style.height = `${window.innerHeight - iframeTop}px`; + } + + const table = document.getElementById("selected-contents"); + if (table) { + const tableTop = table.getBoundingClientRect()["top"]; + table.style.height = `${window.innerHeight - tableTop}px`; + table.classList.add("overflow-auto"); + console.log({ table }); + } +} + +function setTreeHeight() { + const iframe = document.getElementById("tree-container"); + if (iframe) { + const iframeTop = iframe.getBoundingClientRect()["top"]; + iframe.style.height = `${window.innerHeight - iframeTop}px`; + } +} + +document.documentElement.classList.remove("min-h-screen"); +document.documentElement.classList.add("h-screen"); + +document.body.classList.remove("min-h-screen"); +document.body.classList.add("h-screen"); + +document.querySelector("main")?.classList.add("overflow-hidden"); + +new ResizeObserver(() => { + setBrowserHeight(); + setTreeHeight(); +}).observe(document.documentElement); + +document.body.addEventListener("htmx:afterSettle", () => { + return setBrowserHeight(); +}); diff --git a/vite.config.js b/vite.config.js index 96b2d6bb..ec1e4957 100644 --- a/vite.config.js +++ b/vite.config.js @@ -8,6 +8,7 @@ export default defineConfig({ rollupOptions: { input: { main: "assets/src/scripts/main.js", + resizer: "assets/src/scripts/resizer.js", }, }, },