WordPress.org

Make WordPress Core

Ticket #25603: 25603.17.diff

File 25603.17.diff, 2.4 KB (added by jorbin, 6 years ago)
  • src/wp-includes/script-loader.php

     
    332332
    333333        $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
    334334
    335         $scripts->add( 'about', "/wp-admin/js/about$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 );
     335        $scripts->add( 'about', "/wp-admin/js/about$suffix.js", array( 'jquery', 'password-strength-meter', 'underscore' ), false, 1 );
    336336
    337337        $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
    338338
  • src/wp-admin/js/about.js

     
    22    var password = 'Gosh, WordPress is grand.',
    33        $input = $('#pass'),
    44        shouldAnimate = true,
     5        timesForAnimation = [280, 300, 305, 310, 315, 325, 330, 345, 360, 370, 380, 400, 450, 500, 600],
     6        resultsCache = {},
    57        indicatorString = $('#pass-strength-result').text();
    68
    79    function updateResult(){
    8         var strength = wp.passwordStrength.meter($input.val(), [], $input.val());
     10        var strength;
    911
     12        if ( typeof( resultsCache[ $input.val() ]) === 'undefined') {
     13            strength = wp.passwordStrength.meter($input.val(), [], $input.val());
     14            resultsCache[ $input.val() ] = strength;
     15        } else {
     16            strength = resultsCache[ $input.val() ];
     17        }
     18
    1019        $('#pass-strength-result').removeClass('short bad good strong');
    1120        switch ( strength ) {
    1221            case 2:
     
    3443        if ($input.val().length < password.length){
    3544            $input.val( password.substr(0, $input.val().length + 1) );
    3645            updateResult();
     46
     47            // Look like real typing by changing the speed new letters are added each time
     48            setTimeout(animate, _.shuffle(timesForAnimation )[0] );
    3749        } else {
    3850            resetMeter();
     51
     52            // When we reset, let's wait a bit longer than normal to start again
     53            setTimeout(animate, 700);
    3954        }
    40         // Look like real typing by changing the speed new letters are added each time
    41         setTimeout(animate, 220 + Math.floor(Math.random() * ( 800 - 220)) );
     55
    4256    }
    4357    //
    4458    function begin(){