Passed
Push — develop ( 4bb918...3adc5d )
by Andrew
05:50
created

src/assetbundles/imageoptimize/src/js/OptimizedImagesField.js   A

Complexity

Total Complexity 42
Complexity/F 1.45

Size

Lines of Code 286
Function Count 29

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 190
c 0
b 0
f 0
dl 0
loc 286
rs 9.0399
wmc 42
mnd 13
bc 13
fnc 29
bpm 0.4482
cpm 1.4482
noi 112

1 Function

Rating   Name   Duplication   Size   Complexity  
A OptimizedImagesField.js ➔ Plugin 0 10 2

How to fix   Complexity   

Complexity

Complex classes like src/assetbundles/imageoptimize/src/js/OptimizedImagesField.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
/**
2
 * Image Optimize plugin for Craft CMS
3
 *
4
 * OptimizedImages Field JS
5
 *
6
 * @author    nystudio107
7
 * @copyright Copyright (c) 2017 nystudio107
8
 * @link      https://nystudio107.com
9
 * @package   ImageOptimize
10
 * @since     1.2.0
11
 */
12
13
 ;(function ( $, window, document, undefined ) {
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...
Unused Code introduced by
The parameter window 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...
Unused Code introduced by
The parameter undefined 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...
14
15
    var pluginName = "ImageOptimizeOptimizedImages",
16
        defaults = {
17
        };
18
19
    // Plugin constructor
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 8 spaces, found 4
Loading history...
20
    function Plugin( element, options ) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 4
Loading history...
Coding Style introduced by
Opening brace should be on a new line
Loading history...
21
        this.element = element;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 12 spaces, found 8
Loading history...
22
23
        this.options = $.extend( {}, defaults, options) ;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 12 spaces, found 8
Loading history...
Coding Style introduced by
Space after opening parenthesis of function call prohibited
Loading history...
Coding Style introduced by
Space after closing parenthesis of function call prohibited
Loading history...
24
25
        this._defaults = defaults;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 12 spaces, found 8
Loading history...
26
        this._name = pluginName;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 12 spaces, found 8
Loading history...
27
28
        this.init();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 12 spaces, found 8
Loading history...
29
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 4
Loading history...
30
31
    Plugin.prototype = {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 8 spaces, found 4
Loading history...
32
33
        init: function(id) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 8
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
Unused Code introduced by
The parameter id 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...
34
            var _this = this;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 16 spaces, found 12
Loading history...
Unused Code introduced by
The variable _this seems to be never used. Consider removing it.
Loading history...
35
36
            $(function () {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 16 spaces, found 12
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
37
38
/* -- _this.options gives us access to the $jsonVars that our FieldType passed down to us */
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 20 spaces, found 0
Loading history...
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 16 spaces, but found 0.
Loading history...
39
40
            });
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 16 spaces, found 12
Loading history...
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
41
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 8
Loading history...
42
    };
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 4
Loading history...
43
44
    // A really lightweight plugin wrapper around the constructor,
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 8 spaces, found 4
Loading history...
45
    // preventing against multiple instantiations
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 8 spaces, found 4
Loading history...
46
    $.fn[pluginName] = function ( options ) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 8 spaces, found 4
Loading history...
47
        return this.each(function () {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 12 spaces, found 8
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
48
            if (!$.data(this, "plugin_" + pluginName)) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 16 spaces, found 12
Loading history...
49
                $.data(this, "plugin_" + pluginName,
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 20 spaces, found 16
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
50
                new Plugin( this, options ));
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 20 spaces, found 16
Loading history...
Coding Style introduced by
Space after opening parenthesis of function call prohibited
Loading history...
Coding Style introduced by
Expected 0 spaces before closing parenthesis; 1 found
Loading history...
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
51
            }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 16 spaces, found 12
Loading history...
52
        });
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 8
Loading history...
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
53
    };
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 4
Loading history...
54
55
})( jQuery, window, document );
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 1 spaces, found 0
Loading history...
Coding Style introduced by
Space after opening parenthesis of function call prohibited
Loading history...
Coding Style introduced by
Expected 0 spaces before closing parenthesis; 1 found
Loading history...
56
57
Craft.OptimizedImagesInput = Garnish.Base.extend(
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 1 spaces, found 0
Loading history...
Bug introduced by
The variable Garnish seems to be never declared. If this is a global, consider adding a /** global: Garnish */ 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...
Bug introduced by
The variable Craft seems to be never declared. If this is a global, consider adding a /** global: Craft */ 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...
58
    {
59
        id: null,
60
        inputNamePrefix: null,
61
        inputIdPrefix: null,
62
63
        $container: null,
64
        $blockContainer: null,
65
        $addBlockBtnContainer: null,
66
        $addBlockBtnGroup: null,
67
        $addBlockBtnGroupBtns: null,
68
69
        blockSort: null,
70
        blockSelect: null,
71
72
        init: function(id, inputNamePrefix, sizesWrapperId) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
Unused Code introduced by
The parameter sizesWrapperId 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
74
            this.id = id;
75
            this.inputNamePrefix = inputNamePrefix;
76
            this.inputIdPrefix = Craft.formatInputId(this.inputNamePrefix);
0 ignored issues
show
Bug introduced by
The variable Craft seems to be never declared. If this is a global, consider adding a /** global: Craft */ 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...
77
78
            this.$container = $('#' + this.id);
79
            this.$blockContainer = this.$container.children('.variant-blocks');
80
            this.$addBlockBtnContainer = this.$container.children('.buttons');
81
            this.$addBlockBtnGroup = this.$addBlockBtnContainer.children('.btngroup');
82
            this.$addBlockBtnGroupBtns = this.$addBlockBtnGroup.children('.btn');
83
84
            // Create our action button menus
85
            var _this = this;
86
            this.$blockContainer.find('> > .actions > .settings').each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
87
                var $value = $(value);
88
                var menuBtn;
89
                if ($value.data('menubtn')) {
90
                    menuBtn = $value.data('menubtn');
91
                } else {
92
                    menuBtn = new Garnish.MenuBtn(value);
0 ignored issues
show
Bug introduced by
The variable Garnish seems to be never declared. If this is a global, consider adding a /** global: Garnish */ 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...
93
                }
94
                menuBtn.menu.settings.onOptionSelect = $.proxy(function(option) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
95
                    this.onMenuOptionSelect(option, menuBtn);
96
                }, _this);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
97
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
98
99
            var $blocks = this.$blockContainer.children();
100
101
            this.blockSort = new Garnish.DragSort($blocks, {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Bug introduced by
The variable Garnish seems to be never declared. If this is a global, consider adding a /** global: Garnish */ 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...
102
                handle: '> .actions > .move',
103
                axis: 'y',
104
                collapseDraggees: true,
105
                magnetStrength: 4,
106
                helperLagBase: 1.5,
107
                helperOpacity: 0.9,
108
                onSortChange: $.proxy(function() {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
109
                    this.resetVariantBlockOrder();
110
                }, this)
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
111
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
112
113
            this.addListener(this.$addBlockBtnGroupBtns, 'click', function(ev) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
114
                var type = $(ev.target).data('type');
0 ignored issues
show
Unused Code introduced by
The variable type seems to be never used. Consider removing it.
Loading history...
115
                this.addVariantBlock(null);
116
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
117
118
            this.addAspectRatioHandlers();
119
            this.reIndexVariants();
120
        },
121
122
        onMenuOptionSelect: function(option, menuBtn) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
123
            var $option = $(option);
124
            var container = menuBtn.$btn.closest('.matrixblock');
125
126
            switch ($option.data('action')) {
127
                case 'add': {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
128
                    this.addVariantBlock(container);
129
                    break;
130
                }
131
                case 'delete': {
132
                    if (!$option.hasClass('disabled')) {
133
                        this.deleteVariantBlock(container);
134
                    }
135
                    break;
136
                }
137
            }
138
        },
139
140
        getHiddenBlockCss: function($block) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
141
            return {
142
                opacity: 0,
143
                marginBottom: -($block.outerHeight())
144
            };
145
        },
146
147
        // Re-index all of the variant blocks
148
        reIndexVariants: function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
149
            this.$blockContainer = this.$container.children('.variant-blocks');
150
            var $blocks = this.$blockContainer.children();
151
            $blocks.each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
152
                var variantIndex = index;
153
                var $value = $(value);
154
                var elements = $value.find('div .field, label, input, select');
155
156
                // Re-index all of the element attributes
157
                $(elements).each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
158
                    // id attributes
159
                    var str = $(value).attr('id');
160
                    if (str) {
161
                        str = str.replace(/\-([0-9]+)\-/g, "-" + variantIndex +"-");
162
                        $(value).attr('id', str);
163
                    }
164
                    // for attributes
165
                    str = $(value).attr('for');
166
                    if (str) {
167
                        str = str.replace(/\-([0-9]+)\-/g, "-" + variantIndex +"-");
168
                        $(value).attr('for', str);
169
                    }
170
                    // Name attributes
171
                    str = $(value).attr('name');
172
                    if (str) {
173
                        str = str.replace(/\[([0-9]+)\]/g, "[" + variantIndex +"]");
174
                        $(value).attr('name', str);
175
                    }
176
                });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
