torso-bundle.js
function(viewOptions) {
      var view = this;
      if (!_.isEmpty(this.behaviors)) {
        view.__behaviorInstances = {};
        _.each(this.behaviors, function(behaviorDefinition, alias) {
          if (!_.has(behaviorDefinition, 'behavior')) {
            behaviorDefinition = {behavior: behaviorDefinition};
          }
          var BehaviorClass = behaviorDefinition.behavior;
          if (!(BehaviorClass && _.isFunction(BehaviorClass))) {
            throw new Error('Incorrect behavior definition. Expected key "behavior" to be a class but instead got ' +
              String(BehaviorClass));
          }

          var behaviorOptions = _.pick(behaviorDefinition, function(value, key) {
            return key !== 'behavior';
          });
          behaviorOptions.view = view;
          behaviorOptions.alias = alias;
          var behaviorAttributes = behaviorDefinition.attributes || {};
          var behaviorInstance = view.__behaviorInstances[alias] = new BehaviorClass(behaviorAttributes, behaviorOptions, viewOptions);
          // Add the behavior's mixin fields to the view's public API
          if (behaviorInstance.mixin) {
            var mixin = _.result(behaviorInstance, 'mixin');
            _.each(mixin, function(field, fieldName) {
              // Default to a view's field over a behavior mixin
              if (_.isUndefined(view[fieldName])) {
                if (_.isFunction(field)) {
                  // Behavior mixin functions will be behavior-scoped - the context will be the behavior.
                  view[fieldName] = _.bind(field, behaviorInstance);
                } else {
                  view[fieldName] = field;
                }
              }
            });
          }
        });
      }
    }
function(viewOptions) {
      var view = this;
      if (!_.isEmpty(this.behaviors)) {
        view.__behaviorInstances = {};
        _.each(this.behaviors, function(behaviorDefinition, alias) {
          if (!_.has(behaviorDefinition, 'behavior')) {
            behaviorDefinition = {behavior: behaviorDefinition};
          }
          var BehaviorClass = behaviorDefinition.behavior;
          if (!(BehaviorClass && _.isFunction(BehaviorClass))) {
            throw new Error('Incorrect behavior definition. Expected key "behavior" to be a class but instead got ' +
              String(BehaviorClass));
          }

          var behaviorOptions = _.pick(behaviorDefinition, function(value, key) {
            return key !== 'behavior';
          });
          behaviorOptions.view = view;
          behaviorOptions.alias = alias;
          var behaviorAttributes = behaviorDefinition.attributes || {};
          var behaviorInstance = view.__behaviorInstances[alias] = new BehaviorClass(behaviorAttributes, behaviorOptions, viewOptions);
          // Add the behavior's mixin fields to the view's public API
          if (behaviorInstance.mixin) {
            var mixin = _.result(behaviorInstance, 'mixin');
            _.each(mixin, function(field, fieldName) {
              // Default to a view's field over a behavior mixin
              if (_.isUndefined(view[fieldName])) {
                if (_.isFunction(field)) {
                  // Behavior mixin functions will be behavior-scoped - the context will be the behavior.
                  view[fieldName] = _.bind(field, behaviorInstance);
                } else {
                  view[fieldName] = field;
                }
              }
            });
          }
        });
      }
    }
function ( viewOptions ) { var view = this ; if ( ! _ . isEmpty ( this . behaviors ) ) { view . __behaviorInstances = { } ; _ . each ( this . behaviors , function ( behaviorDefinition , alias ) { if ( ! _ . has ( behaviorDefinition , 'behavior' ) ) { behaviorDefinition = { behavior : behaviorDefinition } ; } var BehaviorClass = behaviorDefinition . behavior ; if ( ! ( BehaviorClass && _ . isFunction ( BehaviorClass ) ) ) { throw new Error ( 'Incorrect behavior definition. Expected key "behavior" to be a class but instead got ' + String ( BehaviorClass ) ) ; } var behaviorOptions = _ . pick ( behaviorDefinition , function ( value , key ) { return key !== 'behavior' ; } ) ; behaviorOptions . view = view ; behaviorOptions . alias = alias ; var behaviorAttributes = behaviorDefinition . attributes || { } ; var behaviorInstance = view . __behaviorInstances [ alias ] = new BehaviorClass ( behaviorAttributes , behaviorOptions , viewOptions ) ; // Add the behavior's mixin fields to the view's public API if ( behaviorInstance . mixin ) { var mixin = _ . result ( behaviorInstance , 'mixin' ) ; _ . each ( mixin , function ( field , fieldName ) { // Default to a view's field over a behavior mixin if ( _ . isUndefined ( view [ fieldName ] ) ) { if ( _ . isFunction ( field ) ) { // Behavior mixin functions will be behavior-scoped - the context will be the behavior. view [ fieldName ] = _ . bind ( field , behaviorInstance ) ; } else { view [ fieldName ] = field ; } } } ) ; } } ) ; } }
Initializes the behaviors
@method __initializeBehaviors
Initializes the behaviors