Passed
Branch 2.3 (11c7e7)
by Kenny
02:58
created

  A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
1
if (!jQuery('.scw-cookie').hasClass('scw-cookie-out')) {
2
    jQuery(document).find('body').addClass('scw-cookie-in');
3
}
4
5
function scwCookieHide()
6
{
7
    jQuery.post(
8
        '/scwCookie/ajax.php',
9
        {
10
            action : 'hide'
11
        }
12
    ).done(function(data){
13
        if (data.hasOwnProperty('success') && data.success) {
14
            jQuery('.scw-cookie').addClass('scw-cookie-slide-out');
15
            jQuery(document).find('body').removeClass('scw-cookie-in');            
16
        }
17
18
        if (jQuery('.scw-cookie').hasClass('changed')) {
19
            location.reload();
20
        }
21
    });
22
}
23
24
function scwCookieDetails()
25
{
26
    jQuery('.scw-cookie-details').slideToggle();
27
}
28
29
function scwCookieToggle(element)
30
{
31
    jQuery(element).closest('.scw-cookie-toggle').find('input[type="checkbox"]').click();
32
}
33
34
function scwCookiePanelToggle()
35
{
36
    jQuery('.scw-cookie').removeClass('scw-cookie-out');
37
    if (jQuery(document).find('body').hasClass('scw-cookie-in')) {
38
        jQuery('.scw-cookie').addClass('scw-cookie-slide-out');
39
        jQuery(document).find('body').removeClass('scw-cookie-in');
40
    } else {
41
        jQuery('.scw-cookie').removeClass('scw-cookie-slide-out');
42
        jQuery(document).find('body').addClass('scw-cookie-in');
43
    }
44
}
45
46
jQuery(document).ready(function($){
47
    $('.scw-cookie-switch input').each(function(){
48
        if ($(this).prop('checked')) {
49
            $(this).closest('.scw-cookie-switch').addClass('checked');
50
        } else {
51
            $(this).closest('.scw-cookie-switch').removeClass('checked');
52
        }
53
    });
54
});
55
jQuery(document).on('change', '.scw-cookie-toggle input[type="checkbox"]', function(){
56
    jQuery(this).closest('.scw-cookie').addClass('changed');
57
    jQuery(this).closest('.scw-cookie-switch').toggleClass('checked');
58
    jQuery.post(
59
        '/scwCookie/ajax.php',
60
        {
61
            action : 'toggle',
62
            name   : jQuery(this).attr('name'),
63
            value  : jQuery(this).prop('checked')
64
        }
65
    ).done(function(data){
66
        if (data.hasOwnProperty('removeCookies')) {
67
            jQuery.each(data.removeCookies, function(key, cookie){
68
                document.cookie = cookie+'=; Max-Age=-99999999;';
69
            });
70
        }
71
    });
72
});
73
74
jQuery(document).ready(function($){
75
    $('.scw-cookie-tooltip-trigger').hover(function(){
76
        var label = $(this).attr('data-label');
77
        $(this).append('<span class="scw-cookie-tooltip">'+label+'</span>');
78
    }, function(){
79
        $(this).find('.scw-cookie-tooltip').remove();
80
    });
81
});
82
83
jQuery(document).ready(function($){
0 ignored issues
show
Unused Code introduced by
The parameter $ 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...
84
    jQuery.post(
85
        '/scwCookie/ajax.php',
86
        {
87
            action : 'load',
88
        }
89
    ).done(function(data){
90
        if (data.hasOwnProperty('removeCookies')) {
91
            jQuery.each(data.removeCookies, function(key, cookie){
92
                document.cookie = cookie.name+'=; Max-Age=-99999999; Domain='+cookie.domain+';';
93
                document.cookie = cookie.name+'=; Max-Age=-99999999;';
94
            });
95
        }
96
    });
97
});
98