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:
Tim van der Meij 2016-04-18 23:59:46 +02:00
parent a093d755b7
commit 2b7137ba0a
2 changed files with 82 additions and 63 deletions

View file

@ -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) {