fixes: changes as per suggestion given by claudiosmweb ref #8938

This commit is contained in:
nishitlangaliya 2015-10-09 13:25:47 +05:30
parent a45ef9f814
commit f468f16e29
6 changed files with 120 additions and 74 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;
}

File diff suppressed because one or more lines are too long

View File

@ -491,47 +491,48 @@ jQuery( function( $ ) {
wc_checkout_coupons.init();
wc_checkout_login_form.init();
// Password strength message container
// 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 Edit My Account
function checkPasswordStrength(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)
// 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
}
return e
}
// Binding to trigger checkPasswordStrength
jQuery( "#account_password" ).keyup(function() {
checkPasswordStrength(
jQuery('input[name=account_password]'), // First password field
jQuery('#pass-strength-result'), // Strength meter
['black', 'listed', 'word'] // Blacklisted words
$( '#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;
var passLength = jQuery( '#account_password' ).val().length;
if (passLength<= 0) {
jQuery('#pass-strength-result').css('display','none');
if ( passLength<= 0 ) {
$( '#pass-strength-result' ).css( 'display','none' );
}else {
jQuery('#pass-strength-result').css('display','block');
$( '#pass-strength-result' ).css( 'display','block' );
}
}
);

View File

@ -13,49 +13,48 @@ jQuery( function( $ ) {
}
});
// Password strength message container
$( "#password_1" ).after( '<div id="pass-strength-result" aria-live="polite"></div>');
// 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)
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
}
return e
}
jQuery( "#password_1" ).keyup(function() {
checkPasswordStrength(
jQuery('input[name=password_1]'), // First password field
jQuery('#pass-strength-result'), // Strength meter
['black', 'listed', 'word'] // Blacklisted words
$( '#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;
var passLength = jQuery( '#password_1' ).val().length;
if (passLength<= 0) {
jQuery('#pass-strength-result').css('display','none');
if ( passLength<= 0 ) {
$( '#pass-strength-result' ).css( 'display','none' );
}else {
jQuery('#pass-strength-result').css('display','block');
$( '#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,7 +218,13 @@ class WC_Frontend_Scripts {
self::enqueue_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'] );
}
}
wp_enqueue_script( 'password-strength-meter' );
// 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' );
}
}
}
/**