material_base-8.x-2.x-dev/dist/js/user.js
dist/js/user.js
!function(s,a){a.user={password:{css:{passwordParent:"password-parent",passwordsMatch:"ok",passwordsNotMatch:"error",passwordWeak:"is-weak",passwordFair:"is-fair",passwordGood:"is-good",passwordStrong:"is-strong",widgetInitial:"",passwordEmpty:"",passwordFilled:"",confirmEmpty:"",confirmFilled:""}}},a.behaviors.password={attach:function(r,t){var e=a.user.password.css;once("password","input.js-password-field",r).forEach(function(r){var o=s(r),d=o.parent().parent().addClass(e.passwordParent),i=o.closest(".js-form-type-password-confirm"),n=i.find("input.js-password-confirm"),p=s(a.theme("passwordConfirmMessage",t.password)),l=p.find('[data-drupal-selector="password-match-status-text"]').first(),w=n.parent().parent().addClass("confirm-parent").append(p),c=[e.passwordWeak||"",e.passwordFair||"",e.passwordGood||"",e.passwordStrong||""].join(" ").trim(),h=[e.passwordsMatch||"",e.passwordsNotMatch||""].join(" ").trim(),u=[e.widgetInitial||"",e.passwordEmpty||"",e.passwordFilled||"",e.confirmEmpty||"",e.confirmFilled||""].join(" ").trim(),g={};if(t.password.showStrengthIndicator){var m=s(a.theme("passwordStrength",t.password));g.$strengthBar=m.find('[data-drupal-selector="password-strength-indicator"]').first(),g.$strengthTextWrapper=m.find('[data-drupal-selector="password-strength-text"]').first(),g.$suggestions=s(a.theme("passwordSuggestions",t.password,[])),g.$suggestions.hide(),d.append(m),w.after(g.$suggestions)}var f=function(){i.addClass(o[0].value?e.passwordFilled:e.passwordEmpty).addClass(n[0].value?e.confirmFilled:e.confirmEmpty)},v=function(){if(t.password.showStrengthIndicator){var r=a.evaluatePasswordStrength(o[0].value,t.password),d=s(a.theme("passwordSuggestions",t.password,r.messageTips));g.$suggestions.html()!==d.html()&&(g.$suggestions.replaceWith(d),g.$suggestions=d.toggle(100!==r.strength)),c&&g.$strengthBar.removeClass(c),g.$strengthBar.css("width","".concat(r.strength,"%")).addClass(r.indicatorClass),g.$strengthTextWrapper.html(r.indicatorText)}var w,m,v,C;n[0].value?(w=n[0].value,v=(m=o[0].value===w)?e.passwordsMatch:e.passwordsNotMatch,C=m?t.password.confirmSuccess:t.password.confirmFailure,l.hasClass(v)&&!l.html()!==C||(h&&l.removeClass(h),l.html(C).addClass(v)),p.css({visibility:"visible"}),p.removeClass("is-hidden")):(p.css({visibility:"hidden"}),p.addClass("is-hidden")),u&&(i.removeClass(u),f())};u&&f(),o.on("input",v),n.on("input",v)})}},a.evaluatePasswordStrength=function(r,t){var e,o;r=r.trim();var d=0,i=100,n=[],p=/[a-z]/.test(r),l=/[A-Z]/.test(r),w=/[0-9]/.test(r),c=/[^a-zA-Z0-9]/.test(r),h=s("input.username"),u=h.length>0?h[0].value:t.username;switch(r.length<12&&(n.push(t.tooShort),i-=5*(12-r.length)+30),p||(n.push(t.addLowerCase),d+=1),l||(n.push(t.addUpperCase),d+=1),w||(n.push(t.addNumbers),d+=1),c||(n.push(t.addPunctuation),d+=1),d){case 1:i-=12.5;break;case 2:i-=25;break;case 3:case 4:i-=40}""!==r&&r.toLowerCase()===u.toLowerCase()&&(n.push(t.sameAsUsername),i=5);var g=a.user.password.css;i<60?(e=t.weak,o=g.passwordWeak):i<70?(e=t.fair,o=g.passwordFair):i<80?(e=t.good,o=g.passwordGood):i<=100&&(e=t.strong,o=g.passwordStrong);var m=n;return n="".concat(t.hasWeaknesses,"<ul><li>").concat(n.join("</li><li>"),"</li></ul>"),{strength:i,indicatorText:e,indicatorClass:o,messageTips:m}}}(jQuery,Drupal);