From 6fff91f4d1ddba08752997877be7ef822c777c18 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Thu, 27 Sep 2012 06:20:22 +0000 Subject: [PATCH] Media JS: Move the modal box's title from being stored in the modal view to being stored as an attribute on the workflow. Update modal titles for both the post media and featured image workflows. see #21390, #21776. git-svn-id: https://develop.svn.wordpress.org/trunk@22044 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/meta-boxes.php | 2 +- wp-admin/js/media-upload.js | 1 + wp-includes/js/media-views.js | 10 +++------- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index 98bea084b0..f099627336 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -1031,6 +1031,7 @@ function post_thumbnail_meta_box( $post ) { if ( ! workflow ) { workflow = wp.media({ + title: title, library: { type: 'image' } @@ -1058,7 +1059,6 @@ function post_thumbnail_meta_box( $post ) { width: size.width }).prependTo( $element ); }); - workflow.modal.title( title ); } workflow.modal.open(); diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index 16f0a6e26e..bb1815505c 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -103,6 +103,7 @@ var tb_position; return workflow; workflow = workflows[ id ] = wp.media( _.defaults( options || {}, { + title: wp.media.view.l10n.insertMedia, multiple: true } ) ); diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index aaac41e364..aea5d929e3 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -19,6 +19,7 @@ */ media.controller.Workflow = Backbone.Model.extend({ defaults: { + title: '', multiple: false, view: 'library', library: {}, @@ -193,9 +194,9 @@ initialize: function() { this.controller = this.options.controller; + this.controller.on( 'change:title', this.render, this ); _.defaults( this.options, { - title: '', container: document.body }); }, @@ -208,7 +209,7 @@ // `this.$el.html()` from garbage collecting its events. this.options.$content.detach(); - this.$el.html( this.template( this.options ) ); + this.$el.html( this.template( this.controller.toJSON() ) ); this.$('.media-modal-content').append( this.options.$content ); return this; }, @@ -242,11 +243,6 @@ // Set and render the content. this.options.$content = ( $content instanceof Backbone.View ) ? $content.$el : $content; return this.render(); - }, - - title: function( title ) { - this.options.title = title; - return this.render(); } });