Improve frontend accessibility
This commit is contained in:
1 parent
de1d3d2d63
commit
af7271e2f8
25 files changed
+478
-225
No files matched your search
@@ -13,8 +13,12 @@ async function redirectIfAlreadySignedIn() {
|
||||
|
||||
function togglePassword() {
|
||||
const passwordInput = document.getElementById('password');
|
||||
const togglePasswordButton = document.getElementById('togglePassword');
|
||||
const newInputType = passwordInput.type === 'password' ? 'text' : 'password';
|
||||
passwordInput.type = newInputType;
|
||||
const isVisible = newInputType === 'text';
|
||||
togglePasswordButton.textContent = isVisible ? 'Hide' : 'Show';
|
||||
togglePasswordButton.setAttribute('aria-pressed', String(isVisible));
|
||||
}
|
||||
|
||||
async function submitLoginForm(){
|
||||
|
||||
@@ -90,7 +90,7 @@ export async function postFormAndRenderAsync(
|
||||
}
|
||||
|
||||
const genericFormErrorTemplate = new Template(`
|
||||
<div class="form-error">
|
||||
<div class="form-error" role="alert" aria-live="assertive">
|
||||
{{ $this }}
|
||||
</div>
|
||||
`);
|
||||
@@ -109,7 +109,7 @@ function handleGenericFormError(response, responseText, form) {
|
||||
}
|
||||
|
||||
const validationErrorTemplate = new Template(`
|
||||
<div class="form-error">
|
||||
<div class="form-error" role="alert" aria-live="assertive">
|
||||
<ul>
|
||||
@for(error of $this) {
|
||||
<li class="error">{{error}}</li>
|
||||
@@ -119,7 +119,7 @@ const validationErrorTemplate = new Template(`
|
||||
`);
|
||||
|
||||
const unknownInputErrorTemplate = new Template(`
|
||||
<div class="form-error">
|
||||
<div class="form-error" role="alert" aria-live="assertive">
|
||||
<p>An error occurred with the following fields:</p>
|
||||
@for(field, errors of Object.entries($this)) {
|
||||
<ul>
|
||||
|
||||
@@ -5,8 +5,20 @@ async function signupAsync(params) {
|
||||
await sendFormAsync(form);
|
||||
}
|
||||
|
||||
function togglePassword() {
|
||||
const passwordInput = document.getElementById('password');
|
||||
const togglePasswordButton = document.getElementById('togglePassword');
|
||||
const newInputType = passwordInput.type === 'password' ? 'text' : 'password';
|
||||
passwordInput.type = newInputType;
|
||||
const isVisible = newInputType === 'text';
|
||||
togglePasswordButton.textContent = isVisible ? 'Hide' : 'Show';
|
||||
togglePasswordButton.setAttribute('aria-pressed', String(isVisible));
|
||||
}
|
||||
|
||||
document.getElementById('togglePassword')?.addEventListener('click', togglePassword);
|
||||
|
||||
const signupForm = document.getElementById('signupForm');
|
||||
signupForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
await signupAsync();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user