mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Convert the password prompt to a class
Furthermore we introduce two new methods named `setCallback` and `setReason` so external code does not change the properties of the class directly. Finally we update various names of properties and methods to be more self-explanatory.
This commit is contained in:
parent
a093d755b7
commit
2b7137ba0a
2 changed files with 82 additions and 63 deletions
18
web/app.js
18
web/app.js
|
@ -285,14 +285,13 @@ var PDFViewerApplication = {
|
|||
});
|
||||
}
|
||||
|
||||
PasswordPrompt.initialize({
|
||||
this.passwordPrompt = new PasswordPrompt({
|
||||
overlayName: 'passwordOverlay',
|
||||
passwordField: document.getElementById('password'),
|
||||
passwordText: document.getElementById('passwordText'),
|
||||
passwordSubmit: document.getElementById('passwordSubmit'),
|
||||
passwordCancel: document.getElementById('passwordCancel')
|
||||
label: document.getElementById('passwordText'),
|
||||
input: document.getElementById('password'),
|
||||
submitButton: document.getElementById('passwordSubmit'),
|
||||
cancelButton: document.getElementById('passwordCancel')
|
||||
});
|
||||
this.passwordPrompt = PasswordPrompt;
|
||||
|
||||
this.pdfOutlineViewer = new PDFOutlineViewer({
|
||||
container: document.getElementById('outlineView'),
|
||||
|
@ -687,10 +686,9 @@ var PDFViewerApplication = {
|
|||
var loadingTask = pdfjsLib.getDocument(parameters);
|
||||
this.pdfLoadingTask = loadingTask;
|
||||
|
||||
loadingTask.onPassword = function passwordNeeded(updatePassword, reason) {
|
||||
PasswordPrompt.updatePassword = updatePassword;
|
||||
PasswordPrompt.reason = reason;
|
||||
PasswordPrompt.open();
|
||||
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
|
||||
self.passwordPrompt.setUpdateCallback(updateCallback, reason);
|
||||
self.passwordPrompt.open();
|
||||
};
|
||||
|
||||
loadingTask.onProgress = function getDocumentProgress(progressData) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue