Passed
Push — develop ( 9c3cb1...fa89b0 )
by Andrew
05:01
created

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

Complexity

Total Complexity 42
Complexity/F 1.45

Size

Lines of Code 285
Function Count 29

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

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) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
73
            this.id = id;
74
            this.inputNamePrefix = inputNamePrefix;
75
            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...
76
77
            this.$container = $('#' + this.id);
78
            this.$blockContainer = this.$container.children('.variant-blocks');
79
            this.$addBlockBtnContainer = this.$container.children('.buttons');
80
            this.$addBlockBtnGroup = this.$addBlockBtnContainer.children('.btngroup');
81
            this.$addBlockBtnGroupBtns = this.$addBlockBtnGroup.children('.btn');
82
83
            // Create our action button menus
84
            var _this = this;
85
            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...
86
                var $value = $(value);
87
                var menuBtn;
88
                if ($value.data('menubtn')) {
89
                    menuBtn = $value.data('menubtn');
90
                } else {
91
                    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...
92
                }
93
                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...
94
                    this.onMenuOptionSelect(option, menuBtn);
95
                }, _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...
96
            });
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
98
            var $blocks = this.$blockContainer.children();
99
100
            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...
101
                handle: '> .actions > .move',
102
                axis: 'y',
103
                collapseDraggees: true,
104
                magnetStrength: 4,
105
                helperLagBase: 1.5,
106
                helperOpacity: 0.9,
107
                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...
108
                    this.resetVariantBlockOrder();
109
                }, 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...
110
            });
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
112
            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...
113
                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...
114
                this.addVariantBlock(null);
115
            });
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...
116
117
            this.addAspectRatioHandlers();
118
            this.reIndexVariants();
119
        },
120
121
        onMenuOptionSelect: function(option, menuBtn) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
122
            var $option = $(option);
123
            var container = menuBtn.$btn.closest('.matrixblock');
124
125
            switch ($option.data('action')) {
126
                case 'add': {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
127
                    this.addVariantBlock(container);
128
                    break;
129
                }
130
                case 'delete': {
131
                    if (!$option.hasClass('disabled')) {
132
                        this.deleteVariantBlock(container);
133
                    }
134
                    break;
135
                }
136
            }
137
        },
138
139
        getHiddenBlockCss: function($block) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
140
            return {
141
                opacity: 0,
142
                marginBottom: -($block.outerHeight())
143
            };
144
        },
145
146
        // Re-index all of the variant blocks
147
        reIndexVariants: function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
148
            this.$blockContainer = this.$container.children('.variant-blocks');
149
            var $blocks = this.$blockContainer.children();
150
            $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...
151
                var variantIndex = index;
152
                var $value = $(value);
153
                var elements = $value.find('div .field, label, input, select');
154
155
                // Re-index all of the element attributes
156
                $(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...
157
                    // id attributes
158
                    var str = $(value).attr('id');
159
                    if (str) {
160
                        str = str.replace(/\-([0-9]+)\-/g, "-" + variantIndex +"-");
161
                        $(value).attr('id', str);
162
                    }
163
                    // for attributes
164
                    str = $(value).attr('for');
165
                    if (str) {
166
                        str = str.replace(/\-([0-9]+)\-/g, "-" + variantIndex +"-");
167
                        $(value).attr('for', str);
168
                    }
169
                    // Name attributes
170
                    str = $(value).attr('name');
171
                    if (str) {
172
                        str = str.replace(/\[([0-9]+)\]/g, "[" + variantIndex +"]");
173
                        $(value).attr('name', str);
174
                    }
175
                });
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...
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
            var disabledDeleteItem = false;
178
            // If we only have one block, don't allow it to be deleted
179
            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...
180
                disabledDeleteItem = true;
181
            }
182
            $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...
183
                var $value = $(value);
184
                var menuBtn;
185
                if ($value.data('menubtn')) {
186
                    menuBtn = $value.data('menubtn');
187
                    $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...
188
                    if (disabledDeleteItem) {
189
                        $menuItem.find("> li > a").addClass('disabled').disable();
190
                    } else {
191
                        $menuItem.find("> li > a").removeClass('disabled').enable();
192
                    }
193
                }
194
            });
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...
195
196
        },
197
198
        addAspectRatioHandlers: function () {
199
            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...
200
                var $target = $(ev.target);
201
                var $block = $target.closest('.matrixblock');
202
                $block.find('.io-aspect-ratio-wrapper').slideToggle();
203
            });
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...
204
            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...
205
                var $target = $(ev.target);
206
                var x = $(ev.target).data('x'),
207
                    y = $(ev.target).data('y'),
208
                    custom = $(ev.target).data('custom'),
209
                    field, $block;
210
                // Select the appropriate aspect ratio
211
                $block = $target.closest('.matrixblock');
212
                $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...
213
                    $(value).removeClass('io-selected-ar-box');
214
                });
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...
215
                $target.addClass('io-selected-ar-box');
216
217
                // Handle setting the actual field values
218
                if (custom) {
219
                    $block.find('.io-custom-ar-wrapper').slideDown();
220
                } else {
221
                    $block.find('.io-custom-ar-wrapper').slideUp();
222
                    field = $block.find('input')[2];
223
                    $(field).val(x);
224
                    field = $block.find('input')[3];
225
                    $(field).val(y);
226
                }
227
            });
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...
228
        },
229
230
        addVariantBlock: function(container) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
231
            var _this = this;
232
            $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...
233
            // Reset to default values
234
            $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...
235
                if (index === 0) {
236
                    $(value).addClass('io-selected-ar-box');
237
                } else {
238
                    $(value).removeClass('io-selected-ar-box');
239
                }
240
            });
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...
241
            $block.find('.io-custom-ar-wrapper').hide();
242
            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...
243
            $(field).val(1200);
244
            field = $block.find('input')[1];
245
            $(field).val(1);
246
            field = $block.find('input')[2];
247
            $(field).val(16);
248
            field = $block.find('input')[3];
249
            $(field).val(9);
250
            field = $block.find('select')[0];
251
            $(field).val(82);
252
            field = $block.find('select')[1];
253
            $(field).val('jpg');
254
            $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...
255
                opacity: 1,
256
                'margin-bottom': 10
257
            }, '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...
258
259
                // Insert the block in the right place
260
                if (container) {
261
                    $block.insertBefore(container);
262
                } else {
263
                    $block.appendTo(this.$blockContainer);
264
                }
265
                // Update the Garnish UI controls
266
                this.blockSort.addItems($block);
267
                this.addAspectRatioHandlers();
268
                $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...
269
                    var $value = $(value),
270
                        menuBtn,
271
                        menu;
272
273
                    menu = _this.$container.find('.io-menu-clone > .menu').clone();
274
                    $(menu).insertAfter($value);
275
                    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...
276
277
                    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...
278
                        _this.onMenuOptionSelect(option, menuBtn);
279
                    }, 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...
280
                });
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
                this.reIndexVariants();
282
            }, 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...
283
        },
284
285
        deleteVariantBlock: function(container) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
286
            var _this = this;
287
            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...
288
                container.remove();
289
                _this.reIndexVariants();
290
            }, 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...
291
        },
292
293
        resetVariantBlockOrder: function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
294
            this.reIndexVariants();
295
        }
296
297
    });
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...