mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
Modal to inform that changes will be lost if the page is reloaded or closed
This commit is contained in:
parent
06bac144dd
commit
c375b43b14
@ -17,6 +17,7 @@ var menuOffcanvas = null;
|
||||
var currentCursor = null;
|
||||
var signaturePad = null;
|
||||
var nblayers = null;
|
||||
var hasModifications = false;
|
||||
|
||||
var loadPDF = async function(pdfBlob, filename) {
|
||||
const pdfjsLib = window['pdfjs-dist/build/pdf'];
|
||||
@ -501,6 +502,9 @@ var createAndAddSvgInCanvas = function(canvas, item, x, y, height = null) {
|
||||
if(document.getElementById('save')) {
|
||||
document.getElementById('save').removeAttribute('disabled');
|
||||
}
|
||||
|
||||
hasModifications = true;
|
||||
|
||||
if(document.getElementById('save_mobile')) {
|
||||
document.getElementById('save_mobile').removeAttribute('disabled');
|
||||
}
|
||||
@ -789,6 +793,7 @@ var createEventsListener = function() {
|
||||
}));
|
||||
})
|
||||
document.getElementById('input_svg').files = dataTransfer.files;
|
||||
hasModifications = false;
|
||||
});
|
||||
}
|
||||
|
||||
@ -803,6 +808,7 @@ var createEventsListener = function() {
|
||||
})
|
||||
}
|
||||
document.getElementById('input_svg_share').files = dataTransfer.files;
|
||||
hasModifications = false;
|
||||
});
|
||||
}
|
||||
|
||||
@ -921,6 +927,15 @@ var createEventsListener = function() {
|
||||
zoomChange(1)
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', function(event) {
|
||||
if(!hasModifications) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
return true;
|
||||
});
|
||||
|
||||
if(hash) {
|
||||
updateNbLayers();
|
||||
setInterval(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user