equal
deleted
inserted
replaced
8 * @namespace findPosts |
8 * @namespace findPosts |
9 * |
9 * |
10 * @requires jQuery |
10 * @requires jQuery |
11 */ |
11 */ |
12 |
12 |
13 /* global ajaxurl, _wpMediaGridSettings, showNotice, findPosts */ |
13 /* global ajaxurl, _wpMediaGridSettings, showNotice, findPosts, ClipboardJS */ |
14 |
14 |
15 ( function( $ ){ |
15 ( function( $ ){ |
16 window.findPosts = { |
16 window.findPosts = { |
17 /** |
17 /** |
18 * Opens a dialog to attach media to a post. |
18 * Opens a dialog to attach media to a post. |
139 * various form elements. |
139 * various form elements. |
140 * |
140 * |
141 * @return {void} |
141 * @return {void} |
142 */ |
142 */ |
143 $( function() { |
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 // Opens a manage media frame into the grid. |
149 // Opens a manage media frame into the grid. |
147 if ( $mediaGridWrap.length && window.wp && window.wp.media ) { |
150 if ( $mediaGridWrap.length && window.wp && window.wp.media ) { |
148 settings = _wpMediaGridSettings; |
151 settings = _wpMediaGridSettings; |
149 |
152 |
203 * @return {void} |
206 * @return {void} |
204 */ |
207 */ |
205 $( '.find-box-inside' ).on( 'click', 'tr', function() { |
208 $( '.find-box-inside' ).on( 'click', 'tr', function() { |
206 $( this ).find( '.found-radio input' ).prop( 'checked', true ); |
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.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 })( jQuery ); |
242 })( jQuery ); |