aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/bootstrap/responsive.js
blob: 7ee9b15800ec74c8846808794f6527f60078c550 (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
// Build responsive menu on domready or resize
STUDIP.domReady(() => {
    STUDIP.Responsive.engage();

    if (STUDIP.Responsive.isCompactNavigation()) {
        document.documentElement.classList.add('fullscreen-mode');
        const sidebar = document.getElementById('sidebar');
        if (sidebar) {
            sidebar.ariaHidden = 'true';
        }
    }

}, true);

// Trigger search in responsive display
$(document).on('click', '#quicksearch .quicksearchbutton', function() {
    if ($('html').is(':not(.responsive-display)') || $('#quicksearch').is('.open')) {
        return;
    }

    $('#quicksearch').addClass('open');
    $('.quicksearchbox').focus();

    return false;
}).on('blur', '#quicksearch.open .quicksearchbox', function() {
    if (!this.value.trim().length) {
        $('#quicksearch').removeClass('open');
    }
}).on('autocompleteopen', event => {
    if ($(event.target).closest('#quicksearch').length === 0) {
        return;
    }
    $('body > .ui-autocomplete').css({
        left: 0,
        right: 0,
        boxSizing: 'border-box'
    });
});