2015-06-29 15:51:29 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
//Start by defining the main module and adding the module dependencies
|
|
|
|
angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfiguration.applicationModuleVendorDependencies);
|
|
|
|
|
|
|
|
// Setting HTML5 Location Mode
|
|
|
|
angular.module(ApplicationConfiguration.applicationModuleName).config(['$locationProvider',
|
|
|
|
function($locationProvider) {
|
|
|
|
$locationProvider.hashPrefix('!');
|
|
|
|
}
|
|
|
|
]);
|
2015-07-01 16:14:39 -07:00
|
|
|
angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope', '$state', '$stateParams',
|
|
|
|
function($rootScope, $state, $stateParams) {
|
|
|
|
|
|
|
|
$rootScope.$state = $state;
|
|
|
|
$rootScope.$stateParams = $stateParams;
|
|
|
|
|
|
|
|
// add previous state property
|
|
|
|
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState) {
|
2015-07-09 15:15:34 -07:00
|
|
|
console.log(fromState);
|
2015-07-01 16:14:39 -07:00
|
|
|
$state.previous = fromState;
|
2015-07-06 18:56:38 -07:00
|
|
|
|
|
|
|
//Redirect home to listForms if user is authenticated
|
|
|
|
if(toState.name === 'home'){
|
|
|
|
if($rootScope.authentication.isAuthenticated()){
|
|
|
|
event.preventDefault(); // stop current execution
|
|
|
|
$state.go('listForms'); // go to login
|
|
|
|
}
|
|
|
|
}
|
2015-07-01 16:14:39 -07:00
|
|
|
});
|
|
|
|
|
2015-06-29 15:51:29 -07:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
//Then define the init function for starting up the application
|
|
|
|
angular.element(document).ready(function() {
|
|
|
|
//Fixing facebook bug with redirect
|
|
|
|
if (window.location.hash === '#_=_') window.location.hash = '#!';
|
|
|
|
|
|
|
|
//Then init the app
|
|
|
|
angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]);
|
|
|
|
});
|