mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-17 16:15:24 +01:00
61dd2bfdde
If you forget or enter an invalid username/e-mail, the password choosing shouldn't start over. fixes #33162 Built from https://develop.svn.wordpress.org/trunk@33495 git-svn-id: http://core.svn.wordpress.org/trunk@33462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
!function(a){function b(){"function"!=typeof zxcvbn?setTimeout(b,50):(i.val(i.data("pw")),i.trigger("pwupdate"),1!==parseInt(n.data("start-masked"),10)?h.addClass("show-password"):n.trigger("click"))}function c(){var c=a("#pass-strength-result")[0];q=i.val(),h=i.parent(),j=a('<input type="text"/>').attr({id:"pass1-text",name:"pass1-text",autocomplete:"off"}).addClass(i[0].className).data("pw",i.data("pw")).val(i.val()).on("input propertychange",function(){j.val()!==q&&(k.val(j.val()),i.val(j.val()).trigger("pwupdate"),q=j.val())}),i.after(j),1===parseInt(i.data("reveal"),10)&&b(),i.on("input propertychange pwupdate",function(){i.val()!==q&&(q=i.val(),j.val(q),i.add(j).removeClass("short bad good strong"),c.className&&(i.add(j).addClass(c.className),"short"===c.className||"bad"===c.className?(m.prop("checked")||o.prop("disabled",!0),l.show()):(o.prop("disabled",!1),l.hide())))})}function d(){n=g.find(".wp-hide-pw"),n.show().on("click",function(){1===parseInt(n.data("toggle"),10)?(h.addClass("show-password"),n.data("toggle",0).attr({"aria-label":userProfileL10n.ariaHide}).find(".text").text(userProfileL10n.hide).end().find(".dashicons").removeClass("dashicons-visibility").addClass("dashicons-hidden"),j.focus(),_.isUndefined(j[0].setSelectionRange)||j[0].setSelectionRange(0,100)):(h.removeClass("show-password"),n.data("toggle",1).attr({"aria-label":userProfileL10n.ariaShow}).find(".text").text(userProfileL10n.show).end().find(".dashicons").removeClass("dashicons-hidden").addClass("dashicons-visibility"),i.focus(),_.isUndefined(i[0].setSelectionRange)||i[0].setSelectionRange(0,100))})}function e(){var e,f,n;g=a(".user-pass1-wrap"),a(".user-pass2-wrap").hide(),p=a("#submit").on("click",function(){r=!1}),o=p.add(" #createusersub"),l=a(".pw-weak"),m=l.find(".pw-checkbox"),m.change(function(){o.prop("disabled",!m.prop("checked"))}),i=a("#pass1"),i.length&&c(),k=a("#pass2").on("input propertychange",function(){k.val().length>0&&(i.val(k.val()),k.val(""),q="",i.trigger("pwupdate"))}),e=g.find(".wp-pwd").hide(),d(),f=g.find("button.wp-generate-pw").show(),f.on("click",function(){r=!0,f.hide(),e.show(),0===j.val().length&&b(),_.defer(function(){j.focus(),_.isUndefined(j[0].setSelectionRange)||j[0].setSelectionRange(0,100)},0)}),n=g.find("button.wp-cancel-pw"),n.on("click",function(){r=!1,f.show(),e.hide()}),g.closest("form").on("submit",function(){r=!1,k.val(i.val()),h.removeClass("show-password")})}function f(){var b,c=a("#pass1").val();if(a("#pass-strength-result").removeClass("short bad good strong"),!c)return void a("#pass-strength-result").html(" ");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 g,h,i,j,k,l,m,n,o,p,q,r=!1;a(document).ready(function(){var b,c,d,g,h=a("#display_name");a("#pass1").val("").on("input propertychange pwupdate",f),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()||"",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",h),function(a,c){b.push(c.value)}),a.each(c,function(d,e){if(e){var f=e.replace(/<\/?[a-z][^>]*>/gi,"");c[d].length&&-1===a.inArray(f,b)&&(b.push(f),a("<option />",{text:f}).appendTo(h))}})}),b=a("#color-picker"),c=a("#colors-css"),d=a("input#user_id").val(),g=a('input[name="checkuser_id"]').val(),b.on("click.colorpicker",".color-option",function(){var b,e=a(this);if(!e.hasClass("selected")&&(e.siblings(".selected").removeClass("selected"),e.addClass("selected").find('input[type="radio"]').prop("checked",!0),d===g)){if(0===c.length&&(c=a('<link rel="stylesheet" />').appendTo("head")),c.attr("href",e.children(".css_url").val()),"undefined"!=typeof wp&&wp.svgPainter){try{b=a.parseJSON(e.children(".icon_colors").val())}catch(f){}b&&(wp.svgPainter.setColors(b),wp.svgPainter.paint())}a.post(ajaxurl,{action:"save-user-color-scheme",color_scheme:e.children('input[name="admin_color"]').val(),nonce:a("#color-nonce").val()}).done(function(b){b.success&&a("body").removeClass(b.data.previousScheme).addClass(b.data.currentScheme)})}}),e()}),a("#destroy-sessions").on("click",function(b){var c=a(this);wp.ajax.post("destroy-sessions",{nonce:a("#_wpnonce").val(),user_id:a("#user_id").val()}).done(function(a){c.prop("disabled",!0),c.siblings(".notice").remove(),c.before('<div class="notice notice-success inline"><p>'+a.message+"</p></div>")}).fail(function(a){c.siblings(".notice").remove(),c.before('<div class="notice notice-error inline"><p>'+a.message+"</p></div>")}),b.preventDefault()}),window.generatePassword=b,a(window).on("beforeunload",function(){return!0===r?userProfileL10n.warn:void 0})}(jQuery); |