Skip to content

Commit

Permalink
Fix to solve issue of leaving page during upload of images
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn-vanDijk committed Mar 26, 2024
1 parent 57eca32 commit fbf1396
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions module/Photo/view/photo/album-admin/add.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ $this->breadcrumbs()
document.addEventListener("DOMContentLoaded", function() {
Dropzone.options.imageDropzone = {
acceptedFiles: 'image/*',
init: function () {
let uploading = false;

window.addEventListener("beforeunload", function (e) {
if (uploading) {
// Most modern browsers no longer support setting custom dialog messages
// for this dialog, but for backwards compatibility this could be nice.
const warning = "You are currently uploading files, are you sure you want to leave?";
e.returnValue = warning;
return warning;
}
});

this.on("addedfile", function (file) {
uploading = true
})

this.on("queuecomplete", function (file) {
uploading = false
});
}
};
Dropzone.discover();
});
Expand Down

0 comments on commit fbf1396

Please sign in to comment.