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  .state('app.help', {
 47    url: '/help',
 48    views: {
 49      'menuContent': {
 50        templateUrl: 'templates/help.html',
 51        controller: 'HelpCtrl'
 52      }
 53    }
 54  })
 55
 56  .state('app.users', {
 57      url: '/users',
 58      views: {
 59        'menuContent': {
 60          templateUrl: 'templates/users.html',
 61          controller: 'UsersCtrl'
 62        }
 63      }
 64    })
 65    .state('app.user', {
 66        url: '/users/:username',
 67        views: {
 68          'menuContent': {
 69            templateUrl: 'templates/user.html',
 70            controller: 'UserCtrl'
 71          }
 72        }
 73      })
 74    .state('app.travels', {
 75      url: '/travels',
 76      views: {
 77        'menuContent': {
 78          templateUrl: 'templates/travels.html',
 79          controller: 'TravelsCtrl'
 80        }
 81      }
 82    })
 83
 84  .state('app.travel', {
 85    url: '/travels/:travelId',
 86    views: {
 87      'menuContent': {
 88        templateUrl: 'templates/travel.html',
 89        controller: 'TravelCtrl'
 90      }
 91    }
 92  });
 93  // if none of the above states are matched, use this as the fallback
 94  $urlRouterProvider.otherwise('/app/travels');
 95})
 96
 97
 98
 99/* translator */
100.config(['$translateProvider',function($translateProvider) {
101
102    /* get lang from the file translations.js */
103    for(lang in translations){
104    	$translateProvider.translations(lang, translations[lang]);
105    }
106
107    if(window.localStorage.getItem('lang')) {
108        $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
109    }else{
110        $translateProvider.preferredLanguage('english');
111    };
112
113    $translateProvider.useSanitizeValueStrategy('escape');
114
115}]);