Make WordPress Core

Changeset 34539


Ignore:
Timestamp:
09/25/2015 01:53:04 PM (11 years ago)
Author:
wonderboymusic
Message:

Profile: when clicking "Generate Password", toggling visibility, then canceling, ensure that the UI resets properly for when the "Generate Password" button is clicked again.

Props umesh.nevase.
Fixes #33897.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/user-profile.js

    r34371 r34539  
    9999        }
    100100
     101        function resetToggle() {
     102                $toggleButton
     103                        .data( 'toggle', 0 )
     104                        .attr({
     105                                'aria-label': userProfileL10n.ariaHide
     106                        })
     107                        .find( '.text' )
     108                                .text( userProfileL10n.hide )
     109                        .end()
     110                        .find( '.dashicons' )
     111                                .removeClass( 'dashicons-visibility' )
     112                                .addClass( 'dashicons-hidden' );
     113
     114                $pass1Text.focus();
     115
     116                $pass1Label.attr( 'for', 'pass1-text' );
     117        }
     118
    101119        function bindToggleButton() {
    102120                $toggleButton = $pass1Row.find('.wp-hide-pw');
     
    104122                        if ( 1 === parseInt( $toggleButton.data( 'toggle' ), 10 ) ) {
    105123                                $pass1Wrap.addClass( 'show-password' );
    106                                 $toggleButton
    107                                         .data( 'toggle', 0 )
    108                                         .attr({
    109                                                 'aria-label': userProfileL10n.ariaHide
    110                                         })
    111                                         .find( '.text' )
    112                                                 .text( userProfileL10n.hide )
    113                                         .end()
    114                                         .find( '.dashicons' )
    115                                                 .removeClass('dashicons-visibility')
    116                                                 .addClass('dashicons-hidden');
    117 
    118                                 $pass1Text.focus();
    119 
    120                                 $pass1Label.attr( 'for', 'pass1-text' );
     124
     125                                resetToggle();
    121126
    122127                                if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) {
     
    234239                        $generateButton.show();
    235240                        $passwordWrapper.hide();
     241
     242                        resetToggle();
    236243
    237244                        // Clear password field to prevent update
Note: See TracChangeset for help on using the changeset viewer.