arnaucube
arnaucube/commonroutesAppPublic Self-hosted repository
commonroutesApp/www/js/app.js
www/js/app.jsRaw
  1// Ionic Starter App
  2
  3// angular.module is a global place for creating, registering and retrieving Angular modules
  4// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
  5// the 2nd parameter is an array of 'requires'
  6// 'starter.controllers' is found in controllers.js
  7angular.module('starter', ['ionic',
  8                            'starter.controllers',
  9                            'pascalprecht.translate'])
 10
 11.run(function($ionicPlatform) {
 12  $ionicPlatform.ready(function() {
 13    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
 14    // for form inputs)
 15    if (window.cordova && window.cordova.plugins.Keyboard) {
 16      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
 17      cordova.plugins.Keyboard.disableScroll(true);
 18
 19    }
 20    if (window.StatusBar) {
 21      // org.apache.cordova.statusbar required
 22      StatusBar.styleDefault();
 23    }
 24  });
 25})
 26
 27.config(function($stateProvider, $urlRouterProvider) {
 28  $stateProvider
 29
 30    .state('app', {
 31    url: '/app',
 32    abstract: true,
 33    templateUrl: 'templates/menu.html',
 34    controller: 'AppCtrl'
 35  })
 36
 37  .state('app.settings', {
 38    url: '/settings',
 39    views: {
 40      'menuContent': {
 41        templateUrl: 'templates/settings.html',
 42        controller: 'SettingsCtrl'
 43      }
 44    }
 45  })
 46
 47  .state('app.users', {
 48      url: '/users',
 49      views: {
 50        'menuContent': {
 51          templateUrl: 'templates/users.html',
 52          controller: 'UsersCtrl'
 53        }
 54      }
 55    })
 56    .state('app.user', {
 57        url: '/users/:username',
 58        views: {
 59          'menuContent': {
 60            templateUrl: 'templates/user.html',
 61            controller: 'UserCtrl'
 62          }
 63        }
 64      })
 65    .state('app.travels', {
 66      url: '/travels',
 67      views: {
 68        'menuContent': {
 69          templateUrl: 'templates/travels.html',
 70          controller: 'TravelsCtrl'
 71        }
 72      }
 73    })
 74
 75  .state('app.travel', {
 76    url: '/travels/:travelId',
 77    views: {
 78      'menuContent': {
 79        templateUrl: 'templates/travel.html',
 80        controller: 'TravelCtrl'
 81      }
 82    }
 83  });
 84  // if none of the above states are matched, use this as the fallback
 85  $urlRouterProvider.otherwise('/app/travels');
 86})
 87
 88
 89
 90/* translator */
 91.config(['$translateProvider',function($translateProvider) {
 92
 93    /* get lang from the file translations.js */
 94    for(lang in translations){
 95    	$translateProvider.translations(lang, translations[lang]);
 96    }
 97
 98    if(window.localStorage.getItem('lang')) {
 99        $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
100    }else{
101        $translateProvider.preferredLanguage('english');
102    };
103
104    $translateProvider.useSanitizeValueStrategy('escape');
105
106}]);