Merge pull request #11706 from Snuffleupagus/mv-webViewerOpenFile

Move the `webViewerOpenFile` function, and the "openfile" eventBus listener, since they only matter in GENERIC builds of the default viewer
This commit is contained in:
Tim van der Meij 2020-03-17 22:38:11 +01:00 committed by GitHub
commit c3f4690bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1620,7 +1620,6 @@ const PDFViewerApplication = {
eventBus._on("namedaction", webViewerNamedAction); eventBus._on("namedaction", webViewerNamedAction);
eventBus._on("presentationmodechanged", webViewerPresentationModeChanged); eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
eventBus._on("presentationmode", webViewerPresentationMode); eventBus._on("presentationmode", webViewerPresentationMode);
eventBus._on("openfile", webViewerOpenFile);
eventBus._on("print", webViewerPrint); eventBus._on("print", webViewerPrint);
eventBus._on("download", webViewerDownload); eventBus._on("download", webViewerDownload);
eventBus._on("firstpage", webViewerFirstPage); eventBus._on("firstpage", webViewerFirstPage);
@ -1645,6 +1644,7 @@ const PDFViewerApplication = {
eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState); eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
eventBus._on("fileinputchange", webViewerFileInputChange); eventBus._on("fileinputchange", webViewerFileInputChange);
eventBus._on("openfile", webViewerOpenFile);
} }
}, },
@ -1694,7 +1694,6 @@ const PDFViewerApplication = {
eventBus._off("namedaction", webViewerNamedAction); eventBus._off("namedaction", webViewerNamedAction);
eventBus._off("presentationmodechanged", webViewerPresentationModeChanged); eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
eventBus._off("presentationmode", webViewerPresentationMode); eventBus._off("presentationmode", webViewerPresentationMode);
eventBus._off("openfile", webViewerOpenFile);
eventBus._off("print", webViewerPrint); eventBus._off("print", webViewerPrint);
eventBus._off("download", webViewerDownload); eventBus._off("download", webViewerDownload);
eventBus._off("firstpage", webViewerFirstPage); eventBus._off("firstpage", webViewerFirstPage);
@ -1719,6 +1718,7 @@ const PDFViewerApplication = {
eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState); eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
eventBus._off("fileinputchange", webViewerFileInputChange); eventBus._off("fileinputchange", webViewerFileInputChange);
eventBus._off("openfile", webViewerOpenFile);
} }
_boundEvents.beforePrint = null; _boundEvents.beforePrint = null;
@ -2157,7 +2157,7 @@ function webViewerHashchange(evt) {
} }
} }
let webViewerFileInputChange; let webViewerFileInputChange, webViewerOpenFile;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
webViewerFileInputChange = function(evt) { webViewerFileInputChange = function(evt) {
if ( if (
@ -2195,17 +2195,16 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
appConfig.toolbar.download.setAttribute("hidden", "true"); appConfig.toolbar.download.setAttribute("hidden", "true");
appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true"); appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
}; };
webViewerOpenFile = function(evt) {
const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
document.getElementById(openFileInputName).click();
};
} }
function webViewerPresentationMode() { function webViewerPresentationMode() {
PDFViewerApplication.requestPresentationMode(); PDFViewerApplication.requestPresentationMode();
} }
function webViewerOpenFile() {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
document.getElementById(openFileInputName).click();
}
}
function webViewerPrint() { function webViewerPrint() {
window.print(); window.print();
} }