Skip to content

Commit e3bed3f

Browse files
MAGETWO-56849: Clean Up JS files code styles based on black list
1 parent bf854c4 commit e3bed3f

File tree

27 files changed

+780
-512
lines changed

27 files changed

+780
-512
lines changed

app/code/Magento/Catalog/view/adminhtml/requirejs-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
var config = {
6+
var config = {//eslint-disable-line no-unused-vars
77
map: {
88
'*': {
99
categoryForm: 'Magento_Catalog/catalog/category/form',
@@ -17,4 +17,4 @@ var config = {
1717
deps: [
1818
'Magento_Catalog/catalog/product'
1919
]
20-
};
20+
};

app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
/*global alert:true*/
67
define([
78
'jquery',
@@ -20,8 +21,10 @@ define([
2021
* @protected
2122
*/
2223
options: {
23-
maxImageUploadCount : 10
24+
maxImageUploadCount: 10
2425
},
26+
27+
/** @inheritdoc */
2528
_create: function () {
2629
var $container = this.element,
2730
imageTmpl = mageTemplate(this.element.find('[data-template=image]').html()),
@@ -30,22 +33,25 @@ define([
3033
mainClass = 'base-image',
3134
maximumImageCount = 5,
3235
$fieldCheckBox = $container.closest('[data-attribute-code=image]').find(':checkbox'),
33-
isDefaultChecked = $fieldCheckBox.is(':checked');
36+
isDefaultChecked = $fieldCheckBox.is(':checked'),
37+
findElement, updateVisibility;
3438

3539
if (isDefaultChecked) {
3640
$fieldCheckBox.trigger('click');
3741
}
3842

39-
var findElement = function (data) {
43+
findElement = function (data) {//jscs:ignore jsDoc
4044
return $container.find('.image:not(.image-placeholder)').filter(function () {
4145
if (!$(this).data('image')) {
4246
return false;
4347
}
48+
4449
return $(this).data('image').file === data.file;
4550
}).first();
4651
};
47-
var updateVisibility = function () {
52+
updateVisibility = function () {//jscs:ignore jsDoc
4853
var elementsList = $container.find('.image:not(.removed-item)');
54+
4955
elementsList.each(function (index) {
5056
$(this)[index < maximumImageCount ? 'show' : 'hide']();
5157
});
@@ -78,12 +84,13 @@ define([
7884
});
7985

8086
$galleryContainer.on('moveElement', function (event, data) {
81-
var $element = findElement(data.imageData);
87+
var $element = findElement(data.imageData),
88+
$after;
8289

8390
if (data.position === 0) {
8491
$container.prepend($element);
8592
} else {
86-
var $after = $container.find('.image').eq(data.position);
93+
$after = $container.find('.image').eq(data.position);
8794

8895
if (!$element.is($after)) {
8996
$element.insertAfter($after);
@@ -93,8 +100,10 @@ define([
93100
});
94101

95102
$container.on('click', '[data-role=make-base-button]', function (event) {
103+
var data;
104+
96105
event.preventDefault();
97-
var data = $(event.target).closest('.image').data('image');
106+
data = $(event.target).closest('.image').data('image');
98107
$galleryContainer.productGallery('setBase', data);
99108
});
100109

@@ -108,7 +117,7 @@ define([
108117
items: '.image:not(.image-placeholder)',
109118
distance: 8,
110119
tolerance: 'pointer',
111-
stop: function (event, data) {
120+
stop: function (event, data) {//jscs:ignore jsDoc
112121
$galleryContainer.trigger('setPosition', {
113122
imageData: data.item.data('image'),
114123
position: $container.find('.image').index(data.item)
@@ -122,7 +131,7 @@ define([
122131
dropZone: $dropPlaceholder.closest('[data-attribute-code]'),
123132
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
124133
maxFileSize: this.element.data('maxFileSize'),
125-
done: function (event, data) {
134+
done: function (event, data) {//jscs:ignore jsDoc
126135
$dropPlaceholder.find('.progress-bar').text('').removeClass('in-progress');
127136

128137
if (!data.result) {
@@ -137,35 +146,36 @@ define([
137146
});
138147
}
139148
},
140-
change: function(e, data) {
149+
change: function (e, data) {
141150
if (data.files.length > this.options.maxImageUploadCount) {
142151
$('body').notification('clear').notification('add', {
143152
error: true,
144-
message: $.mage.__('You can\'t upload more than ' + this.options.maxImageUploadCount
145-
+ ' images in one time'),
146-
insertMethod: function(message) {
153+
message: $.mage.__('You can\'t upload more than ' + this.options.maxImageUploadCount +
154+
' images in one time'),
155+
insertMethod: function (message) {//jscs:ignore jsDoc
147156
$('.page-main-actions').after(message);
148157
}
149158
});
150159

151160
return false;
152161
}
153162
}.bind(this),
154-
add: function (event, data) {
163+
add: function (event, data) {//jscs:ignore jsDoc
155164
$(this).fileupload('process', data).done(function () {
156165
data.submit();
157166
});
158167
},
159-
progress: function (e, data) {
168+
progress: function (e, data) {//jscs:ignore jsDoc
160169
var progress = parseInt(data.loaded / data.total * 100, 10);
170+
161171
$dropPlaceholder.find('.progress-bar').addClass('in-progress').text(progress + '%');
162172
},
163-
start: function (event) {
173+
start: function (event) {//jscs:ignore jsDoc
164174
var uploaderContainer = $(event.target).closest('.image-placeholder');
165175

166176
uploaderContainer.addClass('loading');
167177
},
168-
stop: function (event) {
178+
stop: function (event) {//jscs:ignore jsDoc
169179
var uploaderContainer = $(event.target).closest('.image-placeholder');
170180

171181
uploaderContainer.removeClass('loading');

app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,81 @@
55
/**
66
* Create/edit some category
77
*/
8+
9+
/* global tree */
810
define([
911
'jquery',
1012
'prototype'
1113
], function (jQuery) {
14+
'use strict';
15+
16+
var categorySubmit = function () {//jscs:ignore jsDoc
17+
var activeTab = $('active_tab_id'),
18+
params = {},
19+
fields, i,categoryId, isCreating, path, parentId, currentNode, oldClass, newClass;
1220

13-
var categorySubmit = function (url, useAjax) {
14-
var activeTab = $('active_tab_id');
15-
if (activeTab) {
16-
if (activeTab.tabsJsObject && activeTab.tabsJsObject.tabs('activeAnchor')) {
17-
activeTab.value = activeTab.tabsJsObject.tabs('activeAnchor').prop('id');
21+
if (activeTab) {
22+
if (activeTab.tabsJsObject && activeTab.tabsJsObject.tabs('activeAnchor')) {
23+
activeTab.value = activeTab.tabsJsObject.tabs('activeAnchor').prop('id');
24+
}
1825
}
19-
}
2026

21-
var params = {};
22-
var fields = $('category_edit_form').getElementsBySelector('input', 'select');
23-
for (var i=0; i<fields.length; i++) {
24-
if (!fields[i].name) {
25-
continue;
27+
fields = $('category_edit_form').getElementsBySelector('input', 'select');
28+
29+
for (i = 0; i < fields.length; i++) {
30+
if (!fields[i].name) {
31+
continue;//jscs:ignore
32+
}
33+
params[fields[i].name] = fields[i].getValue();
2634
}
27-
params[fields[i].name] = fields[i].getValue();
28-
}
2935

30-
// Get info about what we're submitting - to properly update tree nodes
31-
var categoryId = params['general[id]'] ? params['general[id]'] : 0;
32-
var isCreating = categoryId == 0; // Separate variable is needed because '0' in javascript converts to TRUE
33-
var path = params['general[path]'].split('/');
34-
var parentId = path.pop();
35-
if (parentId == categoryId) { // Maybe path includes category id itself
36+
// Get info about what we're submitting - to properly update tree nodes
37+
categoryId = params['general[id]'] ? params['general[id]'] : 0;
38+
isCreating = categoryId == 0; // eslint-disable-line eqeqeq
39+
path = params['general[path]'].split('/');
3640
parentId = path.pop();
37-
}
3841

39-
// Make operations with category tree
40-
if (isCreating) {
41-
/* Some specific tasks for creating category */
42-
if (!tree.currentNodeId) {
43-
// First submit of form - select some node to be current
44-
tree.currentNodeId = parentId;
42+
if (parentId == categoryId) { // eslint-disable-line eqeqeq
43+
parentId = path.pop();
4544
}
46-
tree.addNodeTo = parentId;
47-
} else {
48-
/* Some specific tasks for editing category */
49-
// Maybe change category enabled/disabled style
50-
if (tree && tree.storeId==0) {
51-
var currentNode = tree.getNodeById(categoryId);
5245

53-
if (currentNode) {
54-
if (parseInt(params['general[is_active]'])) {
55-
var oldClass = 'no-active-category';
56-
var newClass = 'active-category';
57-
} else {
58-
var oldClass = 'active-category';
59-
var newClass = 'no-active-category';
60-
}
46+
// Make operations with category tree
47+
if (isCreating) {
48+
/* Some specific tasks for creating category */
49+
if (!tree.currentNodeId) {
50+
// First submit of form - select some node to be current
51+
tree.currentNodeId = parentId;
52+
}
53+
tree.addNodeTo = parentId;
54+
} else {
55+
/* Some specific tasks for editing category */
56+
// Maybe change category enabled/disabled style
57+
if (tree && tree.storeId == 0) {// eslint-disable-line eqeqeq, no-lonely-if
58+
currentNode = tree.getNodeById(categoryId);
59+
60+
if (currentNode) {//eslint-disable-line max-depth
61+
if (parseInt(params['general[is_active]'])) {//eslint-disable-line radix, max-depth
62+
oldClass = 'no-active-category';
63+
newClass = 'active-category';
64+
} else {
65+
oldClass = 'active-category';
66+
newClass = 'no-active-category';
67+
}
6168

62-
Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
63-
Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
69+
Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
70+
Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
71+
}
6472
}
6573
}
66-
}
6774

68-
// Submit form
69-
jQuery('#category_edit_form').trigger('submit');
70-
};
75+
// Submit form
76+
jQuery('#category_edit_form').trigger('submit');
77+
};
7178

7279
return function (config, element) {
7380
config = config || {};
74-
jQuery(element).on('click', function (event) {
81+
jQuery(element).on('click', function () {
7582
categorySubmit(config.url, config.ajax);
7683
});
7784
};
78-
});
85+
});

app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
/*global alert:true*/
7-
86
define([
97
'jquery',
108
'Magento_Ui/js/modal/alert'

app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
define([
67
'jquery',
78
'underscore',
@@ -12,19 +13,25 @@ define([
1213
'use strict';
1314

1415
$.widget('mage.productAttributes', {
16+
/** @inheritdoc */
1517
_create: function () {
1618
this._on({
1719
'click': '_showPopup'
1820
});
1921
},
2022

23+
/**
24+
* @private
25+
*/
2126
_initModal: function () {
2227
var self = this;
2328

2429
this.modal = $('<div id="create_new_attribute"/>').modal({
25-
title: $.mage.__('New Attribute'),
30+
title: $.mage.__('New Attribute'),
2631
type: 'slide',
2732
buttons: [],
33+
34+
/** @inheritdoc */
2835
opened: function () {
2936
$(this).parent().addClass('modal-content-new-attribute');
3037
self.iframe = $('<iframe id="create_new_attribute_container">').attr({
@@ -35,6 +42,8 @@ define([
3542
self._changeIframeSize();
3643
$(window).off().on('resize.modal', _.debounce(self._changeIframeSize.bind(self), 400));
3744
},
45+
46+
/** @inheritdoc */
3847
closed: function () {
3948
var doc = self.iframe.get(0).document;
4049

@@ -49,6 +58,10 @@ define([
4958
});
5059
},
5160

61+
/**
62+
* @return {Number}
63+
* @private
64+
*/
5265
_getHeight: function () {
5366
var modal = this.modal.data('modal').modal,
5467
modalHead = modal.find('header'),
@@ -59,17 +72,28 @@ define([
5972
return modalHeight - modalHeadHeight - modalContentPadding;
6073
},
6174

75+
/**
76+
* @return {Number}
77+
* @private
78+
*/
6279
_getWidth: function () {
6380
return this.modal.width();
6481
},
6582

83+
/**
84+
* @private
85+
*/
6686
_changeIframeSize: function () {
6787
this.modal.parent().outerHeight(this._getHeight());
6888
this.iframe.outerHeight(this._getHeight());
6989
this.iframe.outerWidth(this._getWidth());
7090

7191
},
7292

93+
/**
94+
* @return {String}
95+
* @private
96+
*/
7397
_prepareUrl: function () {
7498
var productSource,
7599
attributeSetId = '';
@@ -86,6 +110,9 @@ define([
86110
'set=' + attributeSetId;
87111
},
88112

113+
/**
114+
* @private
115+
*/
89116
_showPopup: function () {
90117
this._initModal();
91118
this.modal.modal('openModal');

0 commit comments

Comments
 (0)