177
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
178
            var disabledDeleteItem = false;
179
            // If we only have one block, don't allow it to be deleted
180
            if ($blocks.length == 1) {
0 ignored issues
show
Best Practice introduced by
Comparing $blocks.length to 1 using the == operator is not safe. Consider using === instead.
Loading history...
181
                disabledDeleteItem = true;
182
            }
183
            $blocks.find('> .actions > .settings').each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
184
                var $value = $(value);
185
                var menuBtn;
186
                if ($value.data('menubtn')) {
187
                    menuBtn = $value.data('menubtn');
188
                    $menuItem = $(menuBtn.menu.$menuList[1]);
0 ignored issues
show
Bug introduced by
The variable $menuItem seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$menuItem.
Loading history...
189
                    if (disabledDeleteItem) {
190
                        $menuItem.find("> li > a").addClass('disabled').disable();
191
                    } else {
192
                        $menuItem.find("> li > a").removeClass('disabled').enable();
193
                    }
194
                }
195
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
196
197
        },
198
199
        addAspectRatioHandlers: function () {
200
            this.addListener($('.lightswitch'), 'click', function(ev) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
201
                var $target = $(ev.target);
202
                var $block = $target.closest('.matrixblock');
203
                $block.find('.io-aspect-ratio-wrapper').slideToggle();
204
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
205
            this.addListener($('.io-select-ar-box'), 'click', function(ev) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
206
                var $target = $(ev.target);
207
                var x = $(ev.target).data('x'),
208
                    y = $(ev.target).data('y'),
209
                    custom = $(ev.target).data('custom'),
210
                    field, $block;
211
                // Select the appropriate aspect ratio
212
                $block = $target.closest('.matrixblock');
213
                $block.find('.io-select-ar-box').each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
214
                    $(value).removeClass('io-selected-ar-box');
215
                });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
216
                $target.addClass('io-selected-ar-box');
217
218
                // Handle setting the actual field values
219
                if (custom) {
220
                    $block.find('.io-custom-ar-wrapper').slideDown();
221
                } else {
222
                    $block.find('.io-custom-ar-wrapper').slideUp();
223
                    field = $block.find('input')[2];
224
                    $(field).val(x);
225
                    field = $block.find('input')[3];
226
                    $(field).val(y);
227
                }
228
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
229
        },
