Passed
Push — master ( fe7b3f...22651e )
by Andrey
08:30
created

web/js/navbar.js   A

Complexity

Total Complexity 6
Complexity/F 2

Size

Lines of Code 32
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 32
rs 10
wmc 6
mnd 3
bc 3
fnc 3
bpm 1
cpm 2
noi 1
1
$(document).ready(function () {
2
3
    $('.navbar .dropdown-item.dropdown').on('click', function (e) {
4
        var $el = $(this).children('.dropdown-toggle');
5
        if ($el.length > 0 && $(e.target).hasClass('dropdown-toggle')) {
6
            var $parent = $el.offsetParent(".dropdown-menu");
7
            $(this).parent("li").toggleClass('open');
8
9
            if (!$parent.parent().hasClass('navbar-nav')) {
10
                if ($parent.hasClass('show')) {
11
                    $parent.removeClass('show');
12
                    $el.next().removeClass('show');
13
                    $el.next().css({"top": -999, "left": -999});
14
                } else {
15
                    $parent.parent().find('.show').removeClass('show');
16
                    $parent.addClass('show');
17
                    $el.next().addClass('show');
18
                    $el.next().css({"top": $el[0].offsetTop, "left": $parent.outerWidth() - 4});
19
                }
20
                e.preventDefault();
21
                e.stopPropagation();
22
            }
23
            return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
24
        }
25
    });
26
27
    $('.navbar .dropdown').on('hidden.bs.dropdown', function () {
28
        $(this).find('li.dropdown').removeClass('show open');
29
        $(this).find('ul.dropdown-menu').removeClass('show open');
30
    });
31
32
});
33