Escape key for gallery modal + Dark Video Detector chat rule

* In the Photo Gallery lightbox modal, the Escape key will now dismiss
  the modal.
* Add a chat rule 'nodvd' to exempt specific users from the dark video
  detector.
This commit is contained in:
Noah Petherbridge 2025-01-03 23:12:19 -08:00
parent ea1c4aab18
commit 0d0cabb75d
2 changed files with 19 additions and 2 deletions

View File

@ -237,6 +237,12 @@ var (
Label: "No image sharing privileges ('Shy Accounts')",
Help: "The user can not share or see any image shared on chat.",
},
{
Value: "nodvd",
Label: "[Support] Exempt this user from the dark video detector",
Help: "A special case if a user reaches out that the dark video detector on chat is misfiring for their camera. " +
"This will exempt the user from their camera being cut for being too dark.",
},
}
)

View File

@ -898,10 +898,12 @@
});
{{end}}
// Lightbox modal controls.
document.addEventListener("DOMContentLoaded", () => {
// Get our modal to trigger it on click of a detail img.
let $modal = document.querySelector("#detail-modal"),
$altText = $modal.getElementsByTagName("button")[0];
$altText = $modal.getElementsByTagName("button")[0],
cls = "is-active";
function setModalImage(url, altText) {
let $modalImg = document.querySelector("#detailImg"),
@ -964,7 +966,7 @@
node.addEventListener("click", (e) => {
e.preventDefault();
setModalImage(node.dataset.url, altText);
$modal.classList.add("is-active");
$modal.classList.add(cls);
// Log a view of this photo.
markImageViewed(photoID);
@ -976,6 +978,15 @@
markImageViewed(photoID);
});
});
// Key bindings to control the modal.
window.addEventListener('keydown', (e) => {
if ($modal.classList.contains(cls)) {
if (e.key == 'Escape') {
$modal.classList.remove(cls);
}
}
});
});
</script>