summaryrefslogtreecommitdiffstats
path: root/coffee/lib/owncloud.coffee
blob: 53749913520ce670cc9da76fce1b41dc7068ad0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
###
# ownCloud
#
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
# This file is licensed under the Affero General Public License version 3 or
# later.
#
# See the COPYING-README file
#
###

###
# Various config stuff for owncloud
###
angular.module('OC', []).config ['$httpProvider', ($httpProvider) ->

	# Always send the CSRF token by default
	$httpProvider.defaults.get['requesttoken'] = oc_requesttoken
	$httpProvider.defaults.post['requesttoken'] = oc_requesttoken
	
	# needed because crap PHP does not understand JSON
	$httpProvider.defaults.post['Content-Type'] =
		'application/x-www-form-urlencoded'
		
	$httpProvider.defaults.get['Content-Type'] =
		'application/x-www-form-urlencoded'

	$httpProvider.defaults.transformRequest = (data) ->
		if angular.isDefined(data)
			return data
		else
			return $.param(data)
]

angular.module('OC').init ['$rootScope', 'Router', ($rootScope, Router) ->
        init = ->
                $rootScope.$broadcast('routesLoaded')

        # this registers a callback that is executed once the routes have
        # finished loading. Before this you cant really do request
        OC.Router.registerLoadedCallback(init)
]