summaryrefslogtreecommitdiffstats
path: root/coffee/directives/droppable.coffee
blob: 6579f8db4b3a18fc9f106be1aa45be024b07953e (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
###
# ownCloud news app
#
# @author Alessandro Cosentino
# @author Bernhard Posselt
# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# 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
#
###

angular.module('News').directive 'droppable', ['$rootScope', ($rootScope) ->

	return (scope, elm, attr) ->
		$elem = $(elm)

		details = 
			accept: '.feed'
			hoverClass: 'drag-and-drop'
			greedy: true
			drop: (event, ui) ->
				# in case jquery ui did something weird
				$('.drag-and-drop').removeClass('drag-and-drop')

				data = 
					folderId: parseInt($elem.data('id'), 10)
					feedId: parseInt($(ui.draggable).data('id'), 10)

				$rootScope.$broadcast('moveFeedToFolder', data)
				scope.$apply attr.droppable

		$elem.droppable(details)
]