app.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 'use strict';
  2. /*
  3. Copyright 2015 Davide Alberani <da@erlug.linux.it>
  4. RaspiBO <info@raspibo.org>
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. /* Register our fantastic app. */
  15. var eventManApp = angular.module('eventManApp', [
  16. 'ngRoute',
  17. 'eventManServices',
  18. 'eventManControllers',
  19. 'ui.bootstrap',
  20. 'ui.router',
  21. 'pascalprecht.translate',
  22. 'angularFileUpload'
  23. ]);
  24. /* Add some utilities to the global scope. */
  25. eventManApp.run(function($rootScope, $state, $stateParams) {
  26. $rootScope.$state = $state;
  27. $rootScope.$stateParams = $stateParams;
  28. });
  29. /* Directive that can be used to make an input field react to the press of Enter. */
  30. eventManApp.directive('ngEnter', function () {
  31. return function (scope, element, attrs) {
  32. element.bind("keydown keypress", function (event) {
  33. if(event.which === 13) {
  34. scope.$apply(function (){
  35. scope.$eval(attrs.ngEnter);
  36. });
  37. event.preventDefault();
  38. }
  39. });
  40. };
  41. });
  42. /* Configure the states. */
  43. eventManApp.config(['$stateProvider', '$urlRouterProvider',
  44. function($stateProvider, $urlRouterProvider) {
  45. $urlRouterProvider.otherwise("/events");
  46. $stateProvider
  47. .state('events', {
  48. url: '/events',
  49. templateUrl: 'events-list.html',
  50. controller: 'EventsListCtrl'
  51. })
  52. .state('event', {
  53. url: '/event',
  54. templateUrl: 'event-main.html',
  55. })
  56. .state('event.new', {
  57. url: '/new',
  58. templateUrl: 'event-edit.html',
  59. controller: 'EventDetailsCtrl'
  60. })
  61. .state('event.edit', {
  62. url: '/:id/edit',
  63. templateUrl: 'event-edit.html',
  64. controller: 'EventDetailsCtrl'
  65. })
  66. .state('event.info', {
  67. url: '/:id',
  68. templateUrl: 'event-info.html',
  69. controller: 'EventDetailsCtrl'
  70. })
  71. .state('persons.list', {
  72. url: '/persons',
  73. templateUrl: 'persons-list.html',
  74. controller: 'PersonsListCtrl'
  75. })
  76. .state('persons.info', {
  77. url: '/persons/:id',
  78. templateUrl: 'persons-detail.html',
  79. controller: 'PersonDetailsCtrl'
  80. })
  81. .state('persons.new', {
  82. url: '/new-person',
  83. templateUrl: 'person-detail.html',
  84. controller: 'PersonDetailsCtrl'
  85. })
  86. .state('persons.import', {
  87. url: '/personsaaa',
  88. templateUrl: 'import-persons.html',
  89. controller: 'ImportPersonsCtrl'
  90. }
  91. );
  92. }
  93. ]);