Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 1 | (function() { |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 2 | 'use strict'; |
Matteo Scandolo | b585d38 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 3 | |
Matteo Scandolo | 57404dc | 2016-04-13 16:20:13 -0700 | [diff] [blame] | 4 | /** |
| 5 | * @ngdoc overview |
| 6 | * @name xos.helpers |
Matteo Scandolo | 0ae5d35 | 2016-07-15 17:04:14 -0700 | [diff] [blame] | 7 | * @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 Scandolo | 57404dc | 2016-04-13 16:20:13 -0700 | [diff] [blame] | 18 | **/ |
| 19 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 20 | angular |
| 21 | .module('xos.helpers', [ |
| 22 | 'ngCookies', |
| 23 | 'ngResource', |
Matteo Scandolo | b028075 | 2016-04-25 10:31:22 -0700 | [diff] [blame] | 24 | 'ngAnimate', |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 25 | 'xos.uiComponents' |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 26 | ]) |
Matteo Scandolo | 7bc39c4 | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 27 | .config(config) |
Matteo Scandolo | 974c0e4 | 2016-05-25 16:02:16 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * @ngdoc service |
| 31 | * @name xos.helpers._ |
| 32 | * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service |
| 33 | **/ |
| 34 | |
Matteo Scandolo | 7bc39c4 | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 35 | .factory('_', $window => $window._ ); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 36 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 37 | function config($httpProvider, $interpolateProvider, $resourceProvider) { |
| 38 | $httpProvider.interceptors.push('SetCSRFToken'); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 39 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 40 | $interpolateProvider.startSymbol('{$'); |
| 41 | $interpolateProvider.endSymbol('$}'); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 42 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 43 | // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html |
| 44 | $resourceProvider.defaults.stripTrailingSlashes = false; |
| 45 | } |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 46 | })(); |