#12241 followup - move event listener to PDFViewerApplication.load
This commit is contained in:
parent
0d5ef5dd0a
commit
b1423336c3
14
web/app.js
14
web/app.js
@ -1165,6 +1165,14 @@ const PDFViewerApplication = {
|
||||
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
||||
this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
|
||||
|
||||
const annotationStorage = pdfDocument.annotationStorage;
|
||||
annotationStorage.onSetModified = function () {
|
||||
window.addEventListener("beforeunload", beforeUnload);
|
||||
};
|
||||
annotationStorage.onResetModified = function () {
|
||||
window.removeEventListener("beforeunload", beforeUnload);
|
||||
};
|
||||
|
||||
const pdfViewer = this.pdfViewer;
|
||||
pdfViewer.setDocument(pdfDocument);
|
||||
const { firstPagePromise, onePageRendered, pagesPromise } = pdfViewer;
|
||||
@ -2951,6 +2959,12 @@ function webViewerKeyDown(evt) {
|
||||
}
|
||||
}
|
||||
|
||||
function beforeUnload(evt) {
|
||||
evt.preventDefault();
|
||||
evt.returnValue = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts API PageLayout values to the format used by `PDFViewer`.
|
||||
* NOTE: This is supported to the extent that the viewer implements the
|
||||
|
@ -127,12 +127,6 @@ 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}
|
||||
@ -442,12 +436,6 @@ 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…
Reference in New Issue
Block a user