About page: Prevent the meter from briefly sticking on 'Strong' when the animation resets.

props jorbin.
see #25603.

Built from https://develop.svn.wordpress.org/trunk@25848


git-svn-id: http://core.svn.wordpress.org/trunk@25848 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-10-24 22:56:29 +00:00
parent 112a790734
commit c88a0bb423
2 changed files with 9 additions and 7 deletions

View File

@ -22,6 +22,11 @@
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
}
}
function resetMeter(){
$input.val('');
$('#pass-strength-result').text(indicatorString);
$('#pass-strength-result').removeClass('short bad good strong');
}
function animate(){
if (shouldAnimate === false)
@ -30,8 +35,7 @@
$input.val( password.substr(0, $input.val().length + 1) );
updateResult();
} else {
$input.val('');
$('#pass-strength-result').removeClass('short bad good strong');
resetMeter();
}
// Look like real typing by changing the speed new letters are added each time
setTimeout(animate, 220 + Math.floor(Math.random() * ( 800 - 220)) );
@ -48,9 +52,7 @@
// Turn off the animation on focus
$input.on('focus', function(){
shouldAnimate = false;
$('#pass-strength-result').removeClass('short bad good strong');
$('#pass-strength-result').text(indicatorString);
$input.val('')
resetMeter();
});
// Act like a normal password strength meter

View File

@ -1 +1 @@
!function(a){function b(){var b=wp.passwordStrength.meter(f.val(),[],f.val());switch(a("#pass-strength-result").removeClass("short bad good strong"),b){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}function c(){g!==!1&&(f.val().length<e.length?(f.val(e.substr(0,f.val().length+1)),b()):(f.val(""),a("#pass-strength-result").removeClass("short bad good strong")),setTimeout(c,220+Math.floor(580*Math.random())))}function d(){"undefined"!=typeof zxcvbn?c():setTimeout(d,800)}var e="Gosh, WordPress is grand.",f=a("#pass"),g=!0,h=a("#pass-strength-result").text();f.on("focus",function(){g=!1,a("#pass-strength-result").removeClass("short bad good strong"),a("#pass-strength-result").text(h),f.val("")}),f.on("keyup",function(){b()}),d()}(jQuery);
!function(a){function b(){var b=wp.passwordStrength.meter(g.val(),[],g.val());switch(a("#pass-strength-result").removeClass("short bad good strong"),b){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}function c(){g.val(""),a("#pass-strength-result").text(i),a("#pass-strength-result").removeClass("short bad good strong")}function d(){h!==!1&&(g.val().length<f.length?(g.val(f.substr(0,g.val().length+1)),b()):c(),setTimeout(d,220+Math.floor(580*Math.random())))}function e(){"undefined"!=typeof zxcvbn?d():setTimeout(e,800)}var f="Gosh, WordPress is grand.",g=a("#pass"),h=!0,i=a("#pass-strength-result").text();g.on("focus",function(){h=!1,c()}),g.on("keyup",function(){b()}),e()}(jQuery);