Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GENERIC viewer] Generate the fileInput DOM-element dynamically #17592

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,12 @@ const PDFViewerApplication = {
}

if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const fileInput = appConfig.openFileInput;
const fileInput = (this._openFileInput = document.createElement("input"));
fileInput.id = "fileInput";
fileInput.hidden = true;
fileInput.type = "file";
fileInput.value = null;
document.body.append(fileInput);

fileInput.addEventListener("change", function (evt) {
const { files } = evt.target;
Expand Down Expand Up @@ -2383,8 +2387,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {

// eslint-disable-next-line no-var
var webViewerOpenFile = function (evt) {
const fileInput = PDFViewerApplication.appConfig.openFileInput;
fileInput.click();
PDFViewerApplication._openFileInput?.click();
};
}

Expand Down
5 changes: 0 additions & 5 deletions web/viewer-geckoview.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,5 @@

</div> <!-- outerContainer -->
<div id="printContainer"></div>

<!--#if !MOZCENTRAL-->
<input type="file" id="fileInput" class="hidden">
<!--#endif-->

</body>
</html>
4 changes: 0 additions & 4 deletions web/viewer-geckoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ function getViewerConfiguration() {
cancelButton: document.getElementById("passwordCancel"),
},
printContainer: document.getElementById("printContainer"),
openFileInput:
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? document.getElementById("fileInput")
: null,
};
}

Expand Down
4 changes: 0 additions & 4 deletions web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,5 @@

</div> <!-- outerContainer -->
<div id="printContainer"></div>

<!--#if GENERIC-->
<input type="file" id="fileInput" class="hidden">
<!--#endif-->
</body>
</html>
4 changes: 0 additions & 4 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ function getViewerConfiguration() {
),
},
printContainer: document.getElementById("printContainer"),
openFileInput:
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? document.getElementById("fileInput")
: null,
debuggerScriptPath: "./debugger.mjs",
};
}
Expand Down