From c63124f575b75adde76b0b4f697b691539061a9f Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sat, 21 Mar 2015 15:45:40 +0100 Subject: [PATCH] JavaScript code cleanup --- angular_app/event-detail.html | 38 ++++++++++---------- angular_app/index.html | 56 ++++++++++++++--------------- angular_app/js/app.js | 66 ++++++++++++++++++----------------- angular_app/js/controllers.js | 14 ++++---- angular_app/js/services.js | 46 ++++++++++++------------ 5 files changed, 111 insertions(+), 109 deletions(-) diff --git a/angular_app/event-detail.html b/angular_app/event-detail.html index 6b243f2..0f4c913 100644 --- a/angular_app/event-detail.html +++ b/angular_app/event-detail.html @@ -1,24 +1,24 @@
-
-
- Title - -
+ +
+ Title + +
-
- Short description - -
+
+ Short description + +
-
- Begin time - -
+
+ Begin time + +
-
- End time - -
- -
+
+ End time + +
+ +
diff --git a/angular_app/index.html b/angular_app/index.html index 037bfbd..3c9f06e 100644 --- a/angular_app/index.html +++ b/angular_app/index.html @@ -1,34 +1,34 @@ - - - - - - - - - - - Event Man(ager) - - - - + + + + + + + + + + + Event Man(ager) + + + + - -
- - - - -
+ +
+ + + + +
-
+
- - - - + + + + diff --git a/angular_app/js/app.js b/angular_app/js/app.js index 734c3be..3efc5cc 100644 --- a/angular_app/js/app.js +++ b/angular_app/js/app.js @@ -1,9 +1,10 @@ var eventManApp = angular.module('eventManApp', [ - 'ngRoute', - 'eventManServices', - 'eventManControllers' + 'ngRoute', + 'eventManServices', + 'eventManControllers' ]); + eventManApp.directive('ngEnter', function () { return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { @@ -17,35 +18,36 @@ eventManApp.directive('ngEnter', function () { }; }); + eventManApp.config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/persons', { - templateUrl: 'persons-list.html', - controller: 'PersonsListCtrl' - }). - when('/persons/:id', { - templateUrl: 'person-detail.html', - controller: 'PersonDetailsCtrl' - }). - when('/events', { - templateUrl: 'events-list.html', - controller: 'EventsListCtrl' - }). - when('/events/:id', { - templateUrl: 'event-detail.html', - controller: 'EventDetailsCtrl' - }). - when('/new-event', { - templateUrl: 'event-detail.html', - controller: 'EventDetailsCtrl' - }). - when('/new-person', { - templateUrl: 'person-detail.html', - controller: 'PersonDetailsCtrl' - }). - otherwise({ - redirectTo: '/events' - }); + function($routeProvider) { + $routeProvider. + when('/persons', { + templateUrl: 'persons-list.html', + controller: 'PersonsListCtrl' + }). + when('/persons/:id', { + templateUrl: 'person-detail.html', + controller: 'PersonDetailsCtrl' + }). + when('/events', { + templateUrl: 'events-list.html', + controller: 'EventsListCtrl' + }). + when('/events/:id', { + templateUrl: 'event-detail.html', + controller: 'EventDetailsCtrl' + }). + when('/new-event', { + templateUrl: 'event-detail.html', + controller: 'EventDetailsCtrl' + }). + when('/new-person', { + templateUrl: 'person-detail.html', + controller: 'PersonDetailsCtrl' + }). + otherwise({ + redirectTo: '/events' + }); }]); diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index 3d7384c..d885b0b 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -25,13 +25,13 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$routePa if ($routeParams.id) { $scope.event = Event.get($routeParams); } - $scope.save = function() { - if ($scope.event.id === undefined) { - Event.save($scope.event); - } else { - Event.update($scope.event); - } - }; + $scope.save = function() { + if ($scope.event.id === undefined) { + Event.save($scope.event); + } else { + Event.update($scope.event); + } + }; }] ); diff --git a/angular_app/js/services.js b/angular_app/js/services.js index da53530..b09ab67 100644 --- a/angular_app/js/services.js +++ b/angular_app/js/services.js @@ -1,32 +1,32 @@ var eventManServices = angular.module('eventManServices', ['ngResource']); eventManServices.factory('Event', ['$resource', - function($resource) { - return $resource('events/:id', {id: '@id'}, { - all: { - method: 'GET', - isArray: true, - transformResponse: function(data, headers) { - return angular.fromJson(data).events; - } - }, - update: {method: 'PUT'} - }); - }] + function($resource) { + return $resource('events/:id', {id: '@id'}, { + all: { + method: 'GET', + isArray: true, + transformResponse: function(data, headers) { + return angular.fromJson(data).events; + } + }, + update: {method: 'PUT'} + }); + }] ); eventManServices.factory('Person', ['$resource', - function($resource) { - return $resource('persons/:id', {id: '@id'}, { - all: { - method: 'GET', - isArray:true, - transformResponse: function(data, headers) { - return angular.fromJson(data).persons; - } - } - }); - }] + function($resource) { + return $resource('persons/:id', {id: '@id'}, { + all: { + method: 'GET', + isArray:true, + transformResponse: function(data, headers) { + return angular.fromJson(data).persons; + } + } + }); + }] );