<!DOCTYPE html>
<html>

<head>
    <title>AngularJS: UI-Router Quick Start</title>
    <!-- Bootstrap CSS -->
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
</head>
<body>
  
  <div ng-app="ngSPA" class="container"
        ng-class="{'outline': toggles.developer.outline.enabled}">
    
    <!-- <header-nav></header-nav> -->
    
    <div class="row">
      <div 
        ng-class="{'col-xs-6': toggles.developer.debug.enabled}"
        class="col-xs-12">
        <div ui-view></div>        
        
      </div>
      
      <!-- <debug></debug> -->
    </div>
    
<!--
  <toggles></toggles>
 -->  
    <!-- Angular -->
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.20/angular.js"></script>
    
    <!-- Bootstrap -->
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    
    <!-- UI-Router -->
    <script src="//angular-ui.github.io/ui-router/release/angular-ui-router.js"></script>
    
    <!-- App Script -->
    <script src="app.js"></script>

  </div>

</body>

</html>
angular
  .module('ngSPA', ["ui.router"])
//   .factory('toggles', function($http, $q) {
//       return {
//         get: function() {
//           return {
//             developer: {
//               debug: {
//                 enabled: false
//               },
//               outline: {
//                 enabled: false
//               }
//             },
//             feature: {
//               modify: {
//                 enabled: false
//               },
//               forceTravelParty: {
//                 enabled: false
//               }
//             }
//           }
//         }
//       };
//   })
//   .factory('details', function($http, $q) {
//       return {
//         get: function() {
//           //debugger;
//           var sailings = $q.defer();
//           $http
//             .get('http://localhost:8181/wam/cruise-sales-service/cruise-listing/?region=INTL&storeId=DCL&view=cruise-listing')
//             .then(
//               function(response) {
//                 // debugger;
//                 sailings.resolve(response);
//               }, function(error) {
//                 // debugger;
//                 sailings.reject(error);
//               }
//             );
//           return sailings.promise;
//         }
//       };
//   })
//   .factory('avail', function($http, $q) {
//       return {
//         get: function(itinerary) {
//           var itineraries = {
//             'item-1': [{room: 1},{room: 2},{room: 3},{room: 4}],
//             'item-2': [{room: 11},{room: 12},{room: 13},{room: 14}],
//             'item-3': [{room: 21},{room: 22},{room: 23},{room: 24}],
//             'item-4': [] // no avail
//           };

//           if (itinerary) {
//             return itineraries[itinerary];
//           } else {
//             return itineraries;
//           }
//         }
//       }
//     })
//   .factory('booking', function() {
//       return {
//         travelParty: {
//           adults: 0, 
//           children: 0
//         },
//         rooms: 0,
//         itinerary: null,
//         staterooms: null,
        
//         getTravelParty: function() {
//           return this.travelParty;
//         },

//         saveTravelParty: function(tp) {
//           this.rooms = Math.ceil((tp.adults + tp.children)/4);// tmp logic for room
          
//           if (tp.adults > 1) {
//             this.travelParty = tp;
//             return true;
//           } else {
//             return false
//           }
//         },       
//         saveSelection: function(itinerary) {
//             this.itinerary = itinerary;
//             return true;
//         },
//         getItinerary: function() {
//             return this.itinerary;
//         },
//         // modify uses
//         getConfirmationIds: function() {
//             return {'conf_123': {'item-2': [{room: 32}]}};
//         }
//       }
//   })
//   .directive('debug', function() {
//     return {
//       restrict: 'E',
//       templateUrl: 'debug.html'
//     };
//   })
//   .directive('headerNav', function() {
//     return {
//       restrict: 'E',
//       templateUrl: 'header-nav.html'
//     };
//   })
//   .directive('toggles', function(toggles) {
//     return {
//       restrict: 'E',
//       templateUrl: 'toggles.html',
//       controller: function($rootScope) {
//         $rootScope.toggles = toggles.get();
//       }
//     };
//   })
//   .config(function() {

//   })

  .config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise("/");
    $stateProvider
      .state('home', {
          url: "/home",
          templateUrl: "home.html",
          controller: function($log, $state) {
            $log.log('home controller');
          },
          controllerAs: 'searchVm'
      })
  })

//   .run(['$rootScope', function ($rootScope) {
//     var events = [
//       '$stateChangeStart', 
//       '$stateChangeSuccess', 
//       '$stateChangeError', 
//       '$stateNotFound',
//       '$viewContentLoading',
//       '$viewContentLoaded'
//     ];
//     angular.forEach(events, function(value) {
//       $rootScope.$on(value, function() { 
//         console.log('%s %o', value, arguments);
//       });
//     });
//     // $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) { 
//     // });
//     // $rootScope.$on('$stateNotFound', function(event, unfoundState, fromState, fromParams) { 
//     //   console.log('$stateNotFound', arguments);
//     // });
//   }])
//   .run(['$rootScope', '$state', '$stateParams', 'booking', function ($rootScope, $state, $stateParams, booking) {
//     // It's very handy to add references to $state and $stateParams to the $rootScope
//     // so that you can access them from any scope within your applications.For example,
//     // <li ng-class="{ active: $state.includes('contacts.list') }"> will set the <li>
//     // to active whenever 'contacts.list' or one of its decendents is active.
//     $rootScope.$state = $state;
//     $rootScope.$stateParams = $stateParams;
//     $rootScope.booking = booking;

  // }])
  ;
    if (typeof console._commandLineAPI !== 'undefined') {
      // debugger;
      console.API = console._commandLineAPI;
    } else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
      // debugger;
      console.API = console._inspectorCommandLineAPI;
    } else if (typeof console.clear !== 'undefined') {
      // debugger;
      console.API = console;
    }
    console.API.clear();
home