|
@@ -280,21 +280,38 @@ export default class InviteDialogView {
|
280
|
280
|
* used in dialog
|
281
|
281
|
*/
|
282
|
282
|
registerListeners() {
|
283
|
|
- let $passInput = $('#newPasswordInput');
|
284
|
|
- let $addPassBtn = $('#addPasswordBtn');
|
285
|
|
-
|
286
|
|
- $(document).on('click', '.copyInviteLink', this.copyToClipboard);
|
287
|
|
- $addPassBtn.on('click', () => {
|
288
|
|
- let newPass = $passInput.val();
|
289
|
|
-
|
290
|
|
- if(newPass) {
|
291
|
|
- this.model.setRoomLocked(newPass);
|
292
|
|
- }
|
293
|
|
- });
|
294
|
|
- $('#inviteDialogRemovePassword').on('click', () => {
|
|
283
|
+ const ENTER_KEY = 13;
|
|
284
|
+ let addPasswordBtn = '#addPasswordBtn';
|
|
285
|
+ let copyInviteLink = '.copyInviteLink';
|
|
286
|
+ let newPasswordInput = '#newPasswordInput';
|
|
287
|
+ let removePassword = '#inviteDialogRemovePassword';
|
|
288
|
+
|
|
289
|
+ $(document).on('click', copyInviteLink, this.copyToClipboard);
|
|
290
|
+ $(removePassword).on('click', () => {
|
295
|
291
|
this.model.setRoomUnlocked();
|
296
|
292
|
});
|
297
|
|
- $passInput.keyup(this.disableAddPassIfInputEmpty.bind(this));
|
|
293
|
+ let boundSetPassword = this.setPassword.bind(this);
|
|
294
|
+ $(document).on('click', addPasswordBtn, boundSetPassword);
|
|
295
|
+ let boundDisablePass = this.disableAddPassIfInputEmpty.bind(this);
|
|
296
|
+ $(document).on('keypress', newPasswordInput, boundDisablePass);
|
|
297
|
+
|
|
298
|
+ // We need to handle keydown event because impromptu
|
|
299
|
+ // is listening to it too for closing the dialog
|
|
300
|
+ $(newPasswordInput).on('keydown', (e) => {
|
|
301
|
+ if (e.keyCode === ENTER_KEY) {
|
|
302
|
+ e.stopPropagation();
|
|
303
|
+ this.setPassword();
|
|
304
|
+ }
|
|
305
|
+ });
|
|
306
|
+ }
|
|
307
|
+
|
|
308
|
+ setPassword() {
|
|
309
|
+ let $passInput = $('#newPasswordInput');
|
|
310
|
+ let newPass = $passInput.val();
|
|
311
|
+
|
|
312
|
+ if(newPass) {
|
|
313
|
+ this.model.setRoomLocked(newPass);
|
|
314
|
+ }
|
298
|
315
|
}
|
299
|
316
|
|
300
|
317
|
/**
|