style: format static/login.ts
This commit is contained in:
@@ -1,15 +1,21 @@
|
|||||||
const initPasswordToggle = (): void => {
|
const initPasswordToggle = (): void => {
|
||||||
document.addEventListener("click", (event) => {
|
document.addEventListener("click", (event) => {
|
||||||
const target = event.target;
|
const { target } = event;
|
||||||
if (!(target instanceof Element)) return;
|
if (!(target instanceof Element)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const button = target.closest<HTMLButtonElement>("[data-toggle-password]");
|
const button = target.closest<HTMLButtonElement>("[data-toggle-password]");
|
||||||
if (!button) return;
|
if (!button) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const field = button.closest("form")?.querySelector<HTMLInputElement>("#password");
|
const field = button.closest("form")?.querySelector<HTMLInputElement>("#password");
|
||||||
const openEye = button.querySelector<SVGElement>("[data-eye-open]");
|
const openEye = button.querySelector<SVGElement>("[data-eye-open]");
|
||||||
const closedEye = button.querySelector<SVGElement>("[data-eye-closed]");
|
const closedEye = button.querySelector<SVGElement>("[data-eye-closed]");
|
||||||
if (!(field instanceof HTMLInputElement) || !openEye || !closedEye) return;
|
if (!(field instanceof HTMLInputElement) || !openEye || !closedEye) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const showPassword = field.type === "password";
|
const showPassword = field.type === "password";
|
||||||
field.type = showPassword ? "text" : "password";
|
field.type = showPassword ? "text" : "password";
|
||||||
|
|||||||
Reference in New Issue
Block a user