From 3ebb9b4538ea3db29d1821def244033dc0e07df2 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Tue, 11 Sep 2012 21:21:32 +0000 Subject: [PATCH] Media JS: When adding a view to a media workflow, add a shorthand for registering a view constructor with no options. see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@21821 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-views.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 48518cac57..a8cc75758b 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -31,13 +31,13 @@ this.modal = new media.view.Modal({ controller: this }); // Add default views. - this.add( 'library', { - view: media.view.Workspace - }); + this.add( 'library', media.view.Workspace ); }, - // Accepts an `id` and `options` for a view. Options is an object that + // Accepts an `id` and `options` for a view. + // + // `options` is either a `Backbone.View` constructor or an object that // contains two keys: the `view` key is a `Backbone.View` constructor, // and the `options` key are the options to be passed when the view is // initialized. @@ -45,6 +45,8 @@ // Triggers the `add` and `add:VIEW_ID` events. add: function( id, options ) { this.remove( id ); + if ( _.isFunction( options ) ) + options = { view: options }; this._pending[ id ] = options; this.trigger( 'add add:' + id, options ); return this;