230
231
        addVariantBlock: function(container) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
232
            var _this = this;
233
            $block = $(this.$blockContainer.children()[0]).clone();
0 ignored issues
show
Bug introduced by
The variable $block seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$block.
Loading history...
234
            // Reset to default values
235
            $block.find('.io-select-ar-box').each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
236
                if (index === 0) {
237
                    $(value).addClass('io-selected-ar-box');
238
                } else {
239
                    $(value).removeClass('io-selected-ar-box');
240
                }
241
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
242
            $block.find('.io-custom-ar-wrapper').hide();
243
            field = $block.find('input')[0];
0 ignored issues
show
Bug introduced by
The variable field seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.field.
Loading history...
244
            $(field).val(1200);
245
            field = $block.find('input')[1];
246
            $(field).val(1);
247
            field = $block.find('input')[2];
248
            $(field).val(16);
249
            field = $block.find('input')[3];
250
            $(field).val(9);
251
            field = $block.find('select')[0];
252
            $(field).val(82);
253
            field = $block.find('select')[1];
254
            $(field).val('jpg');
255
            $block.css(this.getHiddenBlockCss($block)).velocity({
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
256
                opacity: 1,
257
                'margin-bottom': 10
258
            }, 'fast', $.proxy(function() {
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 16 spaces, but found 12.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
259
260
                // Insert the block in the right place
261
                if (container) {
262
                    $block.insertBefore(container);
263
                } else {
264
                    $block.appendTo(this.$blockContainer);
265
                }
266
                // Update the Garnish UI controls
267
                this.blockSort.addItems($block);
268
                this.addAspectRatioHandlers();
269
                $block.find('.settings').each(function (index, value) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
270
                    var $value = $(value),
271
                        menuBtn,
272
                        menu;
273
274
                    menu = _this.$container.find('.io-menu-clone > .menu').clone();
275
                    $(menu).insertAfter($value);
276
                    menuBtn = new Garnish.MenuBtn(value);
0 ignored issues
show
Bug introduced by
The variable Garnish seems to be never declared. If this is a global, consider adding a /** global: Garnish */ 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...
277
278
                    menuBtn.menu.settings.onOptionSelect = $.proxy(function(option) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
279
                        _this.onMenuOptionSelect(option, menuBtn);
280
                    }, this);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
281
                });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
282
                this.reIndexVariants();
283
            }, this));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
284
        },
285
286
        deleteVariantBlock: function(container) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
287
            var _this = this;
288
            container.velocity(this.getHiddenBlockCss(container), 'fast', $.proxy(function() {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
289
                container.remove();
290
                _this.reIndexVariants();
291
            }, this));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
292
        },
293
294
        resetVariantBlockOrder: function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
295
            this.reIndexVariants();
296
        }
297
298
    });
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 0 spaces, but found 4.
Loading history...
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
299