Autofocus passcode field on window focus
This commit is contained in:
@@ -13,6 +13,19 @@ class LockScreen {
|
||||
|
||||
$scope.formData = {};
|
||||
|
||||
this.visibilityObserver = passcodeManager.addVisibilityObserver((visible) => {
|
||||
if(visible) {
|
||||
let input = document.getElementById("passcode-input");
|
||||
if(input) {
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$on("$destroy", () => {
|
||||
passcodeManager.removeVisibilityObserver(this.visibilityObserver);
|
||||
});
|
||||
|
||||
$scope.submitPasscodeForm = function() {
|
||||
if(!$scope.formData.passcode || $scope.formData.passcode.length == 0) {
|
||||
return;
|
||||
|
||||
@@ -11,6 +11,7 @@ class PasscodeManager {
|
||||
this._hasPasscode = this.storageManager.getItemSync("offlineParams", StorageManager.Fixed) != null;
|
||||
this._locked = this._hasPasscode;
|
||||
|
||||
this.visibilityObservers = [];
|
||||
this.passcodeChangeObservers = [];
|
||||
|
||||
this.configureAutoLock();
|
||||
@@ -37,6 +38,21 @@ class PasscodeManager {
|
||||
return this._keys;
|
||||
}
|
||||
|
||||
addVisibilityObserver(callback) {
|
||||
this.visibilityObservers.push(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
removeVisibilityObserver(callback) {
|
||||
_.pull(this.visibilityObservers, callback);
|
||||
}
|
||||
|
||||
notifiyVisibilityObservers(visible) {
|
||||
for(let callback of this.visibilityObservers) {
|
||||
callback(visible);
|
||||
}
|
||||
}
|
||||
|
||||
async setAutoLockInterval(interval) {
|
||||
return this.storageManager.setItem(PasscodeManager.AutoLockIntervalKey, JSON.stringify(interval), StorageManager.FixedEncrypted);
|
||||
}
|
||||
@@ -213,6 +229,8 @@ class PasscodeManager {
|
||||
} else {
|
||||
this.beginAutoLockTimer();
|
||||
}
|
||||
|
||||
this.notifiyVisibilityObservers(visible);
|
||||
}
|
||||
|
||||
async beginAutoLockTimer() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
.sk-panel-section
|
||||
%form.sk-panel-form.sk-panel-row{"ng-submit" => "submitPasscodeForm()"}
|
||||
.sk-panel-column.stretch
|
||||
%input.center-text.sk-input.contrast{:type => 'password',
|
||||
%input#passcode-input.center-text.sk-input.contrast{:type => 'password',
|
||||
"ng-model" => "formData.passcode", "autofocus" => "true", "sn-autofocus" => "true", "should-focus" => "true",
|
||||
"placeholder" => "Enter Passcode", "autocomplete" => "new-password"}
|
||||
.sk-button-group.stretch.sk-panel-row.form-submit
|
||||
|
||||
Reference in New Issue
Block a user