Media: Update gallery editing to work with the new frame view. see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-10-31 21:43:59 +00:00
parent 08e68c1ec4
commit 62771d6824
3 changed files with 35 additions and 27 deletions

View File

@ -690,26 +690,29 @@ window.wp = window.wp || {};
},
edit: function() {
if ( ! wp.media.view || this.workflow )
if ( ! wp.media.view || this.frame )
return;
this.workflow = wp.media({
this.frame = wp.media({
state: 'gallery',
selection: this.attachments.models,
title: mceview.l10n.editGallery,
editing: true,
multiple: true
multiple: true,
selection: new wp.media.model.Selection( this.attachments.models, {
props: this.attachments.props.toJSON(),
multiple: true
})
});
// Create a single-use workflow. If the workflow is closed,
// Create a single-use frame. If the frame is closed,
// then detach it from the DOM and remove the reference.
this.workflow.on( 'close', function() {
this.workflow.detach();
delete this.workflow;
this.frame.on( 'close', function() {
this.frame.detach();
delete this.frame;
}, this );
// Update the `shortcode` and `attachments`.
this.workflow.on( 'update:gallery', function( selection ) {
this.frame.get('gallery').on( 'update', function( selection ) {
var view = mceview.get('gallery');
this.options.shortcode = view.gallery.shortcode( selection );

View File

@ -114,7 +114,7 @@
id: 'library',
multiple: false,
describe: false,
title: l10n.mediaLibrary
title: l10n.mediaLibraryTitle
},
initialize: function() {
@ -262,8 +262,9 @@
id: 'gallery',
multiple: false,
describe: true,
title: l10n.createGallery,
edge: 199
title: l10n.createGalleryTitle,
edge: 199,
editing: false
},
toolbar: function() {
@ -324,7 +325,8 @@
library: {},
modal: true,
multiple: false,
uploader: true
uploader: true,
editing: false
});
this.createSelection();
@ -379,7 +381,8 @@
multiple: this.options.multiple
}),
new media.controller.Gallery({
library: options.selection
library: options.selection,
editing: options.editing
})
]);
@ -824,9 +827,9 @@
controller = this.options.controller;
this.options.items = {
'update-gallery': {
update: {
style: 'primary',
text: editing ? l10n.updateGallery : l10n.insertGalleryIntoPost,
text: editing ? l10n.updateGallery : l10n.insertGallery,
priority: 40,
click: function() {
controller.close();
@ -836,12 +839,15 @@
}
},
'return-to-library': {
text: editing ? l10n.addImagesFromLibrary : l10n.returnToLibrary,
priority: -40,
cancel: {
text: l10n.cancel,
priority: -60,
click: function() {
this.controller.state('library');
if ( editing )
controller.close();
else
controller.state('library');
}
}
};

View File

@ -325,20 +325,19 @@ function wp_default_scripts( &$scripts ) {
// Generic
'insertMedia' => __( 'Insert Media' ),
'search' => __( 'Search' ),
'cancel' => __( 'Cancel' ),
'addImages' => __( 'Add images' ),
// Library
'mediaLibrary' => __( 'Media Library' ),
'mediaLibraryTitle' => __( 'Media Library' ),
'createNewGallery' => __( 'Create a new gallery' ),
'insertIntoPost' => __( 'Insert into post' ),
'addToGallery' => __( 'Add to gallery' ),
// Gallery
'createGallery' => __( 'Create Gallery' ),
'returnToLibrary' => __( 'Return to media library' ),
'continueEditingGallery' => __( 'Continue editing gallery' ),
'insertGalleryIntoPost' => __( 'Insert gallery into post' ),
'updateGallery' => __( 'Update gallery' ),
'addImagesFromLibrary' => __( 'Add images from media library' ),
'createGalleryTitle' => __( 'Create Gallery' ),
'insertGallery' => __( 'Insert gallery' ),
'updateGallery' => __( 'Update gallery' ),
) );
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );