mirror of https://github.com/Siphonay/mastodon
Add client-side timeout on resend confirmation button (#26300)
This commit is contained in:
parent
425d77f812
commit
2f932cb2bb
|
@ -13,4 +13,30 @@ ready(() => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
document.querySelectorAll('.timer-button').forEach(button => {
|
||||||
|
let counter = 30;
|
||||||
|
|
||||||
|
const container = document.createElement('span');
|
||||||
|
|
||||||
|
const updateCounter = () => {
|
||||||
|
container.innerText = ` (${counter})`;
|
||||||
|
};
|
||||||
|
|
||||||
|
updateCounter();
|
||||||
|
|
||||||
|
const countdown = setInterval(() => {
|
||||||
|
counter--;
|
||||||
|
|
||||||
|
if (counter === 0) {
|
||||||
|
button.disabled = false;
|
||||||
|
button.removeChild(container);
|
||||||
|
clearInterval(countdown);
|
||||||
|
} else {
|
||||||
|
updateCounter();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
button.appendChild(container);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
= f.input :email, required: true, hint: false, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' }
|
= f.input :email, required: true, hint: false, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' }
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.submit t('auth.resend_confirmation'), class: 'button'
|
= f.button :button, t('auth.resend_confirmation'), type: :submit, class: 'button timer-button', disabled: true
|
||||||
|
|
||||||
.form-footer= render 'auth/shared/links'
|
.form-footer= render 'auth/shared/links'
|
||||||
|
|
Loading…
Reference in New Issue