mirror of
https://github.com/24eme/signaturepdf
synced 2024-06-03 06:22:13 +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 currentCursor = null;
|
||||||
var signaturePad = null;
|
var signaturePad = null;
|
||||||
var nblayers = null;
|
var nblayers = null;
|
||||||
|
var hasModifications = false;
|
||||||
|
|
||||||
var loadPDF = async function(pdfBlob, filename) {
|
var loadPDF = async function(pdfBlob, filename) {
|
||||||
const pdfjsLib = window['pdfjs-dist/build/pdf'];
|
const pdfjsLib = window['pdfjs-dist/build/pdf'];
|
||||||
|
@ -501,6 +502,9 @@ var createAndAddSvgInCanvas = function(canvas, item, x, y, height = null) {
|
||||||
if(document.getElementById('save')) {
|
if(document.getElementById('save')) {
|
||||||
document.getElementById('save').removeAttribute('disabled');
|
document.getElementById('save').removeAttribute('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasModifications = true;
|
||||||
|
|
||||||
if(document.getElementById('save_mobile')) {
|
if(document.getElementById('save_mobile')) {
|
||||||
document.getElementById('save_mobile').removeAttribute('disabled');
|
document.getElementById('save_mobile').removeAttribute('disabled');
|
||||||
}
|
}
|
||||||
|
@ -789,6 +793,7 @@ var createEventsListener = function() {
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
document.getElementById('input_svg').files = dataTransfer.files;
|
document.getElementById('input_svg').files = dataTransfer.files;
|
||||||
|
hasModifications = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,6 +808,7 @@ var createEventsListener = function() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
document.getElementById('input_svg_share').files = dataTransfer.files;
|
document.getElementById('input_svg_share').files = dataTransfer.files;
|
||||||
|
hasModifications = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,6 +927,15 @@ var createEventsListener = function() {
|
||||||
zoomChange(1)
|
zoomChange(1)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', function(event) {
|
||||||
|
if(!hasModifications) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
if(hash) {
|
if(hash) {
|
||||||
updateNbLayers();
|
updateNbLayers();
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
|
|
Loading…
Reference in a new issue