1 /** |
1 /** |
2 * @output wp-admin/js/user-profile.js |
2 * @output wp-admin/js/user-profile.js |
3 */ |
3 */ |
4 |
4 |
5 /* global ajaxurl, pwsL10n, userProfileL10n */ |
5 /* global ajaxurl, pwsL10n, userProfileL10n, ClipboardJS */ |
6 (function($) { |
6 (function($) { |
7 var updateLock = false, |
7 var updateLock = false, |
8 isSubmitting = false, |
8 isSubmitting = false, |
9 __ = wp.i18n.__, |
9 __ = wp.i18n.__, |
|
10 clipboard = new ClipboardJS( '.application-password-display .copy-button' ), |
10 $pass1Row, |
11 $pass1Row, |
11 $pass1, |
12 $pass1, |
12 $pass2, |
13 $pass2, |
13 $weakRow, |
14 $weakRow, |
14 $weakCheckbox, |
15 $weakCheckbox, |
344 } |
346 } |
345 } |
347 } |
346 } |
348 } |
347 } |
349 } |
348 |
350 |
|
351 // Debug information copy section. |
|
352 clipboard.on( 'success', function( e ) { |
|
353 var triggerElement = $( e.trigger ), |
|
354 successElement = $( '.success', triggerElement.closest( '.application-password-display' ) ); |
|
355 |
|
356 // Clear the selection and move focus back to the trigger. |
|
357 e.clearSelection(); |
|
358 |
|
359 // Show success visual feedback. |
|
360 clearTimeout( successTimeout ); |
|
361 successElement.removeClass( 'hidden' ); |
|
362 |
|
363 // Hide success visual feedback after 3 seconds since last success. |
|
364 successTimeout = setTimeout( function() { |
|
365 successElement.addClass( 'hidden' ); |
|
366 }, 3000 ); |
|
367 |
|
368 // Handle success audible feedback. |
|
369 wp.a11y.speak( __( 'Application password has been copied to your clipboard.' ) ); |
|
370 } ); |
|
371 |
349 $( function() { |
372 $( function() { |
350 var $colorpicker, $stylesheet, user_id, current_user_id, |
373 var $colorpicker, $stylesheet, user_id, current_user_id, |
351 select = $( '#display_name' ), |
374 select = $( '#display_name' ), |
352 current_name = select.val(), |
375 current_name = select.val(), |
353 greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' ); |
376 greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' ); |