From a64e986a6e995711e659929fad7fc76352199297 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 10 Mar 2023 23:54:58 +0200 Subject: [PATCH] restore the old behavior for modals --- files/assets/js/core.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 1fb6662c3..b60fddb11 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -598,8 +598,19 @@ function handleUploadProgress(e, upload_prog) { } } -if (width < 768) { - document.getElementById('expandImageModal').addEventListener('hidden.bs.modal', () => { - document.body.style.zoom = "100%"; - }); -} +window.addEventListener('show.bs.modal', function () { + location.hash = "modal"; +}); + +window.addEventListener('hide.bs.modal', function () { + if(location.hash == "#modal") { + history.back(); + } +}); + +window.addEventListener('hashchange', function () { + if(location.hash != "#modal") { + const curr_modal = bootstrap.Modal.getInstance(document.getElementsByClassName('show')[0]) + if (curr_modal) curr_modal.hide() + } +});