Make WordPress Core

Changeset 21821


Ignore:
Timestamp:
09/11/2012 09:21:32 PM (12 years ago)
Author:
koopersmith
Message:

Media JS: When adding a view to a media workflow, add a shorthand for registering a view constructor with no options. see #21390.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-views.js

    r21820 r21821  
    3232
    3333            // Add default views.
    34             this.add( 'library', {
    35                 view: media.view.Workspace
    36             });
    37         },
    38 
    39 
    40         // Accepts an `id` and `options` for a view. Options is an object that
     34            this.add( 'library', media.view.Workspace );
     35        },
     36
     37
     38        // Accepts an `id` and `options` for a view.
     39        //
     40        // `options` is either a `Backbone.View` constructor or an object that
    4141        // contains two keys: the `view` key is a `Backbone.View` constructor,
    4242        // and the `options` key are the options to be passed when the view is
     
    4646        add: function( id, options ) {
    4747            this.remove( id );
     48            if ( _.isFunction( options ) )
     49                options = { view: options };
    4850            this._pending[ id ] = options;
    4951            this.trigger( 'add add:' + id, options );
Note: See TracChangeset for help on using the changeset viewer.