From 278b180b2f5c2544269a2077b9fc0d791e1bdec9 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 18 Oct 2013 18:49:47 +0000 Subject: [PATCH] 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 --- src/wp-admin/js/about.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/js/about.js b/src/wp-admin/js/about.js index 5785e6c5c4..844b732d4f 100644 --- a/src/wp-admin/js/about.js +++ b/src/wp-admin/js/about.js @@ -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 @@ -61,4 +63,4 @@ // Start the animation begin(); -})(jQuery); \ No newline at end of file +})(jQuery);