backbone-baseview.js
function (name, instance, singleton) {
            var arr = (isArray(name)) ? name : (isArray(instance)) ? instance : undefined; // If its a simple array of subviews or configs
            var map = (!arr && isObject(name) && name instanceof View === false) ? name : undefined; // If its a mapping of subviews
            var viewOptions = (!arr && instance instanceof View === false) ? instance : undefined;
            var key;
            var i;
            var len;

            if (map) {
                singleton = (typeof instance === 'boolean') ? instance : undefined;
                for (key in map) {
                    if (map.hasOwnProperty(key)) {
                        map[key] = (isArray(map[key])) ? map[key] : [map[key]];
                        len = map[key].length;
                        if (len && map[key][0] instanceof View) {
                            this._addInstance(key, map[key], singleton);
                        } else {
                            i = -1;
                            while (++i < len) {
                                this._init(key, map[key][i], singleton);
                            }
                        }
                    }
                }
                return this;
            }

            instance = (name instanceof View) ? name : instance;
            name = (typeof name === 'string' || typeof name === "number") ? name : undefined;
            singleton = (typeof singleton === 'boolean') ? singleton :
                    (!name && typeof instance === 'boolean') ? instance : undefined;

            if (viewOptions) {
                this._init(name, viewOptions, singleton);
                return this;
            }

            if (arr && (len = arr.length)) { //eslint-disable-line no-cond-assign
                if (arr[0] instanceof View) {
                    this._addInstance(name, arr, singleton);
                } else {
                    i = -1;
                    while (++i < len) {
                        this._init(name, arr[i], singleton);
                    }
                }

                return this;
            }

            if (instance) {
                this._addInstance(name, instance, singleton);
            } else if (name) {
                this._init(name, singleton);
            }
            return this;
        }
function (name, instance, singleton) {
            var arr = (isArray(name)) ? name : (isArray(instance)) ? instance : undefined; // If its a simple array of subviews or configs
            var map = (!arr && isObject(name) && name instanceof View === false) ? name : undefined; // If its a mapping of subviews
            var viewOptions = (!arr && instance instanceof View === false) ? instance : undefined;
            var key;
            var i;
            var len;

            if (map) {
                singleton = (typeof instance === 'boolean') ? instance : undefined;
                for (key in map) {
                    if (map.hasOwnProperty(key)) {
                        map[key] = (isArray(map[key])) ? map[key] : [map[key]];
                        len = map[key].length;
                        if (len && map[key][0] instanceof View) {
                            this._addInstance(key, map[key], singleton);
                        } else {
                            i = -1;
                            while (++i < len) {
                                this._init(key, map[key][i], singleton);
                            }
                        }
                    }
                }
                return this;
            }

            instance = (name instanceof View) ? name : instance;
            name = (typeof name === 'string' || typeof name === "number") ? name : undefined;
            singleton = (typeof singleton === 'boolean') ? singleton :
                    (!name && typeof instance === 'boolean') ? instance : undefined;

            if (viewOptions) {
                this._init(name, viewOptions, singleton);
                return this;
            }

            if (arr && (len = arr.length)) { //eslint-disable-line no-cond-assign
                if (arr[0] instanceof View) {
                    this._addInstance(name, arr, singleton);
                } else {
                    i = -1;
                    while (++i < len) {
                        this._init(name, arr[i], singleton);
                    }
                }

                return this;
            }

            if (instance) {
                this._addInstance(name, instance, singleton);
            } else if (name) {
                this._init(name, singleton);
            }
            return this;
        }
