From 9e24ea9c6f6833365b9d642071f6b396095af36a Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 30 Jul 2023 10:22:33 +0300 Subject: [PATCH] restore #modal --- files/assets/js/core.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index c5eba232f9..f2a40a0397 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -584,6 +584,26 @@ function handleUploadProgress(e, upload_prog) { } } + +if (screen_width <= 768) { + document.addEventListener('shown.bs.modal', () => { + location.hash = "modal"; + }); + + document.addEventListener('hidden.bs.modal', () => { + if(location.hash == "#modal") { + history.back(); + } + }); + + window.addEventListener('hashchange', () => { + if(location.hash != "#modal") { + const curr_modal = bootstrap.Modal.getInstance(document.getElementsByClassName('show')[0]) + if (curr_modal) curr_modal.hide() + } + }); +} + document.querySelectorAll('form').forEach(form => { form.addEventListener('submit', (e) => { if (form.classList.contains('is-submitting')) {