Add possibilty to set password via return key

This commit is contained in:
Ilya Daynatovich 2016-10-17 15:51:55 +03:00
parent 367c9401eb
commit d94b50f1e4
1 changed files with 29 additions and 12 deletions

View File

@ -280,21 +280,38 @@ export default class InviteDialogView {
* used in dialog
*/
registerListeners() {
let $passInput = $('#newPasswordInput');
let $addPassBtn = $('#addPasswordBtn');
const ENTER_KEY = 13;
let addPasswordBtn = '#addPasswordBtn';
let copyInviteLink = '.copyInviteLink';
let newPasswordInput = '#newPasswordInput';
let removePassword = '#inviteDialogRemovePassword';
$(document).on('click', '.copyInviteLink', this.copyToClipboard);
$addPassBtn.on('click', () => {
$(document).on('click', copyInviteLink, this.copyToClipboard);
$(removePassword).on('click', () => {
this.model.setRoomUnlocked();
});
let boundSetPassword = this.setPassword.bind(this);
$(document).on('click', addPasswordBtn, boundSetPassword);
let boundDisablePass = this.disableAddPassIfInputEmpty.bind(this);
$(document).on('keypress', newPasswordInput, boundDisablePass);
// We need to handle keydown event because impromptu
// is listening to it too for closing the dialog
$(newPasswordInput).on('keydown', (e) => {
if (e.keyCode === ENTER_KEY) {
e.stopPropagation();
this.setPassword();
}
});
}
setPassword() {
let $passInput = $('#newPasswordInput');
let newPass = $passInput.val();
if(newPass) {
this.model.setRoomLocked(newPass);
}
});
$('#inviteDialogRemovePassword').on('click', () => {
this.model.setRoomUnlocked();
});
$passInput.keyup(this.disableAddPassIfInputEmpty.bind(this));
}
/**