From 5c8791fdd892b52343f5ad47bc725e41d6229fe6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 12 Mar 2023 10:35:44 +0200 Subject: [PATCH] minor dedup --- files/assets/js/core.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 8c0eec46c..f8621221c 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -178,6 +178,8 @@ function formkey() { else return null; } +const expandImageModal = document.getElementById('expandImageModal') + function expandImage(url) { const e = this.event if(e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) @@ -191,7 +193,7 @@ function expandImage(url) { document.getElementById("desktop-expanded-image").src = url.replace("200w.webp", "giphy.webp"); document.getElementById("desktop-expanded-image-wrap-link").href = url.replace("200w.webp", "giphy.webp"); - bootstrap.Modal.getOrCreateInstance(document.getElementById('expandImageModal')).show(); + bootstrap.Modal.getOrCreateInstance(expandImageModal).show(); }; function bs_trigger(e) { @@ -586,13 +588,13 @@ function handleUploadProgress(e, upload_prog) { if (width <= 768) { - document.getElementById('expandImageModal').addEventListener('show.bs.modal', function () { + expandImageModal.addEventListener('show.bs.modal', function () { setTimeout(() => { location.hash = "modal"; }, 200); }); - document.getElementById('expandImageModal').addEventListener('hide.bs.modal', function () { + expandImageModal.addEventListener('hide.bs.modal', function () { if(location.hash == "#modal") { history.back(); }