blob: 9ec3f10974b4171bbf6323c6226e780b1fff3bd3 [file] [log] [blame]
Matteo Scandolo817386b2015-11-04 16:07:09 +01001(function() {
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -07002 'use strict';
Matteo Scandolob585d382016-06-15 14:53:33 -07003
Matteo Scandolo57404dc2016-04-13 16:20:13 -07004 /**
5 * @ngdoc overview
6 * @name xos.helpers
Matteo Scandolo0ae5d352016-07-15 17:04:14 -07007 * @description
8 * # xos.Helpers
9 * A collection of helpers to work with XOS <br/>
10 * Currently available components are:
11 * - [NoHyperlinks](/#/module/xos.helpers.NoHyperlinks)
12 * - [SetCSRFToken](/#/module/xos.helpers.SetCSRFToken)
13 * - [xosNotification](/#/module/xos.helpers.xosNotification)
14 * - [XosUserPrefs](/#/module/xos.helpers.XosUserPrefs)
15 * <br/><br/>
16 * A set of angular [$resource](https://docs.angularjs.org/api/ngResource/service/$resource) is provided to work with the API.<br>
17 * You can find the documentation [here](#/rest-api)
Matteo Scandolo57404dc2016-04-13 16:20:13 -070018 **/
19
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070020 angular
21 .module('xos.helpers', [
22 'ngCookies',
23 'ngResource',
Matteo Scandolob0280752016-04-25 10:31:22 -070024 'ngAnimate',
Matteo Scandolob9fb6252016-05-26 15:09:55 -070025 'xos.uiComponents'
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070026 ])
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070027 .config(config)
Matteo Scandolo974c0e42016-05-25 16:02:16 -070028
29 /**
30 * @ngdoc service
31 * @name xos.helpers._
32 * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service
33 **/
34
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070035 .factory('_', $window => $window._ );
Matteo Scandolo817386b2015-11-04 16:07:09 +010036
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070037 function config($httpProvider, $interpolateProvider, $resourceProvider) {
38 $httpProvider.interceptors.push('SetCSRFToken');
Matteo Scandolo817386b2015-11-04 16:07:09 +010039
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070040 $interpolateProvider.startSymbol('{$');
41 $interpolateProvider.endSymbol('$}');
Matteo Scandolo817386b2015-11-04 16:07:09 +010042
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070043 // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html
44 $resourceProvider.defaults.stripTrailingSlashes = false;
45 }
Matteo Scandolo817386b2015-11-04 16:07:09 +010046})();