Ticket #42749: 42749-2.patch
File 42749-2.patch, 3.2 KB (added by , 6 years ago) |
---|
-
wp-admin/js/user-profile.js
161 161 // hide this 162 162 $('.user-pass2-wrap').hide(); 163 163 164 $submitButton = $( '#submit , #wp-submit' ).on( 'click', function () {164 $submitButton = $( '#submit' ).on( 'click', function () { 165 165 updateLock = false; 166 166 }); 167 167 … … 205 205 206 206 bindToggleButton(); 207 207 208 if ( $generateButton.length ) { 209 $passwordWrapper.hide(); 210 } 208 $generateButton.on( 'click', function() { 209 if($generateButton.hasClass( 'open' ) ) { 210 $generateButton.removeClass( 'open' ); 211 // Clear any entered password. 212 $pass1Text.val( '' ); 211 213 212 $generateButton.show(); 213 $generateButton.on( 'click', function () { 214 updateLock = true; 214 // Generate a new password. 215 wp.ajax.post( 'generate-password' ) 216 .done( function( data ) { 217 $pass1.data( 'pw', data ); 218 } ); 215 219 216 $generateButton.hide();217 $passwordWrapper.show();220 $passwordWrapper.hide(); 221 $generateButton.attr( 'aria-expanded', false ); 218 222 219 // Enable the inputs when showing. 220 $pass1.attr( 'disabled', false ); 221 $pass2.attr( 'disabled', false ); 222 $pass1Text.attr( 'disabled', false ); 223 $weakRow.hide( 0, function () { 224 $weakCheckbox.removeProp( 'checked' ); 225 } ); 223 226 224 if ( $pass1Text.val().length === 0 ) { 225 generatePassword(); 227 // Disable the inputs when hiding to prevent autofill and submission. 228 $pass1.prop( 'disabled', true ); 229 $pass2.prop( 'disabled', true ); 230 $pass1Text.prop( 'disabled', true ); 231 232 resetToggle(); 233 234 if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) { 235 // Clear password field to prevent update 236 $pass1.val( '' ).trigger( 'pwupdate' ); 237 $submitButtons.prop( 'disabled', false ); 238 } 239 } else { 240 $generateButton.addClass( 'open' ); 241 $generateButton.attr( 'aria-expanded', true ); 242 $passwordWrapper.show(); 243 244 // Enable the inputs when showing. 245 $pass1.attr( 'disabled', false ); 246 $pass2.attr( 'disabled', false ); 247 $pass1Text.attr( 'disabled', false ); 248 249 if ( $pass1Text.val().length === 0 ) { 250 generatePassword(); 251 } 226 252 } 227 228 253 _.defer( function() { 229 $pass1Text.focus();230 254 if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) { 231 255 $pass1Text[0].setSelectionRange( 0, 100 ); 232 256 } … … 237 261 $cancelButton.on( 'click', function () { 238 262 updateLock = false; 239 263 264 $generateButton.removeClass( 'open' ); 265 240 266 // Clear any entered password. 241 267 $pass1Text.val( '' ); 242 268 … … 246 272 $pass1.data( 'pw', data ); 247 273 } ); 248 274 249 $generateButton. show();275 $generateButton.attr( 'aria-expanded', false ).focus(); 250 276 $passwordWrapper.hide(); 251 277 252 278 $weakRow.hide( 0, function () { … … 314 340 315 341 if ( passStrength.className ) { 316 342 $pass1.add( $pass1Text ).addClass( passStrength.className ); 317 if ( $( passStrength ).is( '.short, .bad' )) {343 if ( 'short' === passStrength.className || 'bad' === passStrength.className ) { 318 344 if ( ! $weakCheckbox.prop( 'checked' ) ) { 319 345 $submitButtons.prop( 'disabled', true ); 320 346 }