Replaced more knockoutjs hasfocus for autofocus=""

This commit is contained in:
djmaze 2020-08-22 09:35:03 +02:00
parent e4ddef97d6
commit dc3b76f53a
4 changed files with 15 additions and 41 deletions

View file

@ -31,8 +31,6 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
this.encrypt = ko.observable(false); this.encrypt = ko.observable(false);
this.password = ko.observable(''); this.password = ko.observable('');
this.password.focus = ko.observable(false);
this.buttonFocus = ko.observable(false);
this.text = ko.observable(''); this.text = ko.observable('');
this.selectedPrivateKey = ko.observable(null); this.selectedPrivateKey = ko.observable(null);
@ -296,8 +294,6 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
this.encrypt(false); this.encrypt(false);
this.password(''); this.password('');
this.password.focus(false);
this.buttonFocus(false);
this.signKey(null); this.signKey(null);
this.encryptKeys([]); this.encryptKeys([]);
@ -308,15 +304,11 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
onBuild() { onBuild() {
key('tab,shift+tab', KeyState.PopupComposeOpenPGP, () => { key('tab,shift+tab', KeyState.PopupComposeOpenPGP, () => {
switch (true) { let btn = this.querySelector('.inputPassword');
case this.password.focus(): if (btn.matches(':focus')) {
this.buttonFocus(true); btn = this.querySelector('.buttonDo');
break;
case this.buttonFocus():
this.password.focus(true);
break;
// no default
} }
btn.focus();
return false; return false;
}); });
} }
@ -326,11 +318,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
} }
onShowWithDelay() { onShowWithDelay() {
if (this.sign()) { this.querySelector(this.sign() ? '.inputPassword' : '.buttonDo').focus();
this.password.focus(true);
} else {
this.buttonFocus(true);
}
} }
onShow(fCallback, sText, identity, sTo, sCc, sBcc) { onShow(fCallback, sText, identity, sTo, sCc, sBcc) {

View file

@ -20,8 +20,6 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
this.privateKeys = ko.observableArray([]); this.privateKeys = ko.observableArray([]);
this.password = ko.observable(''); this.password = ko.observable('');
this.password.focus = ko.observable(false);
this.buttonFocus = ko.observable(false);
this.resultCallback = null; this.resultCallback = null;
@ -72,8 +70,6 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
this.notification(''); this.notification('');
this.password(''); this.password('');
this.password.focus(false);
this.buttonFocus(false);
this.selectedKey(false); this.selectedKey(false);
this.submitRequest(false); this.submitRequest(false);
@ -84,16 +80,11 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
onBuild(oDom) { onBuild(oDom) {
key('tab,shift+tab', KeyState.PopupMessageOpenPGP, () => { key('tab,shift+tab', KeyState.PopupMessageOpenPGP, () => {
switch (true) { let btn = this.querySelector('.inputPassword');
case this.password.focus(): if (btn.matches(':focus')) {
this.buttonFocus(true); btn = this.querySelector('.buttonDo');
break;
case this.buttonFocus():
this.password.focus(true);
break;
// no default
} }
btn.focus();
return false; return false;
}); });
@ -114,7 +105,7 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
self.selectedKey(ko.dataFor(this)); // eslint-disable-line no-invalid-this self.selectedKey(ko.dataFor(this)); // eslint-disable-line no-invalid-this
self.password.focus(true); // this.querySelector('.inputPassword').focus();
}); });
} }
@ -122,11 +113,6 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
this.clearPopup(); this.clearPopup();
} }
onShowWithDelay() {
this.password.focus(true);
// this.buttonFocus(true);
}
onShow(fCallback, privateKeys) { onShow(fCallback, privateKeys) {
this.clearPopup(); this.clearPopup();

View file

@ -87,7 +87,7 @@
<input type="password" class="inputPassword input-block-level i18n" <input type="password" class="inputPassword input-block-level i18n"
autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false" autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false"
data-i18n="[placeholder]POPUPS_COMPOSE_OPEN_PGP/LABEL_PASSWORD" data-i18n="[placeholder]POPUPS_COMPOSE_OPEN_PGP/LABEL_PASSWORD"
data-bind="textInput: password, hasfocus: password.focus, onEnter: doCommand" /> data-bind="textInput: password, onEnter: doCommand" />
<div class="form-inline" data-bind="visible: 0 < privateKeysOptions().length"> <div class="form-inline" data-bind="visible: 0 < privateKeysOptions().length">
<select class="input-block-level" data-bind="options: privateKeysOptions, value: selectedPrivateKey, <select class="input-block-level" data-bind="options: privateKeysOptions, value: selectedPrivateKey,
optionsCaption: privateKeysOptionsCaption, optionsText: 'name', optionsValue: 'id', optionsCaption: privateKeysOptionsCaption, optionsText: 'name', optionsValue: 'id',
@ -105,7 +105,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn buttonDo" data-bind="command: doCommand, hasfocus: buttonFocus, <button class="btn buttonDo" data-bind="command: doCommand,
enable: (sign() || encrypt()) && (!encrypt() || encrypt() && encryptKeys().length > 0)"> enable: (sign() || encrypt()) && (!encrypt() || encrypt() && encryptKeys().length > 0)">
<i data-bind="css: {'icon-key': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i> <i data-bind="css: {'icon-key': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp; &nbsp;&nbsp;

View file

@ -35,14 +35,14 @@
<div class="control-group"> <div class="control-group">
<label class="i18n control-label" data-i18n="POPUPS_MESSAGE_OPEN_PGP/LABEL_PASSWORD"></label> <label class="i18n control-label" data-i18n="POPUPS_MESSAGE_OPEN_PGP/LABEL_PASSWORD"></label>
<div class="controls"> <div class="controls">
<input type="password" class="inputPassword input-xlarge" autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false" <input type="password" class="inputPassword input-xlarge" autofocus="" autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: password, hasfocus: password.focus, onEnter: doCommand" /> data-bind="textInput: password, onEnter: doCommand" />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn buttonDo" data-bind="command: doCommand, hasfocus: buttonFocus"> <button class="btn buttonDo" data-bind="command: doCommand">
<i data-bind="css: {'icon-key': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i> <i data-bind="css: {'icon-key': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp; &nbsp;&nbsp;
<span class="i18n" data-i18n="POPUPS_MESSAGE_OPEN_PGP/BUTTON_DECRYPT"></span> <span class="i18n" data-i18n="POPUPS_MESSAGE_OPEN_PGP/BUTTON_DECRYPT"></span>