Merge branch 'master' of https://github.com/Bhanu-mbvg/OpenRefine into Bhanu-mbvg-master

This commit is contained in:
Antonin Delpeuch 2019-12-22 21:57:00 +01:00
commit c392126308

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,8 +56,10 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
callback(null); callback(null);
}); });
elmts.loginButton.click(function() { var Login = (function() {
return function() {
frame.hide(); frame.hide();
isOpen = false;
Refine.postCSRF( Refine.postCSRF(
"command/wikidata/login", "command/wikidata/login",
elmts.loginForm.serialize(), elmts.loginForm.serialize(),
@ -63,11 +67,27 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
if (data.logged_in) { if (data.logged_in) {
dismiss(); dismiss();
callback(data.username); callback(data.username);
} else { }
else {
frame.show(); frame.show();
isOpen = true;
elmts.invalidCredentials.text("Invalid credentials."); elmts.invalidCredentials.text("Invalid credentials.");
} }
}); });
};
})();
elmts.loginButton.click(function() {
Login();
});
document.addEventListener('keydown', function(event) {
if(isOpen == true){
if (event.keyCode == 13) {
Login();
}
}
}); });
elmts.logoutButton.click(function() { elmts.logoutButton.click(function() {