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

see #32886

git-svn-id: https://develop.svn.wordpress.org/trunk@33465 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2015-07-28 21:10:16 +00:00
parent d5a39fe063
commit 90e39719d8

View File

@@ -27,6 +27,7 @@
function bindPass1() {
var passStrength = $('#pass-strength-result')[0];
var currentPass = $pass1.val();
$pass1Wrap = $pass1.parent();
@@ -50,23 +51,26 @@
}
$pass1.on( 'input propertychange', function () {
setTimeout( function () {
$pass1Text.val( $pass1.val() );
$pass1.add( $pass1Text ).removeClass( 'short bad good strong' );
if ( $pass1.val() === currentPass ) {
return;
}
if ( passStrength.className ) {
$pass1.add( $pass1Text ).addClass( passStrength.className );
if ( 'short' === passStrength.className || 'bad' === passStrength.className ) {
if ( ! $weakCheckbox.prop( 'checked' ) ) {
$submitButtons.prop( 'disabled', true );
}
$weakRow.show();
} else {
$submitButtons.prop( 'disabled', false );
$weakRow.hide();
currentPass = $pass1.val();
$pass1Text.val( currentPass );
$pass1.add( $pass1Text ).removeClass( 'short bad good strong' );
if ( passStrength.className ) {
$pass1.add( $pass1Text ).addClass( passStrength.className );
if ( 'short' === passStrength.className || 'bad' === passStrength.className ) {
if ( ! $weakCheckbox.prop( 'checked' ) ) {
$submitButtons.prop( 'disabled', true );
}
$weakRow.show();
} else {
$submitButtons.prop( 'disabled', false );
$weakRow.hide();
}
}, 1 );
}
} );
}