Resources/views/frontend/_public/src/js/jquery.off-canvas-variant-switch.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 63
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 63
rs 10
c 1
b 0
f 0
wmc 6
mnd 0
bc 6
fnc 6
bpm 1
cpm 1
noi 1

4 Functions

Rating   Name   Duplication   Size   Complexity  
A $.plugin(ꞌdnOffCanvasVariantSwitchꞌ).init 0 21 1
A $.subscribe(ꞌplugin/swCollapseCart/onLoadCartFinishedꞌ) 0 7 1
A $.subscribe(ꞌplugin/swCollapseCart/onRemoveArticleFinishedꞌ) 0 7 1
A $.subscribe(ꞌplugin/swCollapseCart/onArticleAddedꞌ) 0 7 1
1
;(function($, window, document) {
0 ignored issues
show
Unused Code introduced by
The parameter document 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...
2
    'use strict';
3
4
    $.plugin('dnOffCanvasVariantSwitch', {
5
6
        defaults: {
7
            url: '',
8
            basketId: 0,
9
            articleId: 0,
10
            number: '',
11
            quantity: 0,
12
            offCanvas: false
13
        },
14
15
        init: function () {
16
            var me = this;
17
18
            me.applyDataAttributes();
19
20
            $.ajax({
21
                data: me.opts,
22
                url: me.opts.url,
23
                type: "GET",
24
                dataType: "html",
25
                success: function (response) {
26
                    me.$el.html(response);
27
28
                    window.StateManager.addPlugin(
29
                        '*[data-variant-switch="true"]',
30
                        'dnVariantSwitch',
31
                        ['xs', 's', 'm', 'l', 'xl']
32
                    );
33
                }
34
            });
35
        }
36
37
    });
38
39
    $.subscribe("plugin/swCollapseCart/onLoadCartFinished", function() {
40
        window.StateManager.addPlugin(
41
            '*[data-off-canvas-variant-switch="true"]',
42
            'dnOffCanvasVariantSwitch',
43
            ['xs', 's', 'm', 'l', 'xl']
44
        );
45
    });
46
47
    $.subscribe("plugin/swCollapseCart/onArticleAdded", function() {
48
        window.StateManager.addPlugin(
49
            '*[data-off-canvas-variant-switch="true"]',
50
            'dnOffCanvasVariantSwitch',
51
            ['xs', 's', 'm', 'l', 'xl']
52
        );
53
    });
54
55
    $.subscribe("plugin/swCollapseCart/onRemoveArticleFinished", function() {
56
        window.StateManager.addPlugin(
57
            '*[data-off-canvas-variant-switch="true"]',
58
            'dnOffCanvasVariantSwitch',
59
            ['xs', 's', 'm', 'l', 'xl']
60
        );
61
    });
62
63
})(jQuery, window);