Ticket #48463: 48463.patch
File 48463.patch, 3.8 KB (added by , 5 years ago) |
---|
-
src/js/media/views/attachment/details.js
23 23 'click .trash-attachment': 'trashAttachment', 24 24 'click .untrash-attachment': 'untrashAttachment', 25 25 'click .edit-attachment': 'editAttachment', 26 'click .copy-attachment-url': 'copyAttachmentLink', 26 27 'keydown': 'toggleSelectionHandler' 27 28 }, 28 29 29 30 /** 31 * Copies the attachment link to the clipboard. 32 * 33 * Browser support for Chrome 43+, Firefox 42+, Safari 10+, Edge and Internet Explorer 10+ 34 * 35 * @since 5.2.0 36 * 37 * @param {MouseEvent} event A click event. 38 * 39 * @returns {void} 40 */ 41 copyAttachmentLink: function( event ) { 42 43 var successful = false; 44 45 // Copy Link Label 46 var AttachmentLinkLabel = document.querySelector( 'label.name.copy-attachment-url' ); 47 48 // Attachment Input 49 var AttachmentLink = document.querySelector( '#attachment-details-two-column-copy-link' ); 50 51 // Set the focus to the input 52 AttachmentLink.focus(); 53 54 // Select the input text 55 AttachmentLink.select(); 56 57 // especially for IE 58 if (window.clipboardData && window.clipboardData.setData) { 59 60 successful = clipboardData.setData( "Text", AttachmentLink.value ); 61 62 } 63 // checking for browser support 64 else if ( document.queryCommandSupported && document.queryCommandSupported( "copy" ) ) { 65 66 try { 67 68 // process the 'copy' cmd 69 var successful = document.execCommand( 'copy' ); 70 71 // let user know copy didn't happen 72 } catch ( err ) { 73 74 alert( 'Sorry, unable to copy', err ); 75 } 76 } 77 78 // copy did successfully completed 79 if ( successful ) { 80 81 // show 'Link Copied' text 1s animation 82 AttachmentLinkLabel.classList.add("copied"); 83 84 // remove 'Link Copied' text after 2s 85 setTimeout(function(){ 86 87 AttachmentLinkLabel.classList.remove("copied"); 88 89 }, 2000 ); 90 } 91 }, 92 93 /** 30 94 * Shows the details of an attachment. 31 95 * 32 96 * @since 3.5.0 -
src/wp-admin/css/media.css
1281 1281 max-width: 100%; 1282 1282 } 1283 1283 } 1284 1285 @keyframes showCopiedText { 1286 0% { 1287 opacity: 0; 1288 } 1289 100% { 1290 opacity: 1; 1291 } 1292 } 1293 1294 label.name.copy-attachment-url.copied:before { 1295 position: absolute; 1296 content: 'Link Copied!'; 1297 bottom: 30px; 1298 left: 5px; 1299 color: white; 1300 background: green; 1301 padding: 2px 8px; 1302 border-radius: 3px; 1303 -webkit-animation: showCopiedText 1s normal forwards; 1304 -moz-animation: showCopiedText 1s normal forwards; 1305 -o-animation: showCopiedText 1s normal forwards; 1306 animation: showCopiedText 1s normal forwards; 1307 } 1308 No newline at end of file -
src/wp-includes/media-template.php
501 501 </span> 502 502 <# } #> 503 503 <span class="setting" data-setting="url"> 504 <label for="attachment-details-two-column-copy-link" class="name "><?php _e( 'Copy Link' ); ?></label>504 <label for="attachment-details-two-column-copy-link" class="name copy-attachment-url"><?php _e( 'Copy Link' ); ?></label> 505 505 <input type="text" id="attachment-details-two-column-copy-link" value="{{ data.url }}" readonly /> 506 506 </span> 507 507 <div class="attachment-compat"></div>