1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(function () {
document.querySelectorAll("[data-password-toggle]").forEach(function (button) {
var id = button.getAttribute("data-password-toggle");
var input = id ? document.getElementById(id) : null;
if (!input) return;
var showIcon = button.querySelector(".icon-toggle-show");
var hideIcon = button.querySelector(".icon-toggle-hide");
button.addEventListener("click", function () {
var visible = input.type === "text";
input.type = visible ? "password" : "text";
var label = visible ? "Show password" : "Hide password";
button.setAttribute("aria-pressed", visible ? "false" : "true");
button.setAttribute("aria-label", label);
button.setAttribute("title", label);
if (showIcon) showIcon.classList.toggle("d-none", !visible);
if (hideIcon) hideIcon.classList.toggle("d-none", visible);
});
});
})();