From 39552b63cab042f11f1131559ffdf40869da2f4f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 03:57:24 +0000 Subject: [PATCH] Passwords: fix the markup on the Reset Password Form for `user-pass1` so the JavaScript operates properly. Props ldinclaux. See #33892. Fixes #33908. Built from https://develop.svn.wordpress.org/trunk@34371 git-svn-id: http://core.svn.wordpress.org/trunk@34335 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/user-profile.js | 9 +++++++-- wp-admin/js/user-profile.min.js | 2 +- wp-includes/version.php | 2 +- wp-login.php | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/wp-admin/js/user-profile.js b/wp-admin/js/user-profile.js index 02c22b6357..247f29c92b 100644 --- a/wp-admin/js/user-profile.js +++ b/wp-admin/js/user-profile.js @@ -190,11 +190,16 @@ } } ); - $passwordWrapper = $pass1Row.find('.wp-pwd').hide(); + $passwordWrapper = $pass1Row.find( '.wp-pwd' ); + $generateButton = $pass1Row.find( 'button.wp-generate-pw' ); bindToggleButton(); - $generateButton = $pass1Row.find( 'button.wp-generate-pw' ).show(); + if ( $generateButton.length ) { + $passwordWrapper.hide(); + } + + $generateButton.show(); $generateButton.on( 'click', function () { updateLock = true; diff --git a/wp-admin/js/user-profile.min.js b/wp-admin/js/user-profile.min.js index c492cb8068..a4d579237e 100644 --- a/wp-admin/js/user-profile.min.js +++ b/wp-admin/js/user-profile.min.js @@ -1 +1 @@ -!function(a){function b(){"function"!=typeof zxcvbn?setTimeout(b,50):(i.val(i.data("pw")),i.trigger("pwupdate").trigger("wp-check-valid-field"),1!==parseInt(o.data("start-masked"),10)?h.addClass("show-password"):o.trigger("click"))}function c(){var c=a("#pass-strength-result")[0];r=i.val(),h=i.parent(),j=a('').attr({id:"pass1-text",name:"pass1-text",autocomplete:"off"}).addClass(i[0].className).data("pw",i.data("pw")).val(i.val()).on(s,function(){j.val()!==r&&(l.val(j.val()),i.val(j.val()).trigger("pwupdate"),r=j.val())}),i.after(j),1===parseInt(i.data("reveal"),10)&&b(),i.on(s+" pwupdate",function(){i.val()!==r&&(r=i.val(),j.val()!==r&&j.val(r),i.add(j).removeClass("short bad good strong"),c.className&&(i.add(j).addClass(c.className),"short"===c.className||"bad"===c.className?(n.prop("checked")||p.prop("disabled",!0),m.show()):(p.prop("disabled",!1),m.hide())))})}function d(){o=g.find(".wp-hide-pw"),o.show().on("click",function(){1===parseInt(o.data("toggle"),10)?(h.addClass("show-password"),o.data("toggle",0).attr({"aria-label":userProfileL10n.ariaHide}).find(".text").text(userProfileL10n.hide).end().find(".dashicons").removeClass("dashicons-visibility").addClass("dashicons-hidden"),j.focus(),k.attr("for","pass1-text"),_.isUndefined(j[0].setSelectionRange)||j[0].setSelectionRange(0,100)):(h.removeClass("show-password"),o.data("toggle",1).attr({"aria-label":userProfileL10n.ariaShow}).find(".text").text(userProfileL10n.show).end().find(".dashicons").removeClass("dashicons-hidden").addClass("dashicons-visibility"),i.focus(),k.attr("for","pass1"),_.isUndefined(i[0].setSelectionRange)||i[0].setSelectionRange(0,100))})}function e(){var e,f,o;g=a(".user-pass1-wrap"),k=g.find("th label").attr("for","pass1-text"),a(".user-pass2-wrap").hide(),q=a("#submit").on("click",function(){t=!1}),p=q.add(" #createusersub"),m=a(".pw-weak"),n=m.find(".pw-checkbox"),n.change(function(){p.prop("disabled",!n.prop("checked"))}),i=a("#pass1"),i.length&&c(),l=a("#pass2").on(s,function(){l.val().length>0&&(i.val(l.val()),l.val(""),r="",i.trigger("pwupdate"))}),e=g.find(".wp-pwd").hide(),d(),f=g.find("button.wp-generate-pw").show(),f.on("click",function(){t=!0,f.hide(),e.show(),0===j.val().length&&b(),_.defer(function(){j.focus(),_.isUndefined(j[0].setSelectionRange)||j[0].setSelectionRange(0,100)},0)}),o=g.find("button.wp-cancel-pw"),o.on("click",function(){t=!1,j.val(""),wp.ajax.post("generate-password").done(function(a){i.data("pw",a)}),f.show(),e.hide(),i.val("").trigger("pwupdate"),p.prop("disabled",!1)}),g.closest("form").on("submit",function(){t=!1,l.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,s,t=!1;s="oninput"in document.createElement("input")?"input":"keyup",a(document).ready(function(){var b,c,d,g,h=a("#display_name");a("#pass1").val("").on(s+" 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("