Make WordPress Core

Changeset 33465


Ignore:
Timestamp:
07/28/2015 09:10:16 PM (10 years ago)
Author:
markjaquith
Message:

Lose the clunky setTimeout() code and just track the password value changes.

see #32886

File:
1 edited

Legend:

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

    r33450 r33465  
    2828    function bindPass1() {
    2929        var passStrength = $('#pass-strength-result')[0];
     30        var currentPass = $pass1.val();
    3031
    3132        $pass1Wrap = $pass1.parent();
     
    5152
    5253        $pass1.on( 'input propertychange', function () {
    53             setTimeout( function () {
    54                 $pass1Text.val( $pass1.val() );
    55                 $pass1.add( $pass1Text ).removeClass( 'short bad good strong' );
    56 
    57                 if ( passStrength.className ) {
    58                     $pass1.add( $pass1Text ).addClass( passStrength.className );
    59                     if ( 'short' === passStrength.className || 'bad' === passStrength.className ) {
    60                         if ( ! $weakCheckbox.prop( 'checked' ) ) {
    61                             $submitButtons.prop( 'disabled', true );
    62                         }
    63                         $weakRow.show();
    64                     } else {
    65                         $submitButtons.prop( 'disabled', false );
    66                         $weakRow.hide();
    67                     }
    68                 }
    69             }, 1 );
     54            if ( $pass1.val() === currentPass ) {
     55                return;
     56            }
     57
     58            currentPass = $pass1.val();
     59            $pass1Text.val( currentPass );
     60            $pass1.add( $pass1Text ).removeClass( 'short bad good strong' );
     61
     62            if ( passStrength.className ) {
     63                $pass1.add( $pass1Text ).addClass( passStrength.className );
     64                if ( 'short' === passStrength.className || 'bad' === passStrength.className ) {
     65                    if ( ! $weakCheckbox.prop( 'checked' ) ) {
     66                        $submitButtons.prop( 'disabled', true );
     67                    }
     68                    $weakRow.show();
     69                } else {
     70                    $submitButtons.prop( 'disabled', false );
     71                    $weakRow.hide();
     72                }
     73            }
    7074        } );
    7175    }
Note: See TracChangeset for help on using the changeset viewer.