summaryrefslogtreecommitdiff
path: root/assets/js/components/subtask-toggle-status.js
blob: 3014adfa5b532d42eef02dc9c9b0a181cdac04c7 (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
KB.on('dom.ready', function () {
    $(document).on('click', '.js-subtask-toggle-status', function(e) {
        var el = $(this);
        var url = el.attr('href');

        e.preventDefault();

        $.ajax({
            cache: false,
            url: url,
            success: function(data) {
                if (url.indexOf('fragment=table') != -1) {
                    $('.subtasks-table').replaceWith(data);
                } else if (url.indexOf('fragment=rows') != -1) {
                    $(el).closest('.task-list-subtasks').replaceWith(data);
                } else {
                    $(el).closest('.subtask-title').replaceWith(data);
                }
            }
        });
    });

    $(document).on('click', '.js-subtask-toggle-timer', function(e) {
        var el = $(this);
        e.preventDefault();

        $.ajax({
            cache: false,
            url: el.attr('href'),
            success: function(data) {
                $(el).closest('.subtask-time-tracking').replaceWith(data);
            }
        });
    });
});