equal
deleted
inserted
replaced
30 // zxcvbn loaded after the user entered password, check strength. |
30 // zxcvbn loaded after the user entered password, check strength. |
31 check_pass_strength(); |
31 check_pass_strength(); |
32 showOrHideWeakPasswordCheckbox(); |
32 showOrHideWeakPasswordCheckbox(); |
33 } |
33 } |
34 |
34 |
|
35 /* |
|
36 * This works around a race condition when zxcvbn loads quickly and |
|
37 * causes `generatePassword()` to run prior to the toggle button being |
|
38 * bound. |
|
39 */ |
|
40 bindToggleButton(); |
|
41 |
35 // Install screen. |
42 // Install screen. |
36 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { |
43 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { |
37 // Show the password not masked if admin_password hasn't been posted yet. |
44 // Show the password not masked if admin_password hasn't been posted yet. |
38 $pass1.attr( 'type', 'text' ); |
45 $pass1.attr( 'type', 'text' ); |
39 } else { |
46 } else { |
41 $toggleButton.trigger( 'click' ); |
48 $toggleButton.trigger( 'click' ); |
42 } |
49 } |
43 |
50 |
44 // Once zxcvbn loads, passwords strength is known. |
51 // Once zxcvbn loads, passwords strength is known. |
45 $( '#pw-weak-text-label' ).text( __( 'Confirm use of weak password' ) ); |
52 $( '#pw-weak-text-label' ).text( __( 'Confirm use of weak password' ) ); |
|
53 |
|
54 // Focus the password field. |
|
55 $( $pass1 ).trigger( 'focus' ); |
46 } |
56 } |
47 |
57 |
48 function bindPass1() { |
58 function bindPass1() { |
49 currentPass = $pass1.val(); |
59 currentPass = $pass1.val(); |
50 |
60 |
77 .removeClass( show ? 'dashicons-hidden' : 'dashicons-visibility' ) |
87 .removeClass( show ? 'dashicons-hidden' : 'dashicons-visibility' ) |
78 .addClass( show ? 'dashicons-visibility' : 'dashicons-hidden' ); |
88 .addClass( show ? 'dashicons-visibility' : 'dashicons-hidden' ); |
79 } |
89 } |
80 |
90 |
81 function bindToggleButton() { |
91 function bindToggleButton() { |
|
92 if ( !! $toggleButton ) { |
|
93 // Do not rebind. |
|
94 return; |
|
95 } |
82 $toggleButton = $pass1Row.find('.wp-hide-pw'); |
96 $toggleButton = $pass1Row.find('.wp-hide-pw'); |
83 $toggleButton.show().on( 'click', function () { |
97 $toggleButton.show().on( 'click', function () { |
84 if ( 'password' === $pass1.attr( 'type' ) ) { |
98 if ( 'password' === $pass1.attr( 'type' ) ) { |
85 $pass1.attr( 'type', 'text' ); |
99 $pass1.attr( 'type', 'text' ); |
86 resetToggle( false ); |
100 resetToggle( false ); |
93 |
107 |
94 /** |
108 /** |
95 * Handle the password reset button. Sets up an ajax callback to trigger sending |
109 * Handle the password reset button. Sets up an ajax callback to trigger sending |
96 * a password reset email. |
110 * a password reset email. |
97 */ |
111 */ |
98 function bindPasswordRestLink() { |
112 function bindPasswordResetLink() { |
99 $( '#generate-reset-link' ).on( 'click', function() { |
113 $( '#generate-reset-link' ).on( 'click', function() { |
100 var $this = $(this), |
114 var $this = $(this), |
101 data = { |
115 data = { |
102 'user_id': userProfileL10n.user_id, // The user to send a reset to. |
116 'user_id': userProfileL10n.user_id, // The user to send a reset to. |
103 'nonce': userProfileL10n.nonce // Nonce to validate the action. |
117 'nonce': userProfileL10n.nonce // Nonce to validate the action. |
211 $generateButton.show(); |
225 $generateButton.show(); |
212 $generateButton.on( 'click', function () { |
226 $generateButton.on( 'click', function () { |
213 updateLock = true; |
227 updateLock = true; |
214 |
228 |
215 // Make sure the password fields are shown. |
229 // Make sure the password fields are shown. |
216 $generateButton.attr( 'aria-expanded', 'true' ); |
230 $generateButton.not( '.skip-aria-expanded' ).attr( 'aria-expanded', 'true' ); |
217 $passwordWrapper |
231 $passwordWrapper |
218 .show() |
232 .show() |
219 .addClass( 'is-open' ); |
233 .addClass( 'is-open' ); |
220 |
234 |
221 // Enable the inputs when showing. |
235 // Enable the inputs when showing. |
252 .hide() |
266 .hide() |
253 .removeClass( 'is-open' ); |
267 .removeClass( 'is-open' ); |
254 |
268 |
255 // Stop an empty password from being submitted as a change. |
269 // Stop an empty password from being submitted as a change. |
256 $submitButtons.prop( 'disabled', false ); |
270 $submitButtons.prop( 'disabled', false ); |
|
271 |
|
272 $generateButton.attr( 'aria-expanded', 'false' ); |
257 } ); |
273 } ); |
258 |
274 |
259 $pass1Row.closest( 'form' ).on( 'submit', function () { |
275 $pass1Row.closest( 'form' ).on( 'submit', function () { |
260 updateLock = false; |
276 updateLock = false; |
261 |
277 |
429 }); |
445 }); |
430 } |
446 } |
431 }); |
447 }); |
432 |
448 |
433 bindPasswordForm(); |
449 bindPasswordForm(); |
434 bindPasswordRestLink(); |
450 bindPasswordResetLink(); |
435 }); |
451 }); |
436 |
452 |
437 $( '#destroy-sessions' ).on( 'click', function( e ) { |
453 $( '#destroy-sessions' ).on( 'click', function( e ) { |
438 var $this = $(this); |
454 var $this = $(this); |
439 |
455 |