fix observeInput function
This commit is contained in:
parent
a1b0f5e9fb
commit
ea8b46ab91
@ -183,12 +183,23 @@ var MapGuesser = {
|
|||||||
document.getElementById('cover').style.visibility = 'hidden';
|
document.getElementById('cover').style.visibility = 'hidden';
|
||||||
},
|
},
|
||||||
|
|
||||||
observeInput: function (input, buttonToToggle) {
|
observeInput: function (form, observedInputs) {
|
||||||
if (input.defaultValue !== input.value) {
|
var anyChanged = false;
|
||||||
buttonToToggle.disabled = false;
|
|
||||||
} else {
|
for (var i = 0; i < observedInputs.length; i++) {
|
||||||
buttonToToggle.disabled = true;
|
var input = form.elements[observedInputs[i]];
|
||||||
|
if (input.type === 'checkbox') {
|
||||||
|
if (input.defaultChecked !== input.checked) {
|
||||||
|
anyChanged = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (input.defaultValue !== input.value) {
|
||||||
|
anyChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.elements['submit_button'].disabled = !anyChanged;
|
||||||
},
|
},
|
||||||
|
|
||||||
observeInputsInForm: function (form, observedInputs) {
|
observeInputsInForm: function (form, observedInputs) {
|
||||||
@ -199,19 +210,19 @@ var MapGuesser = {
|
|||||||
case 'INPUT':
|
case 'INPUT':
|
||||||
case 'TEXTAREA':
|
case 'TEXTAREA':
|
||||||
input.oninput = function () {
|
input.oninput = function () {
|
||||||
MapGuesser.observeInput(this, form.elements.submit);
|
MapGuesser.observeInput(form, observedInputs);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 'SELECT':
|
case 'SELECT':
|
||||||
input.onchange = function () {
|
input.onchange = function () {
|
||||||
MapGuesser.observeInput(this, form.elements.submit);
|
MapGuesser.observeInput(form, observedInputs);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
form.onreset = function () {
|
form.onreset = function () {
|
||||||
form.elements.submit.disabled = true;
|
form.elements['submit_button'].disabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" autocomplete="new-password" minlength="6">
|
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" autocomplete="new-password" 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="submit" disabled>Save</button>
|
<button type="submit" name="submit_button" disabled>Save</button>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p id="deleteAccountFormError" class="formError justify marginTop"></p>
|
<p id="deleteAccountFormError" class="formError justify marginTop"></p>
|
||||||
<div class="right marginTop">
|
<div class="right marginTop">
|
||||||
<button class="red marginRight" type="submit" name="submit">Delete account</button><!--
|
<button class="red marginRight" type="submit" name="submit_button">Delete account</button><!--
|
||||||
--><a class="button gray marginTop" href="/account" title="Back to account">Cancel</a>
|
--><a class="button gray marginTop" href="/account" title="Back to account">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user