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

Built from https://develop.svn.wordpress.org/trunk@27517


git-svn-id: http://core.svn.wordpress.org/trunk@27360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2014-03-12 22:05:15 +00:00
parent 9aafd2294d
commit 326f49688f
2 changed files with 15 additions and 23 deletions

View File

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

File diff suppressed because one or more lines are too long