mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #12241 from escapewindow/prevent-default
confirm if leaving a modified form without saving
This commit is contained in:
commit
10f61b8c96
4 changed files with 94 additions and 6 deletions
|
@ -127,6 +127,12 @@ function isSameScale(oldScale, newScale) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function beforeUnload(evt) {
|
||||
evt.preventDefault();
|
||||
evt.returnValue = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple viewer control to display PDF content/pages.
|
||||
* @implements {IRenderableView}
|
||||
|
@ -436,6 +442,12 @@ class BaseViewer {
|
|||
const firstPagePromise = pdfDocument.getPage(1);
|
||||
|
||||
const annotationStorage = pdfDocument.annotationStorage;
|
||||
annotationStorage.onSetModified = function () {
|
||||
window.addEventListener("beforeunload", beforeUnload);
|
||||
};
|
||||
annotationStorage.onResetModified = function () {
|
||||
window.removeEventListener("beforeunload", beforeUnload);
|
||||
};
|
||||
|
||||
this._pagesCapability.promise.then(() => {
|
||||
this.eventBus.dispatch("pagesloaded", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue