359 function wpFileExtensionError( up, file, message ) { |
359 function wpFileExtensionError( up, file, message ) { |
360 jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' ); |
360 jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' ); |
361 up.removeFile( file ); |
361 up.removeFile( file ); |
362 } |
362 } |
363 |
363 |
|
364 /** |
|
365 * Copies the attachment URL to the clipboard. |
|
366 * |
|
367 * @since 5.8.0 |
|
368 * |
|
369 * @param {MouseEvent} event A click event. |
|
370 * |
|
371 * @return {void} |
|
372 */ |
|
373 function copyAttachmentUploadURLClipboard() { |
|
374 var clipboard = new ClipboardJS( '.copy-attachment-url' ), |
|
375 successTimeout; |
|
376 |
|
377 clipboard.on( 'success', function( event ) { |
|
378 var triggerElement = jQuery( event.trigger ), |
|
379 successElement = jQuery( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) ); |
|
380 |
|
381 // Clear the selection and move focus back to the trigger. |
|
382 event.clearSelection(); |
|
383 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 |
|
384 triggerElement.trigger( 'focus' ); |
|
385 // Show success visual feedback. |
|
386 clearTimeout( successTimeout ); |
|
387 successElement.removeClass( 'hidden' ); |
|
388 // Hide success visual feedback after 3 seconds since last success. |
|
389 successTimeout = setTimeout( function() { |
|
390 successElement.addClass( 'hidden' ); |
|
391 }, 3000 ); |
|
392 // Handle success audible feedback. |
|
393 wp.a11y.speak( pluploadL10n.file_url_copied ); |
|
394 } ); |
|
395 } |
|
396 |
364 jQuery( document ).ready( function( $ ) { |
397 jQuery( document ).ready( function( $ ) { |
|
398 copyAttachmentUploadURLClipboard(); |
365 var tryAgainCount = {}; |
399 var tryAgainCount = {}; |
366 var tryAgain; |
400 var tryAgain; |
367 |
401 |
368 $( '.media-upload-form' ).bind( 'click.uploader', function( e ) { |
402 $( '.media-upload-form' ).bind( 'click.uploader', function( e ) { |
369 var target = $( e.target ), tr, c; |
403 var target = $( e.target ), tr, c; |
568 uploadStart(); |
602 uploadStart(); |
569 |
603 |
570 plupload.each( files, function( file ) { |
604 plupload.each( files, function( file ) { |
571 if ( file.type === 'image/heic' && up.settings.heic_upload_error ) { |
605 if ( file.type === 'image/heic' && up.settings.heic_upload_error ) { |
572 // Show error but do not block uploading. |
606 // Show error but do not block uploading. |
573 wpQueueError( pluploadL10n.unsupported_image ) |
607 wpQueueError( pluploadL10n.unsupported_image ); |
|
608 } else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) { |
|
609 // Disallow uploading of WebP images if the server cannot edit them. |
|
610 wpQueueError( pluploadL10n.noneditable_image ); |
|
611 up.removeFile( file ); |
|
612 return; |
574 } |
613 } |
575 |
614 |
576 fileQueued( file ); |
615 fileQueued( file ); |
577 }); |
616 }); |
578 |
617 |