The start of a test framework for Angular.
[civicrm-core.git] / js / angular-crmApp.js
1 (function(angular, CRM) {
2 var crmApp = angular.module('crmApp', CRM.angular.modules);
3 crmApp.config(['$routeProvider',
4 function($routeProvider) {
5 $routeProvider.otherwise({
6 template: ts('Unknown path')
7 });
8 }
9 ]);
10 crmApp.factory('crmApi', function() {
11 return function(entity, action, params, message) {
12 // JSON serialization in CRM.api3 is not aware of Angular metadata like $$hash
13 if (CRM._.isObject(entity)) {
14 return CRM.api3(eval('('+angular.toJson(entity)+')'), message);
15 } else {
16 return CRM.api3(entity, action, eval('('+angular.toJson(params)+')'), message);
17 }
18 };
19 });
20 crmApp.factory('crmLegacy', function() {
21 return CRM;
22 });
23 crmApp.factory('crmNavigator', ['$window', function($window) {
24 return {
25 redirect: function(path) {
26 $window.location.href = path;
27 }
28 };
29 }]);
30 })(angular, CRM);