From fd40ade3fb6c211933ac1aaa60f9e55361d424ab Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Tue, 18 Sep 2012 22:41:51 +0000 Subject: [PATCH] Media JS: Improve signature for `Workspace.add()` to accept two arguments instead of an ambiguous object. see #21390, [21820], [21821]. git-svn-id: https://develop.svn.wordpress.org/trunk@21901 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 953aabaf87..7b90d9f687 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -35,20 +35,20 @@ }, - // Accepts an `id` and `options` for a view. + // Registers 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. + // `id` is a unique ID for the view relative to the workflow instance. + // `constructor` is a `Backbone.View` constructor. `options` are the + // options to be passed when the view is initialized. // // Triggers the `add` and `add:VIEW_ID` events. - add: function( id, options ) { + add: function( id, constructor, options ) { this.remove( id ); - if ( _.isFunction( options ) ) - options = { view: options }; - this._pending[ id ] = options; - this.trigger( 'add add:' + id, options ); + this._pending[ id ] = { + view: constructor, + options: options + }; + this.trigger( 'add add:' + id, constructor, options ); return this; },