From 0d0cabb75da58b25999096954f66aea636bf7c3d Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 3 Jan 2025 23:12:19 -0800 Subject: [PATCH] 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. --- pkg/config/enum.go | 6 ++++++ web/templates/photo/gallery.html | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/config/enum.go b/pkg/config/enum.go index 10e0031..2c7eff4 100644 --- a/pkg/config/enum.go +++ b/pkg/config/enum.go @@ -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.", + }, } ) diff --git a/web/templates/photo/gallery.html b/web/templates/photo/gallery.html index 7ec77e7..51c0c3a 100644 --- a/web/templates/photo/gallery.html +++ b/web/templates/photo/gallery.html @@ -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); + } + } + }); });