MAPG-156 adapt account's JS to the new helper functions
This commit is contained in:
parent
87c4c06aa6
commit
910fdddf34
@ -1,48 +1,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var form = document.getElementById('accountForm');
|
var form = document.getElementById('accountForm');
|
||||||
|
|
||||||
form.elements.password_new.onkeyup = function () {
|
MapGuesser.toggleFormSubmitButtonDisableOnChange(form, ['password_new', 'password_new_confirm'])
|
||||||
MapGuesser.toggleDisableOnChange(this, form.elements.save);
|
|
||||||
};
|
|
||||||
|
|
||||||
form.elements.password_new_confirm.onkeyup = function () {
|
MapGuesser.setOnsubmitForForm(form);
|
||||||
MapGuesser.toggleDisableOnChange(this, form.elements.save);
|
|
||||||
};
|
|
||||||
|
|
||||||
form.onsubmit = function (e) {
|
|
||||||
document.getElementById('loading').style.visibility = 'visible';
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var formData = new FormData(form);
|
|
||||||
|
|
||||||
MapGuesser.httpRequest('POST', form.action, function () {
|
|
||||||
document.getElementById('loading').style.visibility = 'hidden';
|
|
||||||
|
|
||||||
if (this.response.error) {
|
|
||||||
var errorText;
|
|
||||||
switch (this.response.error) {
|
|
||||||
case 'password_not_match':
|
|
||||||
errorText = 'The given current password is wrong.'
|
|
||||||
break;
|
|
||||||
case 'password_too_short':
|
|
||||||
errorText = 'The given new password is too short. Please choose a password that is at least 6 characters long!'
|
|
||||||
break;
|
|
||||||
case 'passwords_not_match':
|
|
||||||
errorText = 'The given new passwords do not match.'
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var accountFormError = document.getElementById('accountFormError');
|
|
||||||
accountFormError.style.display = 'block';
|
|
||||||
accountFormError.innerHTML = errorText;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('accountFormError').style.display = 'none';
|
|
||||||
form.reset();
|
|
||||||
form.elements.save.disabled = true;
|
|
||||||
}, formData);
|
|
||||||
};
|
|
||||||
})();
|
})();
|
||||||
|
@ -16,7 +16,7 @@ $jsFiles = [
|
|||||||
<input class="big fullWidth marginTop" type="password" name="password_new_confirm" placeholder="New password confirmation" minlength="6">
|
<input class="big fullWidth marginTop" type="password" name="password_new_confirm" placeholder="New password confirmation" minlength="6">
|
||||||
<p id="accountFormError" class="formError justify marginTop"></p>
|
<p id="accountFormError" class="formError justify marginTop"></p>
|
||||||
<div class="right marginTop">
|
<div class="right marginTop">
|
||||||
<button type="submit" name="save" disabled>Save</button>
|
<button type="submit" name="submit" disabled>Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user