Show/Hide password icon
This commit is contained in:
parent
3624763073
commit
25e8b259f7
7 changed files with 40 additions and 1 deletions
|
@ -30,6 +30,12 @@ let BookWyrm = new (class {
|
|||
.querySelectorAll("[data-back]")
|
||||
.forEach((button) => button.addEventListener("click", this.back));
|
||||
|
||||
document
|
||||
.querySelectorAll("[data-password-icon]")
|
||||
.forEach((button) =>
|
||||
button.addEventListener("click", this.togglePasswordVisibility.bind(this))
|
||||
);
|
||||
|
||||
document
|
||||
.querySelectorAll('input[type="file"]')
|
||||
.forEach((node) => node.addEventListener("change", this.disableIfTooLarge.bind(this)));
|
||||
|
@ -820,4 +826,24 @@ let BookWyrm = new (class {
|
|||
|
||||
form.querySelector('input[name="preferred_timezone"]').value = tz;
|
||||
}
|
||||
|
||||
togglePasswordVisibility(event) {
|
||||
const iconElement = event.currentTarget.getElementsByTagName("button")[0];
|
||||
const passwordElementId = event.currentTarget.dataset.for;
|
||||
const passwordInputElement = document.getElementById(passwordElementId);
|
||||
|
||||
if (!passwordInputElement) return;
|
||||
|
||||
if (passwordInputElement.type === "password") {
|
||||
passwordInputElement.type = "text";
|
||||
this.addRemoveClass(iconElement, "icon-eye-blocked");
|
||||
this.addRemoveClass(iconElement, "icon-eye", true);
|
||||
} else {
|
||||
passwordInputElement.type = "password";
|
||||
this.addRemoveClass(iconElement, "icon-eye");
|
||||
this.addRemoveClass(iconElement, "icon-eye-blocked", true);
|
||||
}
|
||||
|
||||
this.toggleFocus(passwordElementId);
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue