Hide password meter rather than remove it.
This commit is contained in:
parent
8a60d0aee9
commit
4e4d6204bc
|
@ -46,11 +46,14 @@
|
||||||
var meter = wrapper.find( '.woocommerce-password-strength' );
|
var meter = wrapper.find( '.woocommerce-password-strength' );
|
||||||
|
|
||||||
if ( '' === field.val() ) {
|
if ( '' === field.val() ) {
|
||||||
meter.remove();
|
meter.hide();
|
||||||
$( document.body ).trigger( 'wc-password-strength-removed' );
|
$( document.body ).trigger( 'wc-password-strength-hide' );
|
||||||
} else if ( 0 === meter.length ) {
|
} else if ( 0 === meter.length ) {
|
||||||
field.after( '<div class="woocommerce-password-strength" aria-live="polite"></div>' );
|
field.after( '<div class="woocommerce-password-strength" aria-live="polite"></div>' );
|
||||||
$( document.body ).trigger( 'wc-password-strength-added' );
|
$( document.body ).trigger( 'wc-password-strength-added' );
|
||||||
|
} else {
|
||||||
|
meter.show();
|
||||||
|
$( document.body ).trigger( 'wc-password-strength-show' );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -62,16 +65,20 @@
|
||||||
* @return {Int}
|
* @return {Int}
|
||||||
*/
|
*/
|
||||||
checkPasswordStrength: function( wrapper, field ) {
|
checkPasswordStrength: function( wrapper, field ) {
|
||||||
var meter = wrapper.find( '.woocommerce-password-strength' );
|
var meter = wrapper.find( '.woocommerce-password-strength' ),
|
||||||
var hint = wrapper.find( '.woocommerce-password-hint' );
|
hint = wrapper.find( '.woocommerce-password-hint' ),
|
||||||
var hint_html = '<small class="woocommerce-password-hint">' + wc_password_strength_meter_params.i18n_password_hint + '</small>';
|
hint_html = '<small class="woocommerce-password-hint">' + wc_password_strength_meter_params.i18n_password_hint + '</small>',
|
||||||
var strength = wp.passwordStrength.meter( field.val(), wp.passwordStrength.userInputBlacklist() );
|
strength = wp.passwordStrength.meter( field.val(), wp.passwordStrength.userInputBlacklist() ),
|
||||||
var error = '';
|
error = '';
|
||||||
|
|
||||||
// Reset
|
// Reset.
|
||||||
meter.removeClass( 'short bad good strong' );
|
meter.removeClass( 'short bad good strong' );
|
||||||
hint.remove();
|
hint.remove();
|
||||||
|
|
||||||
|
if ( meter.is( ':hidden' ) ) {
|
||||||
|
return strength;
|
||||||
|
}
|
||||||
|
|
||||||
// Error to append
|
// Error to append
|
||||||
if ( strength < wc_password_strength_meter_params.min_password_strength ) {
|
if ( strength < wc_password_strength_meter_params.min_password_strength ) {
|
||||||
error = ' - ' + wc_password_strength_meter_params.i18n_password_error;
|
error = ' - ' + wc_password_strength_meter_params.i18n_password_error;
|
||||||
|
|
Loading…
Reference in New Issue