Merge pull request #9319 from nishitlangaliya/Issue-8938

Issue 8938
This commit is contained in:
Claudio Sanches 2015-10-09 11:12:56 -03:00
commit c4bd6b25c1
9 changed files with 145 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -443,3 +443,38 @@
}
}
}
/**
* PassWord Strength Meter specific styles
*/
#pass-strength-result {
text-align:center;
font-weight:600;
padding: 3px 0px 3px 0px;
}
#pass-strength-result.strong {
background-color: #c1e1b9;
border-color: #83c373;
opacity: 1;
}
#pass-strength-result.short {
background-color: #f1adad;
border-color: #e35b5b;
opacity: 1;
}
#pass-strength-result.bad {
background-color: #fbc5a9;
border-color: #f78b53;
opacity: 1;
}
#pass-strength-result.good {
background-color: #ffe399;
border-color: #ffc733;
opacity: 1;
}

View File

@ -490,4 +490,50 @@ jQuery( function( $ ) {
wc_checkout_form.init();
wc_checkout_coupons.init();
wc_checkout_login_form.init();
// Password strength message container.
$( ".woocommerce-billing-fields .create-account .clear" ).after( '<div id="pass-strength-result" aria-live="polite"></div>');
// Function for check password strength for checkout page
function checkPasswordStrengthChekout( s, a, r ) {
var t = jQuery( '#account_password' ).val();
a.removeClass( 'short bad good strong' ),
r = r.concat( wp.passwordStrength.userInputBlacklist() );
var e = wp.passwordStrength.meter( t, r );
switch ( e ) {
case 2:
a.addClass( 'bad' ).html( pwsL10n.bad );
break;
case 3:
a.addClass( 'good' ).html( pwsL10n.good );
break;
case 4:
a.addClass( 'strong' ).html( pwsL10n.strong );
break;
case 5:
a.addClass( 'short' ).html( pwsL10n.mismatch );
break;
default:
a.addClass( 'short' ).html( pwsL10n.short );
}
return e
}
$( '#account_password' ).keyup(function() {
checkPasswordStrengthChekout(
$( 'input[name=account_password]' ), // First password field
$( '#pass-strength-result' ), // Strength meter
[ 'black', 'listed', 'word' ] // Blacklisted words
);
var passLength = jQuery( '#account_password' ).val().length;
if ( passLength<= 0 ) {
$( '#pass-strength-result' ).css( 'display','none' );
}else {
$( '#pass-strength-result' ).css( 'display','block' );
}
}
);
});

View File

@ -12,4 +12,50 @@ jQuery( function( $ ) {
$( this ).val( min );
}
});
// Password strength message container.
$( '#password_1' ).after( '<div id="pass-strength-result" aria-live="polite"></div>' );
// Function for check password strength for Edit My Account
function checkPasswordStrength( s, a, r ) {
var t = jQuery( '#password_1' ).val();
a.removeClass( 'short bad good strong' ),
r = r.concat( wp.passwordStrength.userInputBlacklist() );
var e = wp.passwordStrength.meter( t, r );
switch ( e ) {
case 2:
a.addClass( 'bad' ).html( pwsL10n.bad );
break;
case 3:
a.addClass( 'good' ).html( pwsL10n.good );
break;
case 4:
a.addClass( 'strong' ).html( pwsL10n.strong );
break;
case 5:
a.addClass( 'short' ).html( pwsL10n.mismatch );
break;
default:
a.addClass( 'short' ).html( pwsL10n.short );
}
return e
}
$( '#password_1' ).keyup(function() {
checkPasswordStrength(
$( 'input[name=password_1]' ), // First password field
$( '#pass-strength-result' ), // Strength meter
[ 'black', 'listed', 'word' ] // Blacklisted words
);
var passLength = jQuery( '#password_1' ).val().length;
if ( passLength<= 0 ) {
$( '#pass-strength-result' ).css( 'display','none' );
}else {
$( '#pass-strength-result' ).css( 'display','block' );
}
}
);
});

View File

@ -184,6 +184,11 @@ class WC_Frontend_Scripts {
}
if ( is_checkout() ) {
self::enqueue_script( 'wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ) );
// Password strength meter js called for checkout page.
if ( !is_user_logged_in() ) {
wp_enqueue_script( 'password-strength-meter' );
}
}
if ( is_add_payment_method_page() ) {
self::enqueue_script( 'wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array( 'jquery', 'woocommerce' ) );
@ -213,6 +218,13 @@ class WC_Frontend_Scripts {
self::enqueue_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'] );
}
}
// Password strength meter js called for my account page.
if ( is_page( get_option( 'woocommerce_myaccount_page_id' ) ) ) {
if ( is_user_logged_in() ) {
wp_enqueue_script( 'password-strength-meter' );
}
}
}
/**

View File

@ -20,6 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/** @global WC_Checkout $checkout */
?>
<div class="woocommerce-billing-fields">
<?php if ( WC()->cart->ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>

View File

@ -18,7 +18,6 @@
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php wc_print_notices(); ?>
@ -52,6 +51,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<p class="form-row form-row-wide">
<label for="password_1"><?php _e( 'New Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_1" id="password_1" />
</p>
<p class="form-row form-row-wide">
<label for="password_2"><?php _e( 'Confirm New Password', 'woocommerce' ); ?></label>