/**
 * Main entrypoint for banknote.
 *
 * Copyright 2015 Ethan Smith
 */

var Backbone = require('backbone'),
    Marionette = require('backbone.marionette'),
    $ = require('jquery'),
    _ = require('underscore'),
    MainLayout = require('./src/view/MainLayout'),
    RegionModal = require('./src/common/modal/RegionModal.js'),
    CategorizedController = require('./src/controller/CategorizedController'),
    DifferenceController = require('./src/controller/DifferenceController'),
    AffixedView = require('./src/view/AffixedView'),
    AmountEntryCollection = require('./src/model/AmountEntryCollection');
require('./src/common/library/CurrencyInputStyler');


var Banknote = new Marionette.Application();

Banknote.addRegions({
   central: '#app',
   modal: RegionModal
});

var summaryConfig = [
   {
      'heading': 'Income Totals',
      'type': CategorizedController,
      'source': 'income'
   },
   {
      'heading': 'Expenses',
      'type': CategorizedController,
      'source': 'expenses'
   },
   {
      'heading': 'Monthly Net',
      'type': DifferenceController,
      'sources': {
         'subtrahend': 'expenses',
         'minuend': 'income'
      }
   }
];

Banknote.addInitializer(function(options) {

   var summaryContainer = new AffixedView();
   Banknote.central.show(summaryContainer);

   $.getJSON('demo.json', function(data) {

      _.each(summaryConfig, function(settings) {
         var source = settings.source,
             multiSource = settings.sources,
             model;

         if (multiSource) {
            model = _.object(_.keys(multiSource), _.map(multiSource, function(sourceField) {
               return new AmountEntryCollection(data[sourceField]);
            }));
         } else {
            model = new AmountEntryCollection(data[source]);
         }

         var controller = new settings.type({
            title: settings.heading
         });
         summaryContainer.affix(controller.render(model));
      });
   });
});

Banknote.start();

// Make Banknote available globally
global.Banknote = Banknote;

@@ -901,25 +901,34 @@
 'income'
+,
 %0A   
-%7D,%0A  
+   'options':
  %7B%0A     
@@ -932,30 +932,55 @@
     
+ 
-'heading': 'Expenses',
+  'title': 'Income Totals',%0A      %7D%0A   %7D,%0A   %7B
 %0A   
@@ -1039,25 +1039,34 @@
 xpenses'
+,
 %0A   
-%7D,%0A  
+   'options':
  %7B%0A     
@@ -1070,33 +1070,50 @@
     
+ 
-'heading': 'Monthly Net',
+  'title': 'Expenses',%0A      %7D%0A   %7D,%0A   %7B
 %0A   
@@ -1228,16 +1228,77 @@
 income'%0A
+      %7D,%0A      'options': %7B%0A         'title': 'Monthly Net',%0A
       %7D%0A
@@ -1984,56 +1984,24 @@
 ype(
-%7B%0A            title: settings.heading%0A         %7D
+settings.options
 );%0A 

Use options for controller param setup