#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.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
||||||
this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
|
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;
|
const pdfViewer = this.pdfViewer;
|
||||||
pdfViewer.setDocument(pdfDocument);
|
pdfViewer.setDocument(pdfDocument);
|
||||||
const { firstPagePromise, onePageRendered, pagesPromise } = pdfViewer;
|
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`.
|
* Converts API PageLayout values to the format used by `PDFViewer`.
|
||||||
* NOTE: This is supported to the extent that the viewer implements the
|
* NOTE: This is supported to the extent that the viewer implements the
|
||||||
|
@ -127,12 +127,6 @@ function isSameScale(oldScale, newScale) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeUnload(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
evt.returnValue = "";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple viewer control to display PDF content/pages.
|
* Simple viewer control to display PDF content/pages.
|
||||||
* @implements {IRenderableView}
|
* @implements {IRenderableView}
|
||||||
@ -442,12 +436,6 @@ class BaseViewer {
|
|||||||
const firstPagePromise = pdfDocument.getPage(1);
|
const firstPagePromise = pdfDocument.getPage(1);
|
||||||
|
|
||||||
const annotationStorage = pdfDocument.annotationStorage;
|
const annotationStorage = pdfDocument.annotationStorage;
|
||||||
annotationStorage.onSetModified = function () {
|
|
||||||
window.addEventListener("beforeunload", beforeUnload);
|
|
||||||
};
|
|
||||||
annotationStorage.onResetModified = function () {
|
|
||||||
window.removeEventListener("beforeunload", beforeUnload);
|
|
||||||
};
|
|
||||||
|
|
||||||
this._pagesCapability.promise.then(() => {
|
this._pagesCapability.promise.then(() => {
|
||||||
this.eventBus.dispatch("pagesloaded", {
|
this.eventBus.dispatch("pagesloaded", {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user