Passed
Push — develop ( 7495d5...7418b4 )
by Andrew
04:55
created

OptimizedImagesField.js ➔ Plugin   B

Complexity

Conditions 6

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 10
rs 8.6666
cc 6
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 humanFileSize(bytes, si=false, dp=1) {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
14
    const thresh = si ? 1000 : 1024;
15
16
    if (Math.abs(bytes) < thresh) {
17
        return bytes + ' B';
18
    }
19
20
    const units = si
21
        ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
22
        : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
23
    let u = -1;
24
    const r = 10**dp;
25
26
    do {
27
        bytes /= thresh;
28
        ++u;
29
    } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
30
31
32
    return bytes.toFixed(dp) + ' ' + units[u];
33
}
34
35
const images = document.querySelectorAll("img.io-prevew-image");
36
for (const image of images) {
37
    const url = image.src || image.href;
38
    if (url && url.length > 0) {
39
        const iTime = performance.getEntriesByName(url)[0];
0 ignored issues
show
Bug introduced by
The variable performance seems to be never declared. If this is a global, consider adding a /** global: performance */ 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...
40
        if (iTime !== undefined) {
41
            const elem = image.parentNode.parentNode.parentNode.nextElementSibling.querySelector('.io-file-size');
42
            if (elem) {
43
                elem.innerHTML = humanFileSize(iTime.decodedBodySize, true);
44
            }
45
        }
46
    }
47
}
48
49
;(function ( $, window, document, undefined ) {
0 ignored issues
show
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...
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...
50
51
    var pluginName = "ImageOptimizeOptimizedImages",
52
        defaults = {
53
        };
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
54
55
    // Plugin constructor
56
    function Plugin( element, options ) {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
57
        this.element = element;
58
59
        this.options = $.extend( {}, defaults, options) ;
0 ignored issues
show
Coding Style introduced by
Space after closing parenthesis of function call prohibited
Loading history...
Coding Style introduced by
Space after opening parenthesis of function call prohibited
Loading history...
60
61
        this._defaults = defaults;
62
        this._name = pluginName;
63
64
        this.init();
65
    }
66
67
    Plugin.prototype = {
68
69
        init: function(id) {
0 ignored issues
show
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...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
70
            var _this = this;
0 ignored issues
show
Unused Code introduced by
The variable _this seems to be never used. Consider removing it.
Loading history...
71
72
            $(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...
73
74
/* -- _this.options gives us access to the $jsonVars that our FieldType passed down to us */
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 0.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected at least 16 spaces, found 0
Loading history...
75
76
            });
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...
77
        }
78
    };
79
80
    // A really lightweight plugin wrapper around the constructor,
81
    // preventing against multiple instantiations
82
    $.fn[pluginName] = function ( options ) {
83
        return this.each(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...
84
            if (!$.data(this, "plugin_" + pluginName)) {
85
                $.data(this, "plugin_" + pluginName,
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
                new Plugin( this, options ));
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces before closing parenthesis; 1 found
Loading history...
Coding Style introduced by
Space after opening parenthesis of function call prohibited
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...
87
            }
88
        });
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...
89
    };
90
91
})( jQuery, window, document );
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces before closing parenthesis; 1 found
Loading history...
Coding Style introduced by
Space after opening parenthesis of function call prohibited
Loading history...
92
93
Craft.OptimizedImagesInput = Garnish.Base.extend(
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...
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...
94
    {
95
        id: null,
96
        inputNamePrefix: null,
97
        inputIdPrefix: null,
98
99
        $container: null,
100
        $blockContainer: null,
101
        $addBlockBtnContainer: null,
102
        $addBlockBtnGroup: null,
103
        $addBlockBtnGroupBtns: null,
104
105
        blockSort: null,
106
        blockSelect: null,
107
108
        init: function(id, inputNamePrefix, sizesWrapperId) {
0 ignored issues
show
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...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
109
110
            this.id = id;
111
            this.inputNamePrefix = inputNamePrefix;
112
            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...
113
114
            this.$container = $('#' + this.id);
115
            this.$blockContainer = this.$container.children('.variant-blocks');
116
            this.$addBlockBtnContainer = this.$container.children('.buttons');
117
            this.$addBlockBtnGroup = this.$addBlockBtnContainer.children('.btngroup');
118
            this.$addBlockBtnGroupBtns = this.$addBlockBtnGroup.children('.btn');
119
120
            // Create our action button menus
121
            var _this = this;
122
            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...
123
                var $value = $(value);
124
                var menuBtn;
125
                if ($value.data('menubtn')) {
126
                    menuBtn = $value.data('menubtn');
127
                } else {
128
                    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...
129
                }
130
                menuBtn.menu.settings.onOptionSelect = $.proxy(function(option) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
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...
131
                    this.onMenuOptionSelect(option, menuBtn);
132
                }, _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...
133
            });
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...
134
135
            var $blocks = this.$blockContainer.children();
136
137
            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...
138
                handle: '> .actions > .move',
139
                axis: 'y',
140
                collapseDraggees: true,
141
                magnetStrength: 4,
142
                helperLagBase: 1.5,
143
                helperOpacity: 0.9,
144
                onSortChange: $.proxy(function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
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...
145
                    this.resetVariantBlockOrder();
146
                }, 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...
147
            });
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...
148
149
            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...
150
                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...
151
                this.addVariantBlock(null);
152
            });
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...
153
154
            this.addAspectRatioHandlers();
155
            this.reIndexVariants();
156
        },
157
158
        onMenuOptionSelect: function(option, menuBtn) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
159
            var $option = $(option);
160
            var container = menuBtn.$btn.closest('.matrixblock');
