-
Notifications
You must be signed in to change notification settings - Fork 3.4k
3534 Password Toggle Text Variation #3827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1cff436
610991c
532d957
8b9a548
a285e1e
108ce82
c727c38
5910151
ab58f95
b676c71
5c4ab19
a0fd4b6
b3905ba
1240f8e
106d80c
10270a8
605a8d6
cf8bae6
70de2bd
6a33173
31210f9
8b3997c
304428c
b00361f
b11bc95
82be788
ca73852
f1c7a78
65c0011
5c77e9f
bb2f668
359b3c6
bef447e
a48daba
c7d4314
f2fb3ff
e71bd9f
86e33e0
6c1b2fd
570df33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * Adds functionality for password visibility buttons to toggle between text and password input types. | ||
| * | ||
| * @since 6.2.0 | ||
| * @output wp-admin/js/password-toggle.js | ||
| */ | ||
|
|
||
| ( function () { | ||
| var toggleElements, status, input, icon, label, __ = wp.i18n.__; | ||
|
|
||
| toggleElements = document.querySelectorAll( '.pwd-toggle' ); | ||
|
|
||
| toggleElements.forEach( function (toggle) { | ||
| toggle.classList.remove( 'hide-if-no-js' ); | ||
| toggle.addEventListener( 'click', togglePassword ); | ||
| } ); | ||
|
|
||
| function togglePassword() { | ||
| status = this.getAttribute( 'data-toggle' ); | ||
| input = this.parentElement.children.namedItem( 'pwd' ); | ||
| icon = this.getElementsByClassName( 'dashicons' )[ 0 ]; | ||
| label = this.getElementsByClassName( 'text' )[ 0 ]; | ||
|
|
||
| if ( 0 === parseInt( status, 10 ) ) { | ||
| this.setAttribute( 'data-toggle', 1 ); | ||
| this.setAttribute( 'aria-label', __( 'Hide password' ) ); | ||
| input.setAttribute( 'type', 'text' ); | ||
| label.innerHTML = __( 'Hide' ); | ||
| icon.classList.remove( 'dashicons-visibility' ); | ||
| icon.classList.add( 'dashicons-hidden' ); | ||
| } else { | ||
| this.setAttribute( 'data-toggle', 0 ); | ||
| this.setAttribute( 'aria-label', __( 'Show password' ) ); | ||
| input.setAttribute( 'type', 'password' ); | ||
| label.innerHTML = __( 'Show' ); | ||
| icon.classList.remove( 'dashicons-hidden' ); | ||
| icon.classList.add( 'dashicons-visibility' ); | ||
| } | ||
| } | ||
| } )(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -551,6 +551,17 @@ fieldset label, | |
|
|
||
| .wp-pwd { | ||
| margin-top: 1em; | ||
| position: relative; | ||
| } | ||
|
|
||
| .wp-pwd button { | ||
| height: min-content; | ||
| width: 4.875rem; | ||
| } | ||
|
|
||
| .wp-pwd button.pwd-toggle .dashicons { | ||
| position: relative; | ||
| top: 0.25rem | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. |
||
| } | ||
|
|
||
| #misc-publishing-actions label { | ||
|
|
@@ -593,6 +604,10 @@ fieldset label, | |
| opacity: 1; | ||
| } | ||
|
|
||
| .password-input-wrapper { | ||
| display: inline-block; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| .password-input-wrapper input { | ||
| font-family: Consolas, Monaco, monospace; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,12 +140,14 @@ function display_setup_form( $error = null ) { | |
| <td> | ||
| <div class="wp-pwd"> | ||
| <?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?> | ||
| <input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" /> | ||
| <span class="password-input-wrapper"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A |
||
| <input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" /> | ||
| <div id="pass-strength-result" aria-live="polite"></div> | ||
| </span> | ||
| <button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> | ||
| <span class="dashicons dashicons-hidden"></span> | ||
| <span class="text"><?php _e( 'Hide' ); ?></span> | ||
| </button> | ||
| <div id="pass-strength-result" aria-live="polite"></div> | ||
| </div> | ||
| <p><span class="description important hide-if-no-js"> | ||
| <strong><?php _e( 'Important:' ); ?></strong> | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed width buttons can be trouble in other languages.
Spanish overflows a little:

Malayalam overflows a lot:
