Completed
Push — develop ( 3d0c4c...e7cba6 )
by Freddie
13:19 queued 12s
created

src/Domain/BoilerPlates/jQuery/main.js   A

Complexity

Total Complexity 18
Complexity/F 2.25

Size

Lines of Code 79
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 52
c 0
b 0
f 0
dl 0
loc 79
rs 10
wmc 18
mnd 10
bc 10
fnc 8
bpm 1.25
cpm 2.25
noi 4
1
jQuery(document).ready(function ($) {
2
    'use strict';
3
    if ($(".notification-list").length) {
4
        $('.notification-list').slimScroll({
5
            height: '100%'
6
        });
7
    }
8
    if ($(".menu-list").length) {
9
        $('.menu-list').slimScroll({
10
            height: '100%'
11
        });
12
    }
13
    if ($(".sidebar-nav-fixed a").length) {
14
        $('.sidebar-nav-fixed a').click(function (event) {
15
            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
16
                && location.hostname == this.hostname
17
            ) {
18
                var target = $(this.hash);
19
                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
20
                if (target.length) {
21
                    event.preventDefault();
22
                    $('html, body').animate({
23
                        scrollTop: target.offset().top - 90
24
                    }, 1000, function () {
25
                        var $target = $(target);
26
                        $target.focus();
27
                        if ($target.is(":focus")) {
28
                            return false;
29
                        } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
30
                            $target.attr('tabindex', '-1');
31
                            $target.focus();
32
                        };
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
33
                    });
34
                }
35
            };
36
37
            $('.sidebar-nav-fixed a').each(function () {
38
                $(this).removeClass('active');
39
            })
40
41
            $(this).addClass('active');
42
        });
43
    }
44
45
    if ($('[data-toggle="tooltip"]').length) {
46
        $('[data-toggle="tooltip"]').tooltip()
47
    }
48
49
    if ($('[data-toggle="popover"]').length) {
50
        $('[data-toggle="popover"]').popover()
51
    }
52
53
    $(document).on('submit', 'form[data-confirmation]', function (event) {
54
        var $form = $(this),
55
            $confirm = $('#confirmationModal');
56
57
        if ($confirm.data('result') !== 'yes') {
58
            //cancel submit event
59
            event.preventDefault();
60
61
            $confirm
62
                .off('click', '#btnYes')
63
                .on('click', '#btnYes', function () {
64
                    $confirm.data('result', 'yes');
65
                    $form.find('input[type="submit"]').attr('disabled', 'disabled');
66
                    $form.submit();
67
                })
68
                .modal('show');
69
        }
70
    });
71
72
    $(document).on('submit', 'form:not([data-confirmation])', function (event) {
0 ignored issues
show
Unused Code introduced by
The parameter event is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
73
        $('.overlay').show();
74
    });
75
76
    $(document).on('click', '.show-overlay', function (event) {
0 ignored issues
show
Unused Code introduced by
The parameter event is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
77
        $('.overlay').show();
78
    });
79
});
80