From 05bb106161f9708b0bcc583652469f51be578dcb Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 3 Aug 2014 19:39:58 +0000 Subject: [PATCH] Media Grid: don't blow away the Attachment Details modal every time a new model is loaded. Props ericlewis. Fixes #29104. git-svn-id: https://develop.svn.wordpress.org/trunk@29368 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-grid.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js index 1c283c2c30..0c912fb5c4 100644 --- a/src/wp-includes/js/media-grid.js +++ b/src/wp-includes/js/media-grid.js @@ -478,18 +478,17 @@ }, /** - * Close this modal and immediately open another one. - * - * Allows for quickly swapping out the attachment being edited. + * Rerender the view. */ - resetContent: function() { - this.modal.close(); - wp.media( { - frame: 'edit-attachments', - gridRouter: this.gridRouter, - library: this.library, - model: this.model - } ); + rerender: function() { + // Only rerender the `content` region. + if ( this.content.mode() !== 'edit-metadata' ) { + this.content.mode( 'edit-metadata' ); + } else { + this.content.render(); + } + this.$('.left').toggleClass( 'disabled', ! this.hasPrevious() ); + this.$('.right').toggleClass( 'disabled', ! this.hasNext() ); }, /** @@ -500,7 +499,8 @@ return; } this.model = this.library.at( this.getCurrentIndex() - 1 ); - this.resetContent(); + + this.rerender(); }, /** @@ -511,7 +511,8 @@ return; } this.model = this.library.at( this.getCurrentIndex() + 1 ); - this.resetContent(); + + this.rerender(); }, getCurrentIndex: function() {