aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/bootstrap/contentbox.js
blob: 3f05331047de7a1f6c7e5a75d1f844c13960f53a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$(document).on('click', 'section.contentbox article header h1 a', function(e) {
    if (!$(this).hasClass('no-contentbox-link')) {
        e.preventDefault();
        var article = $(this).closest('article');

        // If the contentbox article is new send an ajax request
        if (article.hasClass('new')) {
            $.ajax({
                type: 'POST',
                url: STUDIP.URLHelper.getURL(decodeURIComponent(article.data('visiturl') + $(this).attr('href')))
            });
        }

        // Open the contentbox
        article.toggleClass('open').removeClass('new');
        article.attr('aria-expanded', article.attr('aria-expanded') === 'true' ? 'false' : 'true');
    }
});