Enter key press issues resolved

This commit is contained in:
Bhanu Gupta 2019-12-22 19:56:39 +05:30
parent cfc962668c
commit acba3e59ae

View File

@ -17,6 +17,7 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
var self = this; var self = this;
var frame = $(DOM.loadHTML("wikidata", "scripts/dialogs/manage-account-dialog.html")); var frame = $(DOM.loadHTML("wikidata", "scripts/dialogs/manage-account-dialog.html"));
var elmts = this._elmts = DOM.bind(frame); var elmts = this._elmts = DOM.bind(frame);
var isOpen = true;
ManageAccountDialog.firstLaunch = false; ManageAccountDialog.firstLaunch = false;
this._elmts.dialogHeader.text($.i18n('wikidata-account/dialog-header')); this._elmts.dialogHeader.text($.i18n('wikidata-account/dialog-header'));
@ -37,6 +38,7 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
var dismiss = function() { var dismiss = function() {
DialogSystem.dismissUntil(self._level - 1); DialogSystem.dismissUntil(self._level - 1);
isOpen = false;
}; };
if (logged_in_username != null) { if (logged_in_username != null) {
@ -54,40 +56,39 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
callback(null); callback(null);
}); });
var Login = (function() {
return function() {
frame.hide();
Refine.postCSRF(
"command/wikidata/login",
elmts.loginForm.serialize(),
function(data) {
if (data.logged_in) {
dismiss();
callback(data.username);
}
else {
frame.show();
isOpen = true;
elmts.invalidCredentials.text("Invalid credentials.");
}
});
};
})();
elmts.loginButton.click(function() { elmts.loginButton.click(function() {
frame.hide(); Login();
Refine.postCSRF(
"command/wikidata/login",
elmts.loginForm.serialize(),
function(data) {
if (data.logged_in) {
dismiss();
callback(data.username);
} else {
frame.show();
elmts.invalidCredentials.text("Invalid credentials.");
}
});
}); });
document.addEventListener('keydown', function(event) { document.addEventListener('keydown', function(event) {
if (event.keyCode == 13) { if(isOpen == true){
frame.hide(); if (event.keyCode == 13) {
Refine.postCSRF( isOpen = false;
"command/wikidata/login", Login();
elmts.loginForm.serialize(),
function(data) {
if (data.logged_in) {
dismiss();
callback(data.username);
} else {
frame.show();
elmts.invalidCredentials.text("Invalid credentials.");
}
});
} }
}); }
});
elmts.logoutButton.click(function() { elmts.logoutButton.click(function() {
Refine.postCSRF( Refine.postCSRF(