From 62771d68243ee706ac44dffaf27fee963cb44b68 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Wed, 31 Oct 2012 21:43:59 +0000 Subject: [PATCH] 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 --- wp-includes/js/mce-view.js | 21 ++++++++++++--------- wp-includes/js/media-views.js | 28 +++++++++++++++++----------- wp-includes/script-loader.php | 13 ++++++------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index afc66e5b61..7dae0993d3 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -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 ); diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 7d28fb88d8..d462df52b0 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -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'); } } }; diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 0393390365..ebc75a9faf 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -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 );