src/widgets/formInputs/componentSettings/assets/component-settings.js   A
last analyzed

Complexity

Total Complexity 13
Complexity/F 1.18

Size

Lines of Code 87
Function Count 11

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
nc 1
dl 0
loc 87
rs 10
c 0
b 0
f 0
wmc 13
mnd 1
bc 14
fnc 11
bpm 1.2727
cpm 1.1818
noi 3

8 Functions

Rating   Name   Duplication   Size   Complexity  
A sx.classes.Component.extend.goEdit 0 11 1
A sx.classes.Component.extend.getjComponentSelect 0 4 1
A sx.classes.Component.extend.getjWrapper 0 4 1
A sx.classes.Component.extend._onDomReady 0 19 1
A sx.classes.Component.extend.save 0 12 2
A sx.classes.Component.extend.getjBtnEdit 0 4 1
A sx.classes.Component.extend.update 0 13 2
A sx.classes.Component.extend.getjComponentSettings 0 4 1
1
/*!
2
 * @author Semenov Alexander <[email protected]>
3
 * @link http://skeeks.com/
4
 * @copyright 2010 SkeekS (СкикС)
5
 * @date 09.06.2015
6
 */
7
(function(sx, $, _)
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...
8
{
9
    sx.classes.ComponentSettingsWidget = sx.classes.Component.extend({
10
11
        getjWrapper: function()
12
        {
13
            return $("#" + this.get('id'));
14
        },
15
16
        getjBtnEdit: function()
17
        {
18
            return $(".sx-btn-edit", this.getjWrapper());
19
        },
20
21
        getjComponentSelect: function()
22
        {
23
            return $("#" + this.get('componentSelectId'));
24
        },
25
        getjComponentSettings: function()
26
        {
27
            return $("#" + this.get('componentSettingsId'));
28
        },
29
30
        _onDomReady: function()
31
        {
32
            var self = this;
33
34
            this.getjComponentSelect().on("change", function()
35
            {
36
                self.currentComponent = $(this).val();
37
                self.update();
38
            });
39
40
            this.getjBtnEdit().on('click', function()
41
            {
42
                self.goEdit();
43
                return false;
44
            });
45
46
            this.currentComponent = this.getjComponentSelect().val();
47
            self.update();
48
        },
49
50
        /**
51
         * Обновление текущего состояния
52
         * @returns {sx.classes.ComponentSettingsWidget}
53
         */
54
        update: function()
55
        {
56
            var self = this;
57
58
            if (!self.currentComponent)
59
            {
60
                this.getjBtnEdit().hide();
61
            } else
62
            {
63
                this.getjBtnEdit().show();
64
            }
65
            return this;
66
        },
67
68
        save: function(dataStringB64)
69
        {
70
            var old = this.getjComponentSettings().val();
71
            this.getjComponentSettings().val(dataStringB64);
72
            var newVal = this.getjComponentSettings().val();
73
74
            if (newVal != old)
75
            {
76
                console.log('changed');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
77
            }
78
            this.windowObject.close();
79
        },
80
81
        goEdit: function()
82
        {
83
            var url = this.get('backend');
84
                url = url + '?';
85
                url = url + "&component=" + this.currentComponent;
86
                url = url + "&settings="  + this.getjComponentSettings().val();
87
                url = url + "&callbackComonentId="  + this.get('id');
88
89
            this.windowObject = new sx.classes.Window(url);
90
            this.windowObject.open();
91
        },
92
    });
93
})(sx, sx.$, sx._);
0 ignored issues
show
Bug introduced by
The variable sx seems to be never declared. If this is a global, consider adding a /** global: sx */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...