aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/bootstrap/clipboard.js
blob: 0b6c2711a5a62c4a6f4a4a2e71bc6b2417c7eca0 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
STUDIP.domReady(function() {
    jQuery('.clipboard-draggable-item').draggable(
        {
            cursorAt: {left: 28, top: 15},
            appendTo: 'body',
            helper: function () {
                var dragged_item = jQuery('<div class="dragged-clipboard-item"></div>');
                jQuery(dragged_item).data('id', jQuery(this).data('id'));
                jQuery(dragged_item).data('range_type', jQuery(this).data('range_type'));
                jQuery(dragged_item).text(jQuery(this).data('name'));
                return dragged_item;
            },
            revert: true,
            revertDuration: 0
        }
    );

    jQuery('.clipboard-area').droppable(
        {
            drop: STUDIP.Clipboard.handleItemDrop
        }
    );

    jQuery('.clipboard-selector').change(
        STUDIP.Clipboard.switchClipboard
    );

    jQuery(document).on(
        'change',
        '.clipboard-selector',
        STUDIP.Clipboard.switchClipboard
    );

    jQuery(document).on(
        'dragend',
        '.clipboard-draggable-item',
        function(event) {
            jQuery(event.target).css(
                {
                    'top': '0px',
                    'left': '0px'
                }
            );
        }
    );

    jQuery(document).on(
        'dragover',
        '.clipboard-area',
        function(event) {
            event.preventDefault();
            event.stopPropagation();
        }
    );

    jQuery(document).on(
        'dragenter',
        '.clipboard-area',
        function(event) {
            //TODO:rrv2: use CSS classes!
            event.target.style.backgroundColor = '#0F0';
        }
    );

    jQuery(document).on(
        'dragleave',
        '.clipboard-area',
        function(event) {
            //TODO:rrv2: use CSS classes!
            event.target.style.backgroundColor = '#FFF';
        }
    );

    jQuery(document).on(
        'click',
        '.clipboard-remove-button',
        STUDIP.Clipboard.confirmRemoveClick
    );

    jQuery(document).on(
        'click',
        '.clipboard-item-remove-button',
        STUDIP.Clipboard.confirmRemoveItemClick
    );

    jQuery('.clipboard-widget .new-clipboard-form').submit(
        STUDIP.Clipboard.handleAddForm
    );

    jQuery(document).on(
        'click',
        '.clipboard-add-item-button',
        STUDIP.Clipboard.handleAddItemButtonClick
    );
});