From e52c72c366a30cfc2ffaacf20a3db6a97294d7b4 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 11 Jul 2014 05:21:04 +0000 Subject: [PATCH] Media Grid: * The "Edit Image" link in the attachment modal details is redundant. * After an attachment is deleted in the modal, automatically move to the next attachment in the library. If there are no attachments left, close the modal. See #24716. git-svn-id: https://develop.svn.wordpress.org/trunk@29085 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-grid.js | 29 +++++++++++++++++++++++++++++ src/wp-includes/media-template.php | 5 ----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js index 60261ef4b3..c23d1350f1 100644 --- a/src/wp-includes/js/media-grid.js +++ b/src/wp-includes/js/media-grid.js @@ -303,6 +303,35 @@ // Update the selection. this.model.on( 'add', this.select, this ); this.model.on( 'remove', this.deselect, this ); + this.model.on( 'sync', this.afterDelete, this ); + }, + + deleteAttachment: function( event ) { + event.preventDefault(); + + this.lastIndex = this.controller.getCurrentIndex(); + this.hasNext = this.controller.hasNext(); + + media.view.Attachment.Details.prototype.deleteAttachment.apply( this, arguments ); + }, + + afterDelete: function( model ) { + if ( ! model.destroyed ) { + return; + } + + var frame = this.controller, index = this.lastIndex; + + if ( ! frame.library.length ) { + media.frame.modal.close(); + return; + } + + if ( this.hasNext ) { + index -= 1; + } + frame.model = frame.library.at( index ); + frame.nextMediaItem(); }, render: function() { diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 6830bfe9e8..e730d4ab7c 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -290,11 +290,6 @@ function wp_print_media_templates() { <# if ( data.width && data.height ) { #>
{{ data.width }} × {{ data.height }}
<# } #> - - <# if ( data.can.save ) { #> - - - <# } #> <# } #> <# if ( data.fileLength ) { #>