adasd
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
(function () {
|
||||
const toggles = document.querySelectorAll('[data-password-toggle]');
|
||||
|
||||
toggles.forEach((toggle) => {
|
||||
if (!(toggle instanceof HTMLButtonElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const controlId = toggle.getAttribute('aria-controls');
|
||||
const input = controlId ? document.getElementById(controlId) : toggle.parentElement?.querySelector('input[type="password"], input[type="text"]');
|
||||
|
||||
if (!(input instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const showLabel = toggle.getAttribute('data-label-show') || 'Passwort anzeigen';
|
||||
const hideLabel = toggle.getAttribute('data-label-hide') || 'Passwort verbergen';
|
||||
|
||||
toggle.addEventListener('click', () => {
|
||||
const isHidden = input.type === 'password';
|
||||
input.type = isHidden ? 'text' : 'password';
|
||||
toggle.classList.toggle('is-visible', isHidden);
|
||||
toggle.setAttribute('aria-label', isHidden ? hideLabel : showLabel);
|
||||
});
|
||||
});
|
||||
}());
|
||||
Reference in New Issue
Block a user