function ( name , instance , singleton ) { var arr = ( isArray ( name ) ) ? name : ( isArray ( instance ) ) ? instance : undefined ; // If its a simple array of subviews or configs var map = ( ! arr && isObject ( name ) && name instanceof View === false ) ? name : undefined ; // If its a mapping of subviews var viewOptions = ( ! arr && instance instanceof View === false ) ? instance : undefined ; var key ; var i ; var len ; if ( map ) { singleton = ( typeof instance === 'boolean' ) ? instance : undefined ; for ( key in map ) { if ( map . hasOwnProperty ( key ) ) { map [ key ] = ( isArray ( map [ key ] ) ) ? map [ key ] : [ map [ key ] ] ; len = map [ key ] . length ; if ( len && map [ key ] [ 0 ] instanceof View ) { this . _addInstance ( key , map [ key ] , singleton ) ; } else { i = - 1 ; while ( ++ i < len ) { this . _init ( key , map [ key ] [ i ] , singleton ) ; } } } } return this ; } instance = ( name instanceof View ) ? name : instance ; name = ( typeof name === 'string' || typeof name === "number" ) ? name : undefined ; singleton = ( typeof singleton === 'boolean' ) ? singleton : ( ! name && typeof instance === 'boolean' ) ? instance : undefined ; if ( viewOptions ) { this . _init ( name , viewOptions , singleton ) ; return this ; } if ( arr && ( len = arr . length ) ) { //eslint-disable-line no-cond-assign if ( arr [ 0 ] instanceof View ) { this . _addInstance ( name , arr , singleton ) ; } else { i = - 1 ; while ( ++ i < len ) { this . _init ( name , arr [ i ] , singleton ) ; } } return this ; } if ( instance ) { this . _addInstance ( name , instance , singleton ) ; } else if ( name ) { this . _init ( name , singleton ) ; } return this ; }
Adds a subView or subViews to the View's list of subViews. Calling
function must provide instances of views or configurations.
@memberOf SubViewManager#
@class SubViewManager
@type {SubViewManager}
@method add
@param {Object} map
An object with key's to refer to subViews and values that
are View instances, options to pass to the constructor, or
an array of either the previous two to add multiple subViews.
If you pass options or an array of options, the SubViewManager
will look for a configuration matching the key for these options
and will initialize subviews based on the config, passing options
to the constructor.
@param {Boolean} [singleton]
True if the instances mapped to the keys should be singletons.
If you pass options, the singleton param will be ignored.
@return {SubViewManager}
 
Adds a subView or subViews to the View's list of subViews. Calling
function must provide instances of views or configurations.
@memberOf SubViewManager#
@type {SubViewManager}
@method add
@param {String} name
A string key to refer to the subViews with. Should match
a key in the subView configuration. If not, a configuration
will be set up with default values based on the instance
passed.
@param {Backbone.View[]|object[]} arr
An array of View instances or options. Instances will be
appropriately associated with the key, options will be
used to instantiate a subView based on the configuration
matching the key
@param {Boolean} [singleton]
True if the added views should be singletons
@return {SubViewManager}
 
Adds a subView or subViews to the View's list of subViews. Calling
function must provide instances of views or configurations.
@memberOf SubViewManager#
@type {SubViewManager}
@method add
@param {Backbone.View[]} arr
An array of View instances. These will not be accessible
by a type or key
@return {SubViewManager}
 
Adds a subView or subViews to the View's list of subViews. Calling
function must provide instances of views or configurations.
@memberOf SubViewManager#
@type {SubViewManager}
@method add
@param {String} name
A string key to refer to the subView with
@param {Backbone.View} instance
A View instance
@param {Object} [singleton]
If you want the view matching this key to be a singleton
@return {SubViewManager}
 
Adds a subView or subViews to the View's list of subViews. Calling
function must provide instances of views or configurations.
@memberOf SubViewManager#
@type {SubViewManager}
@method add
@param {String} name
A string key to refer to the subView with. Without an instance
as the second param, this variant requires that a configuration
to have been specified matching the 'name' with a constructor to
initialize.
@param {Object} [options]
An object that will be passed as the options parameter to the
view on initialization.
@return {SubViewManager}
 
Adds a subView or subViews to the View's list of subViews. Calling
function must provide instances of views or configurations.
@memberOf SubViewManager#
@type {SubViewManager}
@method add
@param {Backbone.View} instance
A Backbone.View instance to add as the subview
@return {SubViewManager}
Adds a subView or subViews to the View s list of subViews . Calling function must provide instances of views or configurations .