Use jQuery.submit to bind form to login

This commit is contained in:
Antonin Delpeuch 2019-12-22 23:40:57 +01:00
parent c392126308
commit 8ceaeb0743
2 changed files with 8 additions and 25 deletions

View File

@ -25,11 +25,11 @@
<td><label for="remember-credentials" bind="rememberCredentialsLabel"></label></td>
</tr>
</table>
</form>
<div class="wikibase-login-buttons">
<div class="wikibase-login-buttons">
<button class="button cancel-button" bind="cancelButton1"></button>
<button class="button button-primary" bind="loginButton"></button>
</div>
<button class="button button-primary" type="submit" bind="loginButton"></button>
</div>
</form>
</div>
<div class="wikibase-user-logout" bind="logoutArea">
<p><span bind="loggedInAs"></span>

View File

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