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

1 line
6.1 KiB
JavaScript
Raw Normal View History

!function(l){var a,t,n,i,o,r,d,p,c,u,h,f,v=!1;function w(){"function"==typeof zxcvbn?(n.val()?b():(n.val(n.data("pw")),n.trigger("pwupdate")),k(),1!==parseInt(c.data("start-masked"),10)?t.addClass("show-password"):c.trigger("click"),l("#pw-weak-text-label").html(userProfileL10n.warnWeak)):setTimeout(w,50)}function m(){c.data("toggle",0).attr({"aria-label":userProfileL10n.ariaHide}).find(".text").text(userProfileL10n.hide).end().find(".dashicons").removeClass("dashicons-visibility").addClass("dashicons-hidden"),i.focus(),o.attr("for","pass1-text")}function g(){var e,s;a=l(".user-pass1-wrap"),o=a.find("th label").attr("for","pass1-text"),l(".user-pass2-wrap").hide(),h=l("#submit, #wp-submit").on("click",function(){v=!1}),u=h.add(" #createusersub"),d=l(".pw-weak"),(p=d.find(".pw-checkbox")).change(function(){u.prop("disabled",!p.prop("checked"))}),(n=l("#pass1")).length&&(f=n.val(),t=n.parent(),i=l('<input type="text"/>').attr({id:"pass1-text",name:"pass1-text",autocomplete:"off"}).addClass(n[0].className).data("pw",n.data("pw")).val(n.val()).on("input",function(){i.val()!==f&&(r.val(i.val()),n.val(i.val()).trigger("pwupdate"),f=i.val())}),n.after(i),1===parseInt(n.data("reveal"),10)&&w(),n.on("input pwupdate",function(){n.val()!==f&&(f=n.val(),i.val()!==f&&i.val(f),n.add(i).removeClass("short bad good strong"),k())})),r=l("#pass2").on("input",function(){0<r.val().length&&(n.val(r.val()),r.val(""),f="",n.trigger("pwupdate"))}),n.is(":hidden")&&(n.prop("disabled",!0),r.prop("disabled",!0),i.prop("disabled",!0)),e=a.find(".wp-pwd"),s=a.find("button.wp-generate-pw"),(c=a.find(".wp-hide-pw")).show().on("click",function(){1===parseInt(c.data("toggle"),10)?(t.addClass("show-password"),m(),_.isUndefined(i[0].setSelectionRange)||i[0].setSelectionRange(0,100)):(t.removeClass("show-password"),c.data("toggle",1).attr({"aria-label":userProfileL10n.ariaShow}).find(".text").text(userProfileL10n.show).end().find(".dashicons").removeClass("dashicons-hidden").addClass("dashicons-visibility"),n.focus(),o.attr("for","pass1"),_.isUndefined(n[0].setSelectionRange)||n[0].setSelectionRange(0,100))}),s.length&&e.hide(),s.show(),s.on("click",function(){v=!0,s.hide(),e.show(),n.attr("disabled",!1),r.attr("disabled",!1),i.attr("disabled",!1),0===i.val().length&&w(),_.defer(function(){i.focus(),_.isUndefined(i[0].setSelectionRange)||i[0].setSelectionRange(0,100)},0)}),a.find("button.wp-cancel-pw").on("click",function(){v=!1,i.val(""),wp.ajax.post("generate-password").done(function(e){n.data("pw",e)}),s.show(),e.hide(),d.hide(0,function(){p.removeProp("checked")}),n.prop("disabled",!0),r.prop("disabled",!0),i.prop("disabled",!0),m(),a.closest("form").is("#your-profile")&&(n.val("").trigger("pwupdate"),u.prop("disabled",!1))}),a.closest("form").on("submit",function(){v=!1,n.prop("disabled",!1),r.prop("disabled",!1),r.val(n.val()),t.removeClass("show-password")})}function b(){var e=l("#pass1").val();if(l("#pass-strength-result").removeClass("short bad good strong"),e)switch(wp.passwordStrength.meter(e,wp.passwordStrength.userInputBlacklist(),e)){case-1:l("#pass-strength-result").addClass("bad").html(pwsL10n.unknown);break;case 2:l("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:l("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:l("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:l("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:l("#pass-strength-result").addClass("short").html(pwsL10n.short)}else l("#pass-strength-result").html("&nbsp;")}function k(){var e=l("#pass-strength-result")[0];e.className&&(n.add(i).addClass(e.className),l(e).is(".short, .bad")?(p.prop("checked")||u.prop("disabled",!0),d.show()):(u.prop("disabled",!1),d.hide()))}l(document).ready(function(){var e,a,t,n,i=l("#display_name"),s=i.val(),o=l("#wp-admin-bar-my-account").find(".display-name");l("#pass1").val("").on("input pwupdate",b),l("#pass-strength-result").show(),l(".color-palette").click(function(){l(this).siblings('input[name="admin_color"]').prop("checked",!0)}),i.lengt