fix modal window not closing video

This commit is contained in:
Ryan
2025-03-16 13:46:50 -04:00
committed by GitHub
parent 4d0f423ca0
commit 2f88f943f0
2 changed files with 20 additions and 104 deletions

View File

@@ -310,6 +310,7 @@ export function renderFileTable(folder) {
updateFileActionButtons();
}
// Global function to show an image preview modal.
// Global function to show an image preview modal.
window.previewFile = function (fileUrl, fileName) {
let modal = document.getElementById("filePreviewModal");
@@ -337,16 +338,31 @@ window.previewFile = function (fileUrl, fileName) {
<div class="file-preview-container"></div>
</div>`;
document.body.appendChild(modal);
// Close event for the close button.
document.getElementById("closeFileModal").addEventListener("click", function () {
const video = modal.querySelector("video");
if (video) {
video.pause();
video.currentTime = 0;
}
modal.style.display = "none";
});
// Close event when clicking outside the modal content.
modal.addEventListener("click", function (e) {
if (e.target === modal) {
const video = modal.querySelector("video");
if (video) {
video.pause();
video.currentTime = 0;
}
modal.style.display = "none";
}
});
}
modal.querySelector("h4").textContent = "Preview: " + fileName;
modal.querySelector("h4").textContent = fileName;
const container = modal.querySelector(".file-preview-container");
container.innerHTML = ""; // Clear previous content