WordPress/wp-admin/js/user-profile.min.js

1 line
5.4 KiB
JavaScript
Raw Normal View History

!function(a){function b(){var b,c=a("#pass1").val(),d=a("#pass2").val();if(a("#pass-strength-result").removeClass("short bad good strong"),!c)return void a("#pass-strength-result").html("&nbsp;");switch(b=wp.passwordStrength.meter(c,wp.passwordStrength.userInputBlacklist(),d)){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(function(){var b=a(".user-pass1-wrap"),c=b.find(".wp-pwd"),d=a("#pass1"),e=a("#pass2"),f=b.find(".wp-hide-pw"),g=b.find("button.wp-generate-pw"),h=b.find("button.wp-cancel-pw"),i=a(".user-pass2-wrap"),j=b.closest("form"),k=a("#pass-strength-result"),l=a("#submit"),m=a("#createusersub"),n=a(".pw-checkbox"),o=a(".pw-weak"),p=!1,q=document.createElement("input");q.type="text";var r=a(q);d.length>0&&(r.attr({id:"pass1-text",name:"pass1-text",autocomplete:"off"}).addClass(d[0].className).data("pw",d.data("pw")).val(d.val()),d.wrap('<span class="password-input-wrapper"></span>').after(r));var s=d.parent(),t=window.generatePassword=function(){"function"!=typeof zxcvbn?setTimeout(t,50):(d.val(d.data("pw")),d.trigger("propertychange"),s.addClass("show-password"))};i.hide(),c.hide(),f.show(),g.show(),1==d.data("reveal")&&t(),j.on("submit",function(){p=!1,e.val(d.val()),s.removeClass("show-password")}),r.on("input",function(){d.val(r.val()),d.trigger("propertychange")}),d.on("input propertychange",function(){setTimeout(function(){var a=k.attr("class");r.val(d.val()),d.add(r).removeClass("short bad good strong"),"undefined"!=typeof a&&(d.add(r).addClass(a),"short"==a||"bad"==a?(n.attr("checked")||(m.attr("disabled","disabled"),l.attr("disabled","disabled")),o.show()):(m.removeAttr("disabled"),l.removeAttr("disabled"),o.hide()))},1)}),n.change(function(){n.attr("checked")?(m.removeAttr("disabled"),l.removeAttr("disabled")):(m.attr("disabled","disabled"),l.attr("disabled","disabled"))}),e.on("input propertychange",function(){e.val().length>0&&(d.val(e.val()),d.trigger("propertychange"))}),b.on("click","button.wp-generate-pw",function(){p=!0,g.hide(),c.show(),t(),_.defer(function(){r.focus(),_.isUndefined(r[0].setSelectionRange)||r[0].setSelectionRange(0,100)},0)}),l.on("click",function(){p=!1}),h.on("click",function(){p=!1,g.show(),c.hide()}),f.on("click",function(){var a=f.attr("data-toggle");1==a?(s.addClass("show-password"),f.attr({"data-toggle":0,"aria-label":userProfileL10n.ariaHide}).find(".text").text(userProfileL10n.hide),f.find(".dashicons").removeClass("dashicons-visibility").addClass("dashicons-hidden"),r.focus(),_.isUndefined(r[0].setSelectionRange)||r[0].setSelectionRange(0,100)):(s.removeClass("show-password"),f.attr({"data-toggle":1,"aria-label":userProfileL10n.ariaShow}).find(".text").text(userProfileL10n.show),f.find(".dashicons").removeClass("dashicons-hidden").addClass("dashicons-visibility"),d.focus(),_.isUndefined(d[0].setSelectionRange)||d[0].setSelectionRange(0,100))}),a(window).on("beforeunload",function(){return!0===p?userProfileL10n.warn:void 0})}),a(document).ready(function(){var c,d,e,f,g=a("#display_name");a("#pass1").val("").on("input propertychange",b),a("#pass2").val("").on("input propertychange",b),a("#pass-strength-result").show(),a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",!0)}),g.length&&a("#first_name, #last_name, #nickname").bind("blur.user_profile",function(){var b=[],c={display_nickname:a("#nickname").val()||"",display_username:a("#user_login").val()||"",display_firstname:a("#first_name").val()||"",display_lastname:a("#last_name").val()||""};c.display_firstname&&c.display_lastname&&(c.display_firstlast=c.display_firstname+" "+c.display_lastname,c.display_lastfirst=c.display_lastname+" "+c.display_firstname),a.each(a("option",g),function(a,c){b.push(c.value)}),a.each(c,function(d,e){if(e