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: https://develop.svn.wordpress.org/trunk@21821 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
304569a26c
commit
60ee5a5032
@ -31,13 +31,13 @@
|
|||||||
this.modal = new media.view.Modal({ controller: this });
|
this.modal = new media.view.Modal({ controller: this });
|
||||||
|
|
||||||
// Add default views.
|
// Add default views.
|
||||||
this.add( 'library', {
|
this.add( 'library', media.view.Workspace );
|
||||||
view: 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,
|
// 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
|
// and the `options` key are the options to be passed when the view is
|
||||||
// initialized.
|
// initialized.
|
||||||
@ -45,6 +45,8 @@
|
|||||||
// Triggers the `add` and `add:VIEW_ID` events.
|
// Triggers the `add` and `add:VIEW_ID` events.
|
||||||
add: function( id, options ) {
|
add: function( id, options ) {
|
||||||
this.remove( id );
|
this.remove( id );
|
||||||
|
if ( _.isFunction( options ) )
|
||||||
|
options = { view: options };
|
||||||
this._pending[ id ] = options;
|
this._pending[ id ] = options;
|
||||||
this.trigger( 'add add:' + id, options );
|
this.trigger( 'add add:' + id, options );
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user