Skip to content

Commit c3f4690

Browse files
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
2 parents f9ce22c + 300a663 commit c3f4690

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

web/app.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,6 @@ const PDFViewerApplication = {
16201620
eventBus._on("namedaction", webViewerNamedAction);
16211621
eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
16221622
eventBus._on("presentationmode", webViewerPresentationMode);
1623-
eventBus._on("openfile", webViewerOpenFile);
16241623
eventBus._on("print", webViewerPrint);
16251624
eventBus._on("download", webViewerDownload);
16261625
eventBus._on("firstpage", webViewerFirstPage);
@@ -1645,6 +1644,7 @@ const PDFViewerApplication = {
16451644
eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
16461645
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
16471646
eventBus._on("fileinputchange", webViewerFileInputChange);
1647+
eventBus._on("openfile", webViewerOpenFile);
16481648
}
16491649
},
16501650

@@ -1694,7 +1694,6 @@ const PDFViewerApplication = {
16941694
eventBus._off("namedaction", webViewerNamedAction);
16951695
eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
16961696
eventBus._off("presentationmode", webViewerPresentationMode);
1697-
eventBus._off("openfile", webViewerOpenFile);
16981697
eventBus._off("print", webViewerPrint);
16991698
eventBus._off("download", webViewerDownload);
17001699
eventBus._off("firstpage", webViewerFirstPage);
@@ -1719,6 +1718,7 @@ const PDFViewerApplication = {
17191718
eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
17201719
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
17211720
eventBus._off("fileinputchange", webViewerFileInputChange);
1721+
eventBus._off("openfile", webViewerOpenFile);
17221722
}
17231723

17241724
_boundEvents.beforePrint = null;
@@ -2157,7 +2157,7 @@ function webViewerHashchange(evt) {
21572157
}
21582158
}
21592159

2160-
let webViewerFileInputChange;
2160+
let webViewerFileInputChange, webViewerOpenFile;
21612161
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
21622162
webViewerFileInputChange = function(evt) {
21632163
if (
@@ -2195,17 +2195,16 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
21952195
appConfig.toolbar.download.setAttribute("hidden", "true");
21962196
appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
21972197
};
2198+
2199+
webViewerOpenFile = function(evt) {
2200+
const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
2201+
document.getElementById(openFileInputName).click();
2202+
};
21982203
}
21992204

22002205
function webViewerPresentationMode() {
22012206
PDFViewerApplication.requestPresentationMode();
22022207
}
2203-
function webViewerOpenFile() {
2204-
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
2205-
const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
2206-
document.getElementById(openFileInputName).click();
2207-
}
2208-
}
22092208
function webViewerPrint() {
22102209
window.print();
22112210
}

0 commit comments

Comments
 (0)