forked from rDrama/rDrama
1
0
Fork 0

extend backbutton behavior to all modals

master
Aevann 2023-08-03 09:35:33 +03:00
parent 3358d833a9
commit 08f42ed354
1 changed files with 9 additions and 11 deletions

View File

@ -586,20 +586,18 @@ function handleUploadProgress(e, upload_prog) {
if (screen_width <= 768) {
if (expandImageModal) {
expandImageModal.addEventListener('shown.bs.modal', () => {
location.hash = "modal";
});
document.addEventListener('shown.bs.modal', (e) => {
location.hash = `m-${e.target.id}`;
});
expandImageModal.addEventListener('hidden.bs.modal', () => {
if(location.hash == "#modal") {
history.back();
}
});
}
document.addEventListener('hidden.bs.modal', (e) => {
if (location.hash == `#m-${e.target.id}`) {
history.back();
}
});
window.addEventListener('hashchange', () => {
if(location.hash != "#modal") {
if (!location.hash.startsWith("#m-")) {
const curr_modal = bootstrap.Modal.getInstance(document.getElementsByClassName('show')[0])
if (curr_modal) curr_modal.hide()
}