Changeset 48232
- Timestamp:
- 06/30/2020 01:14:05 PM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/post.js
r48168 r48232 5 5 */ 6 6 7 /* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting */7 /* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */ 8 8 /* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */ 9 9 /* global WPSetThumbnailHTML, wptitlehint */ … … 298 298 $timestampdiv = $('#timestampdiv'), 299 299 $postStatusSelect = $('#post-status-select'), 300 isMac = window.navigator.platform ? window.navigator.platform.indexOf( 'Mac' ) !== -1 : false; 300 isMac = window.navigator.platform ? window.navigator.platform.indexOf( 'Mac' ) !== -1 : false, 301 copyAttachmentURLClipboard = new ClipboardJS( '.copy-attachment-url.edit-media' ), 302 copyAttachmentURLSuccessTimeout, 303 __ = wp.i18n.__; 301 304 302 305 postboxes.add_postbox_toggles(pagenow); … … 1218 1221 }); 1219 1222 } 1220 }); 1223 1224 /** 1225 * Copies the attachment URL in the Edit Media page to the clipboard. 1226 * 1227 * @since 5.5.0 1228 * 1229 * @param {MouseEvent} event A click event. 1230 * 1231 * @returns {void} 1232 */ 1233 copyAttachmentURLClipboard.on( 'success', function( event ) { 1234 var triggerElement = $( event.trigger ), 1235 successElement = $( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) ); 1236 1237 // Clear the selection and move focus back to the trigger. 1238 event.clearSelection(); 1239 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 1240 triggerElement.focus(); 1241 1242 // Show success visual feedback. 1243 clearTimeout( copyAttachmentURLSuccessTimeout ); 1244 successElement.removeClass( 'hidden' ); 1245 1246 // Hide success visual feedback after 3 seconds since last success. 1247 copyAttachmentURLSuccessTimeout = setTimeout( function() { 1248 successElement.addClass( 'hidden' ); 1249 }, 3000 ); 1250 1251 // Handle success audible feedback. 1252 wp.a11y.speak( __( 'The file URL has been copied to your clipboard' ) ); 1253 } ); 1254 } ); 1221 1255 1222 1256 /** -
trunk/src/js/media/views/attachment/details.js
r47233 r48232 1 /* global ClipboardJS */ 1 2 var Attachment = wp.media.view.Attachment, 2 3 l10n = wp.media.view.l10n, 3 4 $ = jQuery, 4 Details; 5 Details, 6 __ = wp.i18n.__; 5 7 6 8 Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototype */{ … … 28 30 29 31 /** 32 * Copies the attachment URL to the clipboard. 33 * 34 * @since 5.5.0 35 * 36 * @param {MouseEvent} event A click event. 37 * 38 * @returns {void} 39 */ 40 copyAttachmentDetailsURLClipboard: function() { 41 var clipboard = new ClipboardJS( '.copy-attachment-url' ), 42 successTimeout; 43 44 clipboard.on( 'success', function( event ) { 45 var triggerElement = $( event.trigger ), 46 successElement = $( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) ); 47 48 // Clear the selection and move focus back to the trigger. 49 event.clearSelection(); 50 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 51 triggerElement.focus(); 52 53 // Show success visual feedback. 54 clearTimeout( successTimeout ); 55 successElement.removeClass( 'hidden' ); 56 57 // Hide success visual feedback after 3 seconds since last success. 58 successTimeout = setTimeout( function() { 59 successElement.addClass( 'hidden' ); 60 }, 3000 ); 61 62 // Handle success audible feedback. 63 wp.a11y.speak( __( 'The file URL has been copied to your clipboard' ) ); 64 } ); 65 }, 66 67 /** 30 68 * Shows the details of an attachment. 31 69 * … … 44 82 // Call 'initialize' directly on the parent class. 45 83 Attachment.prototype.initialize.apply( this, arguments ); 84 85 this.copyAttachmentDetailsURLClipboard(); 46 86 }, 47 87 -
trunk/src/wp-admin/css/media.css
r47418 r48232 798 798 } 799 799 800 .copy-to-clipboard-container { 801 display: flex; 802 align-items: center; 803 margin-top: 8px; 804 clear: both; 805 } 806 807 .copy-to-clipboard-container .success { 808 margin-left: 8px; 809 } 800 810 801 811 /*------------------------------------------------------------------------------ … … 1216 1226 max-width: none; 1217 1227 } 1228 1229 .copy-to-clipboard-container .success { 1230 font-size: 14px; 1231 } 1218 1232 } 1219 1233 -
trunk/src/wp-admin/includes/media.php
r48199 r48232 3269 3269 <label for="attachment_url"><?php _e( 'File URL:' ); ?></label> 3270 3270 <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" /> 3271 <span class="copy-to-clipboard-container"> 3272 <button type="button" class="button copy-attachment-url edit-media" data-clipboard-target="#attachment_url"><?php _e( 'Copy URL' ); ?></button> 3273 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 3274 </span> 3271 3275 </div> 3272 3276 <div class="misc-pub-section misc-pub-filename"> -
trunk/src/wp-includes/css/buttons.css
r47771 r48232 355 355 } 356 356 357 /* Copy attachment URL button in the legacy edit media page. */ 358 .wp-core-ui .copy-to-clipboard-container .copy-attachment-url { 359 margin-bottom: 0; 360 } 361 357 362 #media-upload.wp-core-ui .button { 358 363 padding: 0 10px 1px; -
trunk/src/wp-includes/css/media-views.css
r47549 r48232 458 458 } 459 459 460 .media-sidebar .copy-to-clipboard-container, 461 .attachment-details .copy-to-clipboard-container { 462 flex-wrap: wrap; 463 margin-top: 10px; 464 margin-left: calc( 35% - 1px ); 465 padding-top: 10px; 466 } 467 468 /* Needs high specificity. */ 469 .attachment-details .attachment-info .copy-to-clipboard-container { 470 float: none; 471 } 472 473 .media-sidebar .copy-to-clipboard-container .success, 474 .attachment-details .copy-to-clipboard-container .success { 475 padding: 0; 476 min-height: 0; 477 text-align: left; 478 } 479 460 480 .compat-item label span { 461 481 text-align: right; … … 2540 2560 } 2541 2561 2562 /* Needs high specificity. */ 2563 .media-sidebar .setting .copy-to-clipboard-container, 2564 .attachment-details .attachment-info .copy-to-clipboard-container { 2565 margin-left: 0; 2566 padding-top: 0; 2567 } 2568 2569 .media-sidebar .setting .copy-attachment-url, 2570 .attachment-details .attachment-info .copy-attachment-url { 2571 margin: 0 1px; 2572 } 2573 2542 2574 .media-sidebar .setting .value, 2543 2575 .attachment-details .setting .value { … … 2713 2745 bottom: -54px; 2714 2746 } 2715 } 2716 2717 @media screen and (max-width: 782px) { 2747 2718 2748 .mode-grid .attachments-browser .media-toolbar-primary { 2719 2749 display: block; 2750 } 2751 2752 .media-sidebar .copy-to-clipboard-container .success, 2753 .attachment-details .copy-to-clipboard-container .success { 2754 font-size: 14px; 2755 line-height: 2.71428571; 2720 2756 } 2721 2757 } -
trunk/src/wp-includes/media-template.php
r47808 r48232 501 501 <# } #> 502 502 <span class="setting" data-setting="url"> 503 <label for="attachment-details-two-column-copy-link" class="name"><?php _e( 'Copy Link' ); ?></label> 504 <input type="text" id="attachment-details-two-column-copy-link" value="{{ data.url }}" readonly /> 503 <label for="attachment-details-two-column-copy-link" class="name"><?php _e( 'File URL:' ); ?></label> 504 <input type="text" class="attachment-details-copy-link" id="attachment-details-two-column-copy-link" value="{{ data.url }}" readonly /> 505 <span class="copy-to-clipboard-container"> 506 <button type="button" class="button button-small copy-attachment-url" data-clipboard-target="#attachment-details-two-column-copy-link"><?php _e( 'Copy URL' ); ?></button> 507 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 508 </span> 505 509 </span> 506 510 <div class="attachment-compat"></div> … … 688 692 </span> 689 693 <span class="setting" data-setting="url"> 690 <label for="attachment-details-copy-link" class="name"><?php _e( 'Copy Link' ); ?></label> 691 <input type="text" id="attachment-details-copy-link" value="{{ data.url }}" readonly /> 694 <label for="attachment-details-copy-link" class="name"><?php _e( 'File URL:' ); ?></label> 695 <input type="text" class="attachment-details-copy-link" id="attachment-details-copy-link" value="{{ data.url }}" readonly /> 696 <div class="copy-to-clipboard-container"> 697 <button type="button" class="button button-small copy-attachment-url" data-clipboard-target="#attachment-details-copy-link"><?php _e( 'Copy URL' ); ?></button> 698 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 699 </div> 692 700 </span> 693 701 </script> -
trunk/src/wp-includes/script-loader.php
r48142 r48232 1233 1233 // To enqueue media-views or media-editor, call wp_enqueue_media(). 1234 1234 // Both rely on numerous settings, styles, and templates to operate correctly. 1235 $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'wp-i18n' ), false, 1 );1235 $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'wp-i18n', 'clipboard' ), false, 1 ); 1236 1236 $scripts->set_translations( 'media-views' ); 1237 1237 $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); … … 1295 1295 ); 1296 1296 1297 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize' ), false, 1 );1297 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize', 'clipboard', 'wp-i18n' ), false, 1 ); 1298 1298 did_action( 'init' ) && $scripts->localize( 1299 1299 'post',
Note: See TracChangeset
for help on using the changeset viewer.