woocommerce/assets/js/frontend/password-strength-meter.min.js

1 line
1.9 KiB
JavaScript

!function(a){"use strict";var d={init:function(){a(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),a("form.checkout #createaccount").change()},strengthMeter:function(){var s,r=a("form.register, form.checkout, form.edit-account, form.lost_reset_password"),e=a('button[type="submit"]',r),t=a("#reg_password, #account_password, #password_1",r),o=t.val();d.includeMeter(r,t),s=d.checkPasswordStrength(r,t),0<o.length&&s<wc_password_strength_meter_params.min_password_strength&&!r.is("form.checkout")&&-1!==s?e.attr("disabled","disabled").addClass("disabled"):e.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(s,r){var e=s.find(".woocommerce-password-strength");""===r.val()?(e.hide(),a(document.body).trigger("wc-password-strength-hide")):0===e.length?(r.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),a(document.body).trigger("wc-password-strength-added")):(e.show(),a(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n["short"]+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};d.init()}(jQuery);