torso-bundle.js
function(whenMap, indexMap) {
      var self = this,
          events = [];
      _.each(whenMap, function(whenEvents, whenField) {
        var substitutedWhenField,
            qualifiedFields = [whenField],
            useAtNotation = (whenField.charAt(0) === '@');

        if (whenField !== 'on' || whenField !== 'listenTo') {
          if (useAtNotation) {
            whenField = whenField.substring(1);
            // substitute indices in to "when" placeholders
            // [] -> to all, [0] -> to specific, [x] -> [x's value]
            substitutedWhenField = self.__substituteIndicesUsingMap(whenField, indexMap);
            qualifiedFields = _.flatten(self.__generateSubAttributes(substitutedWhenField, self.model));
          }
          // For each qualified field
          _.each(qualifiedFields, function(qualifiedField) {
            _.each(whenEvents, function(eventType) {
              var backboneEvent = eventType + ' ' + qualifiedField;
              if (useAtNotation) {
                backboneEvent = eventType + ' [data-model="' + qualifiedField + '"]';
              }
              events.push(backboneEvent);
            });
          });
        }
      });
      return events;
    }
function(whenMap, indexMap) {
      var self = this,
          events = [];
      _.each(whenMap, function(whenEvents, whenField) {
        var substitutedWhenField,
            qualifiedFields = [whenField],
            useAtNotation = (whenField.charAt(0) === '@');

        if (whenField !== 'on' || whenField !== 'listenTo') {
          if (useAtNotation) {
            whenField = whenField.substring(1);
            // substitute indices in to "when" placeholders
            // [] -> to all, [0] -> to specific, [x] -> [x's value]
            substitutedWhenField = self.__substituteIndicesUsingMap(whenField, indexMap);
            qualifiedFields = _.flatten(self.__generateSubAttributes(substitutedWhenField, self.model));
          }
          // For each qualified field
          _.each(qualifiedFields, function(qualifiedField) {
            _.each(whenEvents, function(eventType) {
              var backboneEvent = eventType + ' ' + qualifiedField;
              if (useAtNotation) {
                backboneEvent = eventType + ' [data-model="' + qualifiedField + '"]';
              }
              events.push(backboneEvent);
            });
          });
        }
      });
      return events;
    }
function ( whenMap , indexMap ) { var self = this , events = [ ] ; _ . each ( whenMap , function ( whenEvents , whenField ) { var substitutedWhenField , qualifiedFields = [ whenField ] , useAtNotation = ( whenField . charAt ( 0 ) === '@' ) ; if ( whenField !== 'on' || whenField !== 'listenTo' ) { if ( useAtNotation ) { whenField = whenField . substring ( 1 ) ; // substitute indices in to "when" placeholders // [] -> to all, [0] -> to specific, [x] -> [x's value] substitutedWhenField = self . __substituteIndicesUsingMap ( whenField , indexMap ) ; qualifiedFields = _ . flatten ( self . __generateSubAttributes ( substitutedWhenField , self . model ) ) ; } // For each qualified field _ . each ( qualifiedFields , function ( qualifiedField ) { _ . each ( whenEvents , function ( eventType ) { var backboneEvent = eventType + ' ' + qualifiedField ; if ( useAtNotation ) { backboneEvent = eventType + ' [data-model="' + qualifiedField + '"]' ; } events . push ( backboneEvent ) ; } ) ; } ) ; } } ) ; return events ; }
Generates the events needed to listen to the feedback's when methods. A when event is only created
if the appropriate element exist on the page
@param whenMap the collection of "when"'s for a given feedback
@param indexMap map from variable names to values when substituting array notation
@return the events that were generated
@private
@method __generateWhenEvents
Generates the events needed to listen to the feedback s when methods . A when event is only created if the appropriate element exist on the page