Ensure the correct model is selected when editing an image from gallery mode. props gcorne. fixes #27363.

git-svn-id: https://develop.svn.wordpress.org/trunk@27517 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2014-03-12 22:04:56 +00:00
parent 5f936ab3dd
commit 14615cd317
1 changed files with 12 additions and 20 deletions

View File

@ -1139,16 +1139,11 @@
menu: false,
toolbar: 'edit-image',
title: l10n.editImage,
content: 'edit-image',
syncSelection: true
content: 'edit-image'
},
activate: function() {
if ( ! this.get('selection') ) {
this.set( 'selection', new media.model.Selection() );
}
this.listenTo( this.frame, 'toolbar:render:edit-image', this.toolbar );
this.syncSelection();
},
deactivate: function() {
@ -1180,8 +1175,6 @@
}
});
_.extend( media.controller.EditImage.prototype, media.selectionSync );
/**
* wp.media.controller.MediaLibrary
*
@ -1980,7 +1973,7 @@
// Embed states.
new media.controller.Embed(),
new media.controller.EditImage( { selection: options.selection } ),
new media.controller.EditImage( { model: options.editImage } ),
// Gallery states.
new media.controller.CollectionEdit({
@ -2251,8 +2244,8 @@
},
editImageContent: function() {
var selection = this.state().get('selection'),
view = new media.view.EditImage( { model: selection.single(), controller: this } ).render();
var image = this.state().get('image'),
view = new media.view.EditImage( { model: image, controller: this } ).render();
this.content.set( view );
@ -2648,18 +2641,11 @@
editImageContent: function() {
var state = this.state(),
attachment = state.get('image').attachment,
model,
model = state.get('image'),
view;
if ( ! attachment ) {
return;
}
model = state.get('selection').single();
if ( ! model ) {
model = attachment;
return;
}
view = new media.view.EditImage( { model: model, controller: this } ).render();
@ -6072,7 +6058,10 @@
* @param {Object} event
*/
editAttachment: function( event ) {
var editState = this.controller.state( 'edit-image' );
event.preventDefault();
editState.set( 'image', this.model );
this.controller.setState( 'edit-image' );
},
/**
@ -6419,7 +6408,10 @@
},
editAttachment: function( event ) {
var editState = this.controller.state( 'edit-image' );
event.preventDefault();
editState.set( 'image', this.model.attachment );
this.controller.setState( 'edit-image' );
}
});