Passwords: Add password strength meter feedback for screen readers.

Also gives context to the show/hide button.

Props rianrietveld, afercia.
Fixes #33032.



git-svn-id: https://develop.svn.wordpress.org/trunk@33353 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Konstantin Obenland 2015-07-22 00:14:37 +00:00
parent 7527a5c65e
commit 2ab769b1b9
6 changed files with 17 additions and 17 deletions

View File

@ -140,12 +140,12 @@ function display_setup_form( $error = null ) {
<button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button>
<div class="wp-pwd hide-if-js">
<?php $initial_password = wp_generate_password( 24 ); ?>
<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0">
<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-visibility"></span>
<span class="text"><?php _e( 'Hide' ); ?></span>
</button>
<div id="pass-strength-result"></div>
<div id="pass-strength-result" aria-live="polite"></div>
</div>
<p><span class="description hide-if-no-js"><?php _e( 'A password reset link will be sent to you via email.' ); ?></span></p>
</td>

View File

@ -94,15 +94,13 @@
var show = pw_togglebtn.attr( 'data-toggle' );
if ( show == 1 ) {
pw_field.attr( 'type', 'text' );
pw_togglebtn.attr( 'data-toggle', 0 )
.find( '.text' )
.text( userProfileL10n.hide )
pw_togglebtn.attr({ 'data-toggle': 0, 'aria-label': userProfileL10n.ariaHide })
.find( '.text' ).text( userProfileL10n.hide )
;
} else {
pw_field.attr( 'type', 'password' );
pw_togglebtn.attr( 'data-toggle', 1 )
.find( '.text' )
.text( userProfileL10n.show )
pw_togglebtn.attr({ 'data-toggle': 1, 'aria-label': userProfileL10n.ariaShow })
.find( '.text' ).text( userProfileL10n.show )
;
}
pw_field.focus();

View File

@ -464,12 +464,12 @@ if ( $show_password_fields ) :
<input class="hidden" value=" " /><!-- #24364 workaround -->
<button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate new password' ); ?></button>
<div class="wp-pwd hide-if-js">
<input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0">
<input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-visibility"></span>
<span class="text"><?php _e( 'Hide' ); ?></span>
</button>
<div style="display:none" id="pass-strength-result"></div>
<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
</div>
</td>
</tr>

View File

@ -402,12 +402,12 @@ if ( apply_filters( 'show_password_fields', true ) ) : ?>
<button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button>
<div class="wp-pwd hide-if-js">
<?php $initial_password = wp_generate_password( 24 ); ?>
<input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0">
<input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-visibility"></span>
<span class="text"><?php _e( 'Hide' ); ?></span>
</button>
<div style="display:none" id="pass-strength-result"></div>
<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
</div>
<p><span class="description"><?php _e( 'A password reset link will be sent to the user via email.' ); ?></span></p>
</td>

View File

@ -376,6 +376,8 @@ function wp_default_scripts( &$scripts ) {
did_action( 'init' ) && $scripts->localize( 'user-profile', 'userProfileL10n', array(
'show' => __( 'Show' ),
'hide' => __( 'Hide' ),
'ariaShow' => esc_attr__( 'Show password' ),
'ariaHide' => esc_attr__( 'Hide password' ),
) );
$scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );

View File

@ -655,8 +655,8 @@ case 'rp' :
<p class="user-pass1-wrap">
<label for="pass1"><?php _e('New password') ?></label><br />
<div class="wp-pwd">
<input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" />
<div id="pass-strength-result" class="hide-if-no-js"><?php _e( 'Strength indicator' ); ?></div>
<input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" />
<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div>
</div>
</p>
<p class="user-pass2-wrap">