Files
desktop/CopyToKeycloak/theme/kusche-desktop/login/resources/js/passwordVisibility.js
Lars Gebhardt-Kusche 84a367bdc9
All checks were successful
Deploy / deploy-staging (push) Successful in 23s
Deploy / deploy-production (push) Has been skipped
adasd
2026-06-15 23:38:30 +02:00

27 lines
1020 B
JavaScript

(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);
});
});
}());