UI improvements, save build feature partial implementation

This commit is contained in:
Colin McLeod
2015-05-02 00:04:57 -07:00
parent bca5ed899f
commit 71405e6cb7
21 changed files with 383 additions and 192 deletions

View File

@@ -1,44 +1,9 @@
angular.module('app', ['ui.router', 'shipyard', 'ngLodash', 'app.templates'])
.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$stateProvider
.state('outfit', {
url: '/outfit/:shipId/:code?bn',
params: {
// TODO: fix below, default, squash false not working
//shipId: { value: 'sidewinder', squash: false }, // Allow 'shipId' parameter to default to
code: { value: null, squash: true } // Allow 'code' parameter to be empty/optional
},
templateUrl: 'views/page-outfit.html',
controller: 'OutfitController',
resolve: {
shipId: ['$stateParams',function ($p) { // Ensure ship exists before loading controller
if (!DB.ships[$p.shipId]) {
throw { type: 404, message: 'Ship "' + $p.shipId + '" does not exist'};
}
}]
}
})
.state('shipyard', { url: '/', templateUrl: 'views/page-shipyard.html', controller: 'ShipyardController' })
.state('error', { params: {type:null, message:null, details: null }, templateUrl: 'views/page-error.html', controller: 'ErrorController' })
.state('notfound', { url: '*path', templateUrl: 'views/page-error.html', controller: 'ErrorController' });
}])
.config(['$provide',function($provide) {
// Global Error Handler, redirects uncaught errors to the error page
$provide.decorator('$exceptionHandler', ['$delegate', '$injector', function ($delegate, $injector) {
return function(exception, cause) {
$injector.get('$state').go('error', { details: exception }, {location:false, reload:true}); // Go to error state, reload the controller, keep the current URL
$delegate(exception, cause);
};
}]);
}])
.run(['$rootScope','$document','$state','commonArray','shipPurpose','shipSize','hardPointClass','internalGroupMap','hardpointsGroupMap', function ($rootScope, $doc, $state, CArr, shipPurpose, sz, hpc, igMap, hgMap) {
// Redirect any state transition errors to the error controller/state
$rootScope.$on('$stateChangeError', function(e, toState, toParams, fromState, fromParams, error){
e.preventDefault();
$state.go('error',error, {location:false, reload:true}); // Go to error state, reload the controller, keep the current URL
$state.go('error', error, {location:false, reload:true}); // Go to error state, reload the controller, keep the current URL
});
// Global Reference variables
@@ -47,7 +12,7 @@ angular.module('app', ['ui.router', 'shipyard', 'ngLodash', 'app.templates'])
$rootScope.SZ = sz;
$rootScope.HPC = hpc;
$rootScope.igMap = igMap;
window.hgmap = $rootScope.hgMap = hgMap;
$rootScope.hgMap = hgMap;
$rootScope.ships = DB.ships;
$rootScope.title = 'Coriolis';
@@ -61,11 +26,16 @@ angular.module('app', ['ui.router', 'shipyard', 'ngLodash', 'app.templates'])
// Global Event Listeners
$doc.bind('keyup', function (e) {
$rootScope.$broadcast('keyup', e);
if(e.keyCode == 27) { // Escape Key
$rootScope.$broadcast('close', e);
$rootScope.$apply();
} else {
$rootScope.$broadcast('keyup', e);
}
});
$rootScope.bgClicked = function (e) {
$rootScope.$broadcast('bgClicked', e);
$rootScope.$broadcast('close', e);
}
}]);