feat: Allow back button to close files modal
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -544,7 +544,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const html = `
|
const html = `
|
||||||
<div class="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
|
<div id="gallery-modal" class="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
|
||||||
<div class="max-w-6xl w-full h-[90vh] rounded-2xl bg-white dark:bg-gray-900 border dark:border-gray-700 p-4 flex flex-col">
|
<div class="max-w-6xl w-full h-[90vh] rounded-2xl bg-white dark:bg-gray-900 border dark:border-gray-700 p-4 flex flex-col">
|
||||||
<div class="flex items-center justify-between mb-2">
|
<div class="flex items-center justify-between mb-2">
|
||||||
<div class="text-lg font-medium">Files</div>
|
<div class="text-lg font-medium">Files</div>
|
||||||
@@ -575,15 +575,32 @@
|
|||||||
const dlg = wrap.firstElementChild;
|
const dlg = wrap.firstElementChild;
|
||||||
document.body.appendChild(dlg);
|
document.body.appendChild(dlg);
|
||||||
|
|
||||||
const close = () => { try { dlg.remove(); } catch {} };
|
const close = () => {
|
||||||
|
if (location.hash === '#gallery') {
|
||||||
|
history.back();
|
||||||
|
} else {
|
||||||
|
try { dlg.remove(); } catch {}
|
||||||
|
}
|
||||||
|
};
|
||||||
dlg.onclick = (e) => { if (e.target === e.currentTarget) close(); };
|
dlg.onclick = (e) => { if (e.target === e.currentTarget) close(); };
|
||||||
dlg.querySelectorAll('.dlgClose').forEach(b => b.onclick = close);
|
dlg.querySelectorAll('.dlgClose').forEach(b => b.onclick = close);
|
||||||
|
|
||||||
|
if (location.hash !== '#gallery') {
|
||||||
|
history.pushState(null, '', '#gallery');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btnFilesRefresh.onclick = loadDirs;
|
btnFilesRefresh.onclick = loadDirs;
|
||||||
filesSearchQ.oninput = () => { clearTimeout(filesSearchQ._t); filesSearchQ._t = setTimeout(loadDirs, 300); };
|
filesSearchQ.oninput = () => { clearTimeout(filesSearchQ._t); filesSearchQ._t = setTimeout(loadDirs, 300); };
|
||||||
filesSortSel.onchange = loadDirs;
|
filesSortSel.onchange = loadDirs;
|
||||||
|
|
||||||
|
window.addEventListener('popstate', () => {
|
||||||
|
const galleryModal = document.querySelector('#gallery-modal');
|
||||||
|
if (galleryModal) {
|
||||||
|
galleryModal.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
loadDirs();
|
loadDirs();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user