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() { edit: function() {
if ( ! wp.media.view || this.workflow ) if ( ! wp.media.view || this.frame )
return; return;
this.workflow = wp.media({ this.frame = wp.media({
state: 'gallery', state: 'gallery',
selection: this.attachments.models,
title: mceview.l10n.editGallery, title: mceview.l10n.editGallery,
editing: true, 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. // then detach it from the DOM and remove the reference.
this.workflow.on( 'close', function() { this.frame.on( 'close', function() {
this.workflow.detach(); this.frame.detach();
delete this.workflow; delete this.frame;
}, this ); }, this );
// Update the `shortcode` and `attachments`. // 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'); var view = mceview.get('gallery');
this.options.shortcode = view.gallery.shortcode( selection ); this.options.shortcode = view.gallery.shortcode( selection );

View File

@ -114,7 +114,7 @@
id: 'library', id: 'library',
multiple: false, multiple: false,
describe: false, describe: false,
title: l10n.mediaLibrary title: l10n.mediaLibraryTitle
}, },
initialize: function() { initialize: function() {
@ -262,8 +262,9 @@
id: 'gallery', id: 'gallery',
multiple: false, multiple: false,
describe: true, describe: true,
title: l10n.createGallery, title: l10n.createGalleryTitle,
edge: 199 edge: 199,
editing: false
}, },
toolbar: function() { toolbar: function() {
@ -324,7 +325,8 @@
library: {}, library: {},
modal: true, modal: true,
multiple: false, multiple: false,
uploader: true uploader: true,
editing: false
}); });
this.createSelection(); this.createSelection();
@ -379,7 +381,8 @@
multiple: this.options.multiple multiple: this.options.multiple
}), }),
new media.controller.Gallery({ new media.controller.Gallery({
library: options.selection library: options.selection,
editing: options.editing
}) })
]); ]);
@ -824,9 +827,9 @@
controller = this.options.controller; controller = this.options.controller;
this.options.items = { this.options.items = {
'update-gallery': { update: {
style: 'primary', style: 'primary',
text: editing ? l10n.updateGallery : l10n.insertGalleryIntoPost, text: editing ? l10n.updateGallery : l10n.insertGallery,
priority: 40, priority: 40,
click: function() { click: function() {
controller.close(); controller.close();
@ -836,12 +839,15 @@
} }
}, },
'return-to-library': { cancel: {
text: editing ? l10n.addImagesFromLibrary : l10n.returnToLibrary, text: l10n.cancel,
priority: -40, priority: -60,
click: function() { 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 // Generic
'insertMedia' => __( 'Insert Media' ), 'insertMedia' => __( 'Insert Media' ),
'search' => __( 'Search' ), 'search' => __( 'Search' ),
'cancel' => __( 'Cancel' ),
'addImages' => __( 'Add images' ),
// Library // Library
'mediaLibrary' => __( 'Media Library' ), 'mediaLibraryTitle' => __( 'Media Library' ),
'createNewGallery' => __( 'Create a new gallery' ), 'createNewGallery' => __( 'Create a new gallery' ),
'insertIntoPost' => __( 'Insert into post' ), 'insertIntoPost' => __( 'Insert into post' ),
'addToGallery' => __( 'Add to gallery' ), 'addToGallery' => __( 'Add to gallery' ),
// Gallery // Gallery
'createGallery' => __( 'Create Gallery' ), 'createGalleryTitle' => __( 'Create Gallery' ),
'returnToLibrary' => __( 'Return to media library' ), 'insertGallery' => __( 'Insert gallery' ),
'continueEditingGallery' => __( 'Continue editing gallery' ), 'updateGallery' => __( 'Update gallery' ),
'insertGalleryIntoPost' => __( 'Insert gallery into post' ),
'updateGallery' => __( 'Update gallery' ),
'addImagesFromLibrary' => __( 'Add images from media library' ),
) ); ) );
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );