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

props jorbin.
see #25603.


git-svn-id: https://develop.svn.wordpress.org/trunk@25848 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-10-18 18:49:47 +00:00
parent c85914b57e
commit 278b180b2f

View File

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