// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('ngGanzhornfest', ['ionic', 'ngGanzhornfest.controllers', 'ngGanzhornfest.services', 'leaflet-directive', 'ngTouch', 'ngCordova'])

.value('Application', {
  version: "0.1.4",
  name: "Ganzhornfest",
})

.run(function($ionicPlatform, Application) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.getAppVersion.getVersionNumber(function(version) {
        Application.version = version;
      });
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleLightContent();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {

  // Place tabs on top for every OS (otherwise Android defaults to top)
  // see: http://forum.ionicframework.com/t/ion-tabs-on-top-of-the-screen-in-android/15732/8
  // and: http://ionicframework.com/docs/api/provider/%24ionicConfigProvider/
  $ionicConfigProvider.tabs.position('top'); 

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider

  // setup an abstract state for the tabs directive
  .state('tab', {
    url: "/tab",
    abstract: true,
    templateUrl: "templates/tabs.html"
  })

  // Each tab has its own nav history stack:
  .state('tab.list', {
    url: '/list',
    views: {
      'tab-list': {
        templateUrl: 'templates/tab-list.html',
        controller: 'ListCtrl'
      }
    }
  })

  .state('tab.detail', {
    url: '/detail?id?type',
    views: {
      'tab-list': {
        templateUrl: 'templates/tab-detail.html',
        controller: 'DetailCtrl'
      }
    }
  })

  .state('tab.stand', {
    url: '/stand?id',
    views: {
      'tab-list': {
        templateUrl: 'templates/tab-detail-stand.html',
        controller: 'DetailStandCtrl'
      }
    }
  })

  .state('tab.program', {
    url: '/program?day?stage',
    params: {
      day: function() {
        var possibleDays = [6,0,1];
        var date = new Date();
        var day = date.getDay();
        if ( possibleDays.indexOf(day) !== -1 ) {
          return day;
        } else {
          return 6;
        }
      },
      stage: 59,
    },
    views: {
      'tab-program': {
        templateUrl: 'templates/tab-program.html',
        controller: 'ProgramCtrl'
      }
    }
  })

  .state('tab.stage', {
    url: '/stage?id',
    views: {
      'tab-program': {
        templateUrl: 'templates/tab-detail-poi.html',
        controller: 'DetailStageCtrl'
      }
    }
  })


  .state('tab.bus', {
    url: '/bus?day',
    params: {
      day: function() {
        var possibleDays = [6,0,1];
        var date = new Date();
        var day = date.getDay();
        if ( possibleDays.indexOf(day) !== -1 ) {
          return day;
        } else {
          return 6;
        }
      },
    },
    views: {
      'tab-bus': {
        templateUrl: 'templates/tab-bus.html',
        controller: 'BusCtrl'
      }
    }
  })

  .state('tab.busstop', {
    url: '/busstop',
    views: {
      'tab-bus': {
        templateUrl: 'templates/tab-detail-poi.html',
        controller: 'DetailBusstopCtrl'
      }
    }
  })

  .state('tab.map', {
    url: '/map',
    views: {
      'tab-map': {
        templateUrl: 'templates/tab-map.html',
        controller: 'MapCtrl'
      }
    }
  })

  .state('tab.info', {
    url: '/info',
    views: {
      'tab-info': {
        templateUrl: 'templates/tab-info.html',
        controller: 'InfoCtrl'
      }
    }
  });


  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/tab/info');

});

@@ -616,16 +616,39 @@
 lication
+, $templateCache, $http
 ) %7B%0A  $i
@@ -1196,16 +1196,632 @@
 %7D%0A  %7D);%0A
+  $http.get(%22templates/tabs.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-list.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-detail.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-detail-stand.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-detail-poi.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-program.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-bus.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-info.html%22, %7B cache: $templateCache %7D);%0A  $http.get(%22templates/tab-map.html%22, %7B cache: $templateCache %7D);%0A
 %7D)%0A%0A.con

Use templateCache.