Merge pull request #14857 from Snuffleupagus/rm-webViewerOpenFileViaURL

Inline the `webViewerOpenFileViaURL` function in  `webViewerInitialized`
This commit is contained in:
Tim van der Meij 2022-04-30 12:21:25 +02:00 committed by GitHub
commit 75ac897284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2229,15 +2229,6 @@ function webViewerInitialized() {
);
try {
webViewerOpenFileViaURL(file);
} catch (reason) {
PDFViewerApplication.l10n.get("loading_error").then(msg => {
PDFViewerApplication._documentError(msg, reason);
});
}
}
function webViewerOpenFileViaURL(file) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (file) {
PDFViewerApplication.open(file);
@ -2248,11 +2239,12 @@ function webViewerOpenFileViaURL(file) {
PDFViewerApplication.setTitleUsingUrl(file, /* downloadUrl = */ file);
PDFViewerApplication.initPassiveLoading();
} else {
if (file) {
throw new Error("Not implemented: webViewerOpenFileViaURL");
} else {
PDFViewerApplication._hideViewBookmark();
throw new Error("Not implemented: webViewerInitialized");
}
} catch (reason) {
PDFViewerApplication.l10n.get("loading_error").then(msg => {
PDFViewerApplication._documentError(msg, reason);
});
}
}
@ -2432,9 +2424,9 @@ function webViewerHashchange(evt) {
}
}
let webViewerFileInputChange, webViewerOpenFile;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
webViewerFileInputChange = function (evt) {
// eslint-disable-next-line no-var
var webViewerFileInputChange = function (evt) {
if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
return; // Opening a new PDF file isn't supported in Presentation Mode.
}
@ -2447,7 +2439,8 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
PDFViewerApplication.open(url);
};
webViewerOpenFile = function (evt) {
// eslint-disable-next-line no-var
var webViewerOpenFile = function (evt) {
const fileInput = PDFViewerApplication.appConfig.openFileInput;
fileInput.click();
};