161
162
            switch ($option.data('action')) {
163
                case 'add': {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
164
                    this.addVariantBlock(container);
165
                    break;
166
                }
167
                case 'delete': {
168
                    if (!$option.hasClass('disabled')) {
169
                        this.deleteVariantBlock(container);
170
                    }
171
                    break;
172
                }
173
            }
174
        },
175
176
        getHiddenBlockCss: function($block) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
177
            return {
178
                opacity: 0,
179
                marginBottom: -($block.outerHeight())
180
            };
181
        },
182
183
        // Re-index all of the variant blocks
184
        reIndexVariants: function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
185
            this.$blockContainer = this.$container.children('.variant-blocks');
186
            var $blocks = this.$blockContainer.children();
187
            $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...
188
                var variantIndex = index;
189
                var $value = $(value);
190
                var elements = $value.find('div .field, label, input, select');
191
192
                // Re-index all of the element attributes
193
                $(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...
194
                    // id attributes
195
                    var str = $(value).attr('id');
196
                    if (str) {
197
                        str = str.replace(/\-([0-9]+)\-/g, "-" + variantIndex +"-");
198
                        $(value).attr('id', str);
199
                    }
200
                    // for attributes
201
                    str = $(value).attr('for');
202
                    if (str) {
203
                        str = str.replace(/\-([0-9]+)\-/g, "-" + variantIndex +"-");
204
                        $(value).attr('for', str);
205
                    }
206
                    // Name attributes
207
                    str = $(value).attr('name');
208
                    if (str) {
209
                        str = str.replace(/\[([0-9]+)\]/g, "[" + variantIndex +"]");
210
                        $(value).attr('name', str);
211
                    }
212
                });
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...
213
            });
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...
214
            var disabledDeleteItem = false;
215
            // If we only have one block, don't allow it to be deleted
216
            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...
217
                disabledDeleteItem = true;
218
            }
219
            $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...
220
                var $value = $(value);
221
                var menuBtn;
222
                if ($value.data('menubtn')) {
223
                    menuBtn = $value.data('menubtn');
224
                    $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...
225
                    if (disabledDeleteItem) {
226
                        $menuItem.find("> li > a").addClass('disabled').disable();
227
                    } else {
228
                        $menuItem.find("> li > a").removeClass('disabled').enable();
229
                    }
230
                }
231
            });
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...
232
233
        },
234
235
        addAspectRatioHandlers: function () {
236
            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...
237
                var $target = $(ev.target);
238
                var $block = $target.closest('.matrixblock');
239
                $block.find('.io-aspect-ratio-wrapper').slideToggle();
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
            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...
242
                var $target = $(ev.target);
243
                var x = $(ev.target).data('x'),
244
                    y = $(ev.target).data('y'),
245
                    custom = $(ev.target).data('custom'),
246
                    field, $block;
247
                // Select the appropriate aspect ratio
248
                $block = $target.closest('.matrixblock');
249
                $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...
250
                    $(value).removeClass('io-selected-ar-box');
251
                });
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...
252
                $target.addClass('io-selected-ar-box');
253
254
                // Handle setting the actual field values
255
                if (custom) {
256
                    $block.find('.io-custom-ar-wrapper').slideDown();
257
                } else {
258
                    $block.find('.io-custom-ar-wrapper').slideUp();
259
                    field = $block.find('input')[2];
260
                    $(field).val(x);
261
                    field = $block.find('input')[3];
262
                    $(field).val(y);
263
                }
264
            });
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...
265
        },
266
267
        addVariantBlock: function(container) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
268
            var _this = this;
269
            $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...
270
            // Reset to default values
271
            $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...
272
                if (index === 0) {
273
                    $(value).addClass('io-selected-ar-box');
274
                } else {
275
                    $(value).removeClass('io-selected-ar-box');
276
                }
277
            });
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...
278
            $block.find('.io-custom-ar-wrapper').hide();
279
            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...
280
            $(field).val(1200);
281
            field = $block.find('input')[1];
282
            $(field).val(1);
283
            field = $block.find('input')[2];
284
            $(field).val(16);
285
            field = $block.find('input')[3];
286
            $(field).val(9);
287
            field = $block.find('select')[0];
288
            $(field).val(82);
289
            field = $block.find('select')[1];
290
            $(field).val('jpg');
291
            $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...
292
                opacity: 1,
293
                'margin-bottom': 10
294
            }, 'fast', $.proxy(function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
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 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...
295
296
                // Insert the block in the right place
297
                if (container) {
298
                    $block.insertBefore(container);
299
                } else {
300
                    $block.appendTo(this.$blockContainer);
301
                }
302
                // Update the Garnish UI controls
303
                this.blockSort.addItems($block);
304
                this.addAspectRatioHandlers();
305
                $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...
306
                    var $value = $(value),
307
                        menuBtn,
308
                        menu;
309
310
                    menu = _this.$container.find('.io-menu-clone > .menu').clone();
311
                    $(menu).insertAfter($value);
312
                    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...
313
314
                    menuBtn.menu.settings.onOptionSelect = $.proxy(function(option) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
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...
315
                        _this.onMenuOptionSelect(option, menuBtn);
316
                    }, 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...
317
                });
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...
318
                this.reIndexVariants();
319
            }, 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...
320
        },
321
322
        deleteVariantBlock: function(container) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
323
            var _this = this;
324
            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...
325
                container.remove();
326
                _this.reIndexVariants();
327
            }, 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...
328
        },
329
330
        resetVariantBlockOrder: function() {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
331
            this.reIndexVariants();
332
        }
333
334
    });
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...
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...
335