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

1 line
5.9 KiB
JavaScript
Raw Normal View History

!function(a){function b(){"function"!=typeof zxcvbn?setTimeout(b,50):(j.val(j.data("pw")),j.trigger("pwupdate").trigger("wp-check-valid-field"),1!==parseInt(p.data("start-masked"),10)?i.addClass("show-password"):p.trigger("click"))}function c(){var c=a("#pass-strength-result")[0];s=j.val(),i=j.parent(),k=a('<input type="text"/>').attr({id:"pass1-text",name:"pass1-text",autocomplete:"off"}).addClass(j[0].className).data("pw",j.data("pw")).val(j.val()).on(t,function(){k.val()!==s&&(m.val(k.val()),j.val(k.val()).trigger("pwupdate"),s=k.val())}),j.after(k),1===parseInt(j.data("reveal"),10)&&b(),j.on(t+" pwupdate",function(){j.val()!==s&&(s=j.val(),k.val()!==s&&k.val(s),j.add(k).removeClass("short bad good strong"),c.className&&(j.add(k).addClass(c.className),"short"===c.className||"bad"===c.className?(o.prop("checked")||q.prop("disabled",!0),n.show()):(q.prop("disabled",!1),n.hide())))})}function d(){p.data("toggle",0).attr({"aria-label":userProfileL10n.ariaHide}).find(".text").text(userProfileL10n.hide).end().find(".dashicons").removeClass("dashicons-visibility").addClass("dashicons-hidden"),k.focus(),l.attr("for","pass1-text")}function e(){p=h.find(".wp-hide-pw"),p.show().on("click",function(){1===parseInt(p.data("toggle"),10)?(i.addClass("show-password"),d(),_.isUndefined(k[0].setSelectionRange)||k[0].setSelectionRange(0,100)):(i.removeClass("show-password"),p.data("toggle",1).attr({"aria-label":userProfileL10n.ariaShow}).find(".text").text(userProfileL10n.show).end().find(".dashicons").removeClass("dashicons-hidden").addClass("dashicons-visibility"),j.focus(),l.attr("for","pass1"),_.isUndefined(j[0].setSelectionRange)||j[0].setSelectionRange(0,100))})}function f(){var f,g,p;h=a(".user-pass1-wrap"),l=h.find("th label").attr("for","pass1-text"),a(".user-pass2-wrap").hide(),r=a("#submit").on("click",function(){u=!1}),q=r.add(" #createusersub"),n=a(".pw-weak"),o=n.find(".pw-checkbox"),o.change(function(){q.prop("disabled",!o.prop("checked"))}),j=a("#pass1"),j.length&&c(),m=a("#pass2").on(t,function(){m.val().length>0&&(j.val(m.val()),m.val(""),s="",j.trigger("pwupdate"))}),j.is(":hidden")&&(j.prop("disabled",!0),m.prop("disabled",!0),k.prop("disabled",!0)),f=h.find(".wp-pwd"),g=h.find("button.wp-generate-pw"),e(),g.length&&f.hide(),g.show(),g.on("click",function(){u=!0,g.hide(),f.show(),j.attr("disabled",!1),m.attr("disabled",!1),k.attr("disabled",!1),0===k.val().length&&b(),_.defer(function(){k.focus(),_.isUndefined(k[0].setSelectionRange)||k[0].setSelectionRange(0,100)},0)}),p=h.find("button.wp-cancel-pw"),p.on("click",function(){u=!1,k.val(""),wp.ajax.post("generate-password").done(function(a){j.data("pw",a)}),g.show(),f.hide(),n.hide(0,function(){o.removeProp("checked")}),j.prop("disabled",!0),m.prop("disabled",!0),k.prop("disabled",!0),d(),j.val("").trigger("pwupdate"),q.prop("disabled",!1)}),h.closest("form").on("submit",function(){u=!1,j.prop("disabled",!1),m.prop("disabled",!1),m.val(j.val()),i.removeClass("show-password")})}function g(){var b,c=a("#pass1").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(),c)){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"])}}var h,i,j,k,l,m,n,o,p,q,r,s,t,u=!1;t="oninput"in document.createElement("input")?"input":"keyup",a(document).ready(function(){var b,c,d,e,h=a("#display_name");a("#pass1").val("").on(t+" pwupdate",g),a("#pass-strength-result").show(),a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",!0)}),h.length&&a("#first_name, #last_name, #nickname").bind("blur.user_profile",function(){var b=[],c={display_nickname:a("#nickname").val()||"",di