summaryrefslogtreecommitdiffstats
path: root/js/directive/NewsDroppable.js
blob: e06b2aac1b6d8e4e525d8c9f6b6f2e5ce01be4c0 (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
/**
 * Nextcloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
 * @copyright Bernhard Posselt 2014
 */
app.directive('newsDroppable', function ($rootScope) {
    'use strict';

    return function (scope, elem, attr) {
        var details = {
            accept: '.feed',
            hoverClass: 'drag-and-drop',
            greedy: true,
            drop: function (event, ui) {

                $('.drag-and-drop').removeClass('drag-and-drop');

                var 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);
    };
});