Convert the password prompt to ES6 syntax
This commit is contained in:
parent
27c3c33eec
commit
e3796f6f41
@ -30,15 +30,11 @@ import { PasswordResponses } from './pdfjs';
|
||||
* entry.
|
||||
*/
|
||||
|
||||
class PasswordPrompt {
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
var PasswordPrompt = (function PasswordPromptClosure() {
|
||||
/**
|
||||
* @constructs PasswordPrompt
|
||||
* @param {PasswordPromptOptions} options
|
||||
*/
|
||||
function PasswordPrompt(options) {
|
||||
constructor(options) {
|
||||
this.overlayName = options.overlayName;
|
||||
this.container = options.container;
|
||||
this.label = options.label;
|
||||
@ -52,19 +48,18 @@ var PasswordPrompt = (function PasswordPromptClosure() {
|
||||
// Attach the event listeners.
|
||||
this.submitButton.addEventListener('click', this.verify.bind(this));
|
||||
this.cancelButton.addEventListener('click', this.close.bind(this));
|
||||
this.input.addEventListener('keydown', function (e) {
|
||||
this.input.addEventListener('keydown', (e) => {
|
||||
if (e.keyCode === 13) { // Enter key
|
||||
this.verify();
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
OverlayManager.register(this.overlayName, this.container,
|
||||
this.close.bind(this), true);
|
||||
}
|
||||
|
||||
PasswordPrompt.prototype = {
|
||||
open: function PasswordPrompt_open() {
|
||||
OverlayManager.open(this.overlayName).then(function () {
|
||||
open() {
|
||||
OverlayManager.open(this.overlayName).then(() => {
|
||||
this.input.type = 'password';
|
||||
this.input.focus();
|
||||
|
||||
@ -77,33 +72,29 @@ var PasswordPrompt = (function PasswordPromptClosure() {
|
||||
}
|
||||
|
||||
this.label.textContent = promptString;
|
||||
}.bind(this));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
close: function PasswordPrompt_close() {
|
||||
OverlayManager.close(this.overlayName).then(function () {
|
||||
close() {
|
||||
OverlayManager.close(this.overlayName).then(() => {
|
||||
this.input.value = '';
|
||||
this.input.type = '';
|
||||
}.bind(this));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
verify: function PasswordPrompt_verify() {
|
||||
verify() {
|
||||
var password = this.input.value;
|
||||
if (password && password.length > 0) {
|
||||
this.close();
|
||||
return this.updateCallback(password);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
setUpdateCallback:
|
||||
function PasswordPrompt_setUpdateCallback(updateCallback, reason) {
|
||||
setUpdateCallback(updateCallback, reason) {
|
||||
this.updateCallback = updateCallback;
|
||||
this.reason = reason;
|
||||
}
|
||||
};
|
||||
|
||||
return PasswordPrompt;
|
||||
})();
|
||||
}
|
||||
|
||||
export {
|
||||
PasswordPrompt,
|
||||
|
Loading…
Reference in New Issue
Block a user