Skip to content

Commit b493d23

Browse files
committed
Fix and harmonize JS
- run function is required by the base class - using the `live()` event shortcut as is used on rest of codebase
1 parent 39d4736 commit b493d23

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

src/adminui/templates/auth/login.html

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,25 @@
8686
{% endblock %}
8787

8888
{% block javascript %}
89-
<script>
90-
document.querySelectorAll('.password-toggle').forEach(button => {
91-
button.addEventListener('click', function () {
92-
// Find the input that lives in the same group as this button
93-
const input = this.parentElement.querySelector('.password-input');
94-
const iconShow = this.querySelector('.icon-show');
95-
const iconHide = this.querySelector('.icon-hide');
89+
<script type="text/javascript">
90+
function run() {
91+
live('.password-toggle', 'click', function (elem, event) {
92+
// Find the input that lives in the same group as this button
93+
const input = elem.parentElement.querySelector('.password-input');
94+
const iconShow = elem.querySelector('.icon-show');
95+
const iconHide = elem.querySelector('.icon-hide');
9696

97-
if (input.getAttribute('type') === 'password') {
98-
input.setAttribute('type', 'text');
99-
iconShow.style.display = 'none';
100-
iconHide.style.display = 'block';
101-
} else {
102-
input.setAttribute('type', 'password');
103-
iconShow.style.display = 'block';
104-
iconHide.style.display = 'none';
105-
}
106-
});
107-
});
97+
if (input.getAttribute('type') === 'password') {
98+
input.setAttribute('type', 'text');
99+
iconShow.style.display = 'none';
100+
iconHide.style.display = 'block';
101+
} else {
102+
input.setAttribute('type', 'password');
103+
iconShow.style.display = 'block';
104+
iconHide.style.display = 'none';
105+
}
106+
});
107+
}
108+
</script>
108109
</script>
109110
{% endblock %}

0 commit comments

Comments
 (0)