Ticket #54426: 54426.diff
File 54426.diff, 4.3 KB (added by , 3 years ago) |
---|
-
src/js/_enqueues/admin/media.js
141 141 * @return {void} 142 142 */ 143 143 $( function() { 144 var settings, $mediaGridWrap = $( '#wp-media-grid' ); 144 var settings, 145 $mediaGridWrap = $( '#wp-media-grid' ), 146 copyAttachmentURLClipboard = new ClipboardJS( '.copy-attachment-url.media-library' ), 147 copyAttachmentURLSuccessTimeout; 145 148 146 149 // Opens a manage media frame into the grid. 147 150 if ( $mediaGridWrap.length && window.wp && window.wp.media ) { … … 205 208 $( '.find-box-inside' ).on( 'click', 'tr', function() { 206 209 $( this ).find( '.found-radio input' ).prop( 'checked', true ); 207 210 }); 211 212 /** 213 * Handles media list copy media URL button. 214 * 215 * @since 6.0 216 * 217 * @param {MouseEvent} event A click event. 218 * @return {void} 219 */ 220 copyAttachmentURLClipboard.on( 'success', function( event ) { 221 var triggerElement = $( event.trigger ), 222 successElement = $( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) ); 223 224 // Clear the selection and move focus back to the trigger. 225 event.clearSelection(); 226 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 227 triggerElement.trigger( 'focus' ); 228 229 // Show success visual feedback. 230 clearTimeout( copyAttachmentURLSuccessTimeout ); 231 successElement.removeClass( 'hidden' ); 232 233 // Hide success visual feedback after 3 seconds since last success and unfocus the trigger. 234 copyAttachmentURLSuccessTimeout = setTimeout( function() { 235 successElement.addClass( 'hidden' ); 236 }, 3000 ); 237 238 // Handle success audible feedback. 239 wp.a11y.speak( wp.i18n.__( 'The file URL has been copied to your clipboard' ) ); 240 } ); 208 241 }); 209 242 })( jQuery ); -
src/wp-admin/css/list-tables.css
384 384 margin-bottom: 0.2em; 385 385 } 386 386 387 /* Media Copy to clipboard row action */ 388 .media .row-actions .copy-to-clipboard-container { 389 display: inline; 390 position: relative; 391 } 392 393 .media .row-actions .copy-to-clipboard-container .success { 394 position: absolute; 395 left: 50%; 396 transform: translate(-50%, -100%); 397 background: #000; 398 color: #fff; 399 border-radius: 5px; 400 margin: 0; 401 padding: 2px 5px; 402 } 403 387 404 /* @todo: pick a consistent list table selector */ 388 405 .wp-list-table a { 389 406 transition: none; -
src/wp-admin/includes/class-wp-media-list-table.php
806 806 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), 807 807 __( 'View' ) 808 808 ); 809 810 $actions['copy'] = sprintf( 811 '<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>', 812 esc_url( wp_get_attachment_url( $post->ID ) ), 813 /* translators: %s: Attachment title. */ 814 esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ), 815 __( 'Copy URL to clipboard' ), 816 __( 'Copied!' ) 817 ); 809 818 } 810 819 } 811 820 -
src/wp-includes/script-loader.php
1351 1351 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); 1352 1352 1353 1353 $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); 1354 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );1354 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 ); 1355 1355 $scripts->set_translations( 'media' ); 1356 1356 1357 1357 $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 );