forked from internetarchive/openlibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving to single password field for registration (internetarchive#7729)
* Use localized strings * Adjust margin for password inputs --------- Co-authored-by: James Champ <jameschamp@acm.org>
- Loading branch information
Showing
5 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Adds ability to toggle a password field's visibilty. | ||
* | ||
* @param {HTMLElement} elem Reference to affordance that toggles a password input's visibility | ||
*/ | ||
export function initPasswordToggling(elem) { | ||
const i18nStrings = JSON.parse(elem.dataset.i18n) | ||
const passwordInput = document.querySelector('input[type=password]') | ||
|
||
elem.addEventListener('click', () => { | ||
if (passwordInput.type === 'password') { | ||
passwordInput.type = 'text' | ||
elem.textContent = i18nStrings['hide_password'] | ||
} else { | ||
passwordInput.type = 'password' | ||
elem.textContent = i18nStrings['show_password'] | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters