Ticket #33398: 33398.2.diff
File 33398.2.diff, 2.0 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/user-profile.js
(this hunk was shorter than expected) 6 6 $pass1Wrap, 7 7 $pass1, 8 8 $pass1Text, 9 10 9 $pass2, 11 12 10 $weakRow, 13 11 $weakCheckbox, 14 15 12 $toggleButton, 16 13 $submitButtons, 17 14 $submitButton, 18 currentPass; 15 currentPass, 16 inputEvent; 19 17 18 /** 19 * Use feature detection to determine whether password inputs should use 20 * the `keyup` or `input` event. Input is preferred but lacks support 21 * in legacy browsers. 22 */ 23 if ( 'oninput' in document.createElement('input') ) { 24 inputEvent = 'input'; 25 } 26 else { 27 inputEvent = 'keyup'; 28 } 29 20 30 function generatePassword() { 21 31 if ( typeof zxcvbn !== 'function' ) { 22 32 setTimeout( generatePassword, 50 ); … … 47 59 .addClass( $pass1[0].className ) 48 60 .data( 'pw', $pass1.data( 'pw' ) ) 49 61 .val( $pass1.val() ) 50 .on( 'keyup', function () {62 .on( inputEvent, function () { 51 63 if ( $pass1Text.val() === currentPass ) { 52 64 return; 53 65 } … … 62 74 generatePassword(); 63 75 } 64 76 65 $pass1.on( 'keyuppwupdate', function () {77 $pass1.on( inputEvent + ' pwupdate', function () { 66 78 if ( $pass1.val() === currentPass ) { 67 79 return; 68 80 } … … 165 177 * This fixes the issue by copying any changes from the hidden 166 178 * pass2 field to the pass1 field, then running check_pass_strength. 167 179 */ 168 $pass2 = $('#pass2').on( 'keyup', function () {180 $pass2 = $('#pass2').on( inputEvent, function () { 169 181 if ( $pass2.val().length > 0 ) { 170 182 $pass1.val( $pass2.val() ); 171 183 $pass2.val(''); … … 250 262 var $colorpicker, $stylesheet, user_id, current_user_id, 251 263 select = $( '#display_name' ); 252 264 253 $('#pass1').val('').on( 'keyuppwupdate', check_pass_strength );265 $('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength ); 254 266 $('#pass-strength-result').show(); 255 267 $('.color-palette').click( function() { 256 268 $(this).siblings('input[name="admin_color"]').prop('checked', true);