aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/bootstrap/tables.js
blob: f4afc52f7b5d221d53eb0f0e4494c985f8d9bef8 (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
/*jslint esversion: 6*/

STUDIP.domReady(function() {
    if (window.MutationObserver !== undefined) {
        var observer = new window.MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.attributeName === 'class') {
                    if (
                        $(mutation.target)
                            .attr('class')
                            .indexOf('open') !== -1
                    ) {
                        $(mutation.target)
                            .next()
                            .find('td')
                            .slideDown()
                            .find('.detailscontainer')
                            .hide()
                            .slideDown();
                    } else {
                        $(mutation.target)
                            .next()
                            .show()
                            .find('td')
                            .slideUp()
                            .find('.detailscontainer')
                            .slideUp();
                    }
                }
            });
        });
        $('table.withdetails > tbody > tr:not(.details)').each(function(index, element) {
            observer.observe(element, { attributes: true });
        });
    }
});

STUDIP.ready(function (event) {
    $('table.sortable-table:not(.tablesorter)', event.target).each((index, element) => {
        STUDIP.Table.enhanceSortableTable(element);
    });
});