WordPress.org

Make WordPress Core

Changeset 21901


Ignore:
Timestamp:
09/18/2012 10:41:51 PM (8 years ago)
Author:
koopersmith
Message:

Media JS: Improve signature for Workspace.add() to accept two arguments instead of an ambiguous object. see #21390, [21820], [21821].

File:
1 edited

Legend:

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

    r21898 r21901  
    3636
    3737
    38         // Accepts an `id` and `options` for a view.
     38        // Registers a view.
    3939        //
    40         // `options` is either a `Backbone.View` constructor or an object that
    41         // contains two keys: the `view` key is a `Backbone.View` constructor,
    42         // and the `options` key are the options to be passed when the view is
    43         // initialized.
     40        // `id` is a unique ID for the view relative to the workflow instance.
     41        // `constructor` is a `Backbone.View` constructor. `options` are the
     42        // options to be passed when the view is initialized.
    4443        //
    4544        // Triggers the `add` and `add:VIEW_ID` events.
    46         add: function( id, options ) {
     45        add: function( id, constructor, options ) {
    4746            this.remove( id );
    48             if ( _.isFunction( options ) )
    49                 options = { view: options };
    50             this._pending[ id ] = options;
    51             this.trigger( 'add add:' + id, options );
     47            this._pending[ id ] = {
     48                view:    constructor,
     49                options: options
     50            };
     51            this.trigger( 'add add:' + id, constructor, options );
    5252            return this;
    5353        },
Note: See TracChangeset for help on using the changeset viewer.