Make WordPress Core

Changeset 22681


Ignore:
Timestamp:
11/19/2012 10:40:49 AM (14 years ago)
Author:
koopersmith
Message:

Media: Add documentation to media.Views. see #21390.

File:
1 edited

Legend:

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

    r22671 r22681  
    575575
    576576        _.extend( media.Views.prototype, {
     577                // ### Fetch all of the subviews
     578                //
     579                // Returns an array of all subviews.
    577580                all: function() {
    578581                        return _.flatten( this._views );
    579582                },
    580583
     584                // ### Get a selector's subviews
     585                //
     586                // Fetches all subviews that match a given `selector`.
     587                //
     588                // If no `selector` is provided, it will grab all subviews attached
     589                // to the view's root.
    581590                get: function( selector ) {
    582591                        selector = selector || '';
    … …  
    584593                },
    585594
     595                // ### Register subview(s)
     596                //
     597                // Registers any number of `views` to a `selector`.
     598                //
     599                // When no `selector` is provided, the root selector (the empty string)
     600                // is used. `views` accepts a `Backbone.View` instance or an array of
     601                // `Backbone.View` instances.
     602                //
     603                // Use `Views.add()` as a shortcut for setting `options.add` to `true`.
     604                //
     605                // Accepts an `options` object, which has a significant effect on the
     606                // resulting behavior. By default, the provided `views` will replace
     607                // any existing views associated with the selector. If `options.add`
     608                // is set to `true`, the provided `views` will be added to the existing
     609                // views. When adding, the `views` will added to the end of the array
     610                // by default. To insert `views` at a specific index, use `options.at`.
    586611                set: function( selector, views, options ) {
    587612                        var $selector, els, existing, add, method;
    … …  
    639664                },
    640665
     666                // ### Add subview(s) to existing subviews
     667                //
     668                // An alias to `Views.set()`, which defaults `options.add` to true.
     669                //
     670                // Adds any number of `views` to a `selector`.
     671                //
     672                // When no `selector` is provided, the root selector (the empty string)
     673                // is used. `views` accepts a `Backbone.View` instance or an array of
     674                // `Backbone.View` instances.
     675                //
     676                // Use `Views.set()` when setting `options.add` to `false`.
     677                //
     678                // Accepts an `options` object. By default, provided `views` will be
     679                // inserted at the end of the array of existing views. To insert
     680                // `views` at a specific index, use `options.at`. For more information
     681                // on the `options` object, see `Views.set()`.
    641682                add: function( selector, views, options ) {
    642683                        return this.set( selector, views, _.extend({ add: true }, options ) );
    643684                },
    644685
     686                // ### Stop tracking subviews
     687                //
     688                // Stops tracking `views` registered to a `selector`. If no `views` are
     689                // set, then all of the `selector`'s subviews will be unregistered.
    645690                unset: function( selector, views ) {
    646691                        var existing;
    … …  
    659704                },
    660705
     706                // ### Detach all subviews
     707                //
     708                // Detaches all subviews from the DOM.
     709                //
     710                // Helps to preserve all subview events when re-rendering the master
     711                // view. Used in conjunction with `Views.render()`.
    661712                detach: function() {
    662713                        $( _.pluck( this.all(), 'el' ) ).detach();
    … …  
    664715                },
    665716
     717                // ### Render all subviews
     718                //
     719                // Renders all subviews. Used in conjunction with `Views.detach()`.
    666720                render: function() {
    667721                        var root = this._views[''];
    … …  
    678732                },
    679733
     734                // ### Dispose all subviews
     735                //
     736                // Triggers the `dispose()` method on all subviews. Resets the
     737                // internals of the views manager.
    680738                dispose: function() {
    681739                        delete this.parent;
    … …  
    687745                },
    688746
     747                // ### Replace a selector's subviews
     748                //
     749                // By default, sets the `$target` selector's html to the subview `els`.
     750                //
     751                // Can be overridden in subclasses.
    689752                replace: function( $target, els ) {
    690753                        $target.html( els );
    … …  
    692755                },
    693756
     757                // ### Insert subviews into a selector
     758                //
     759                // By default, appends the subview `els` to the end of the `$target`
     760                // selector. If `options.at` is set, inserts the subview `els` at the
     761                // provided index.
     762                //
     763                // Can be overridden in subclasses.
    694764                insert: function( $target, els, options ) {
    695765                        var at = options && options.at,
Note: See TracChangeset for help on using the changeset viewer.