3
3
* See COPYING.txt for license details.
4
4
*/
5
5
6
+ /* global Ext, varienWindowOnload, varienElementMethods */
7
+
6
8
define ( [
7
9
'jquery' ,
8
10
'prototype' ,
@@ -32,39 +34,36 @@ define([
32
34
parameters = { } ,
33
35
root = { } ,
34
36
len = 0 ,
35
- key = '' ,
36
- i = 0 ;
37
+ key = '' ;
37
38
38
- /* eslint-disable */
39
39
/**
40
40
* Fix ext compatibility with prototype 1.6
41
41
*/
42
- Ext . lib . Event . getTarget = function ( e ) { // eslint-disable-line no-undef
42
+ Ext . lib . Event . getTarget = function ( e ) {
43
43
var ee = e . browserEvent || e ;
44
44
45
45
return ee . target ? Event . element ( ee ) : null ;
46
46
} ;
47
47
48
48
/**
49
49
* @param {Object } el
50
- * @param {Object } config
50
+ * @param {Object } nodeConfig
51
51
*/
52
- Ext . tree . TreePanel . Enhanced = function ( el , config ) { // eslint-disable-line no-undef
53
- Ext . tree . TreePanel . Enhanced . superclass . constructor . call ( this , el , config ) ; // eslint-disable-line no-undef
52
+ Ext . tree . TreePanel . Enhanced = function ( el , nodeConfig ) {
53
+ Ext . tree . TreePanel . Enhanced . superclass . constructor . call ( this , el , nodeConfig ) ;
54
54
} ;
55
55
56
- Ext . extend ( Ext . tree . TreePanel . Enhanced , Ext . tree . TreePanel , { // eslint-disable-line no-undef
57
- /* eslint-enable */
56
+ Ext . extend ( Ext . tree . TreePanel . Enhanced , Ext . tree . TreePanel , {
58
57
/**
59
- * @param {Object } config
58
+ * @param {Object } treeConfig
60
59
* @param {Boolean } firstLoad
61
60
*/
62
- loadTree : function ( config , firstLoad ) { // eslint-disable-line no-shadow
63
- parameters = config . parameters ,
64
- data = config . data ,
65
- root = new Ext . tree . TreeNode ( parameters ) ; // eslint-disable-line no-undef
61
+ loadTree : function ( treeConfig , firstLoad ) {
62
+ parameters = treeConfig . parameters ,
63
+ data = treeConfig . data ,
64
+ root = new Ext . tree . TreeNode ( parameters ) ;
66
65
67
- if ( typeof parameters . rootVisible != 'undefined' ) {
66
+ if ( typeof parameters . rootVisible !== 'undefined' ) {
68
67
this . rootVisible = parameters . rootVisible * 1 ;
69
68
}
70
69
@@ -90,7 +89,7 @@ define([
90
89
} ) ;
91
90
92
91
jQuery ( function ( ) {
93
- var categoryLoader = new Ext . tree . TreeLoader ( { // eslint-disable-line no-undef
92
+ var categoryLoader = new Ext . tree . TreeLoader ( {
94
93
dataUrl : config . dataUrl
95
94
} ) ;
96
95
@@ -110,42 +109,42 @@ define([
110
109
} ;
111
110
112
111
/**
113
- * @param {Object } config
112
+ * @param {Object } nodeConfig
114
113
* @returns {Object }
115
114
*/
116
- categoryLoader . createNode = function ( config ) { // eslint-disable-line no-shadow
115
+ categoryLoader . createNode = function ( nodeConfig ) {
117
116
var node ;
118
117
119
- config . uiProvider = Ext . tree . CheckboxNodeUI ; // eslint-disable-line no-undef
118
+ nodeConfig . uiProvider = Ext . tree . CheckboxNodeUI ;
120
119
121
- if ( config . children && ! config . children . length ) {
122
- delete config . children ;
123
- node = new Ext . tree . AsyncTreeNode ( config ) ; // eslint-disable-line no-undef
120
+ if ( nodeConfig . children && ! nodeConfig . children . length ) {
121
+ delete nodeConfig . children ;
122
+ node = new Ext . tree . AsyncTreeNode ( nodeConfig ) ;
124
123
} else {
125
- node = new Ext . tree . TreeNode ( config ) ; // eslint-disable-line no-undef
124
+ node = new Ext . tree . TreeNode ( nodeConfig ) ;
126
125
}
127
126
128
127
return node ;
129
128
} ;
130
129
131
130
/**
132
131
* @param {Object } parent
133
- * @param {Object } config
132
+ * @param {Object } nodeConfig
134
133
* @param {Integer } i
135
134
*/
136
- categoryLoader . processCategoryTree = function ( parent , config , i ) { // eslint-disable-line no-shadow
135
+ categoryLoader . processCategoryTree = function ( parent , nodeConfig , i ) {
137
136
var node ,
138
137
_node = { } ;
139
138
140
- config [ i ] . uiProvider = Ext . tree . CheckboxNodeUI ; // eslint-disable-line no-undef
139
+ nodeConfig [ i ] . uiProvider = Ext . tree . CheckboxNodeUI ;
141
140
142
- _node = Object . clone ( config [ i ] ) ;
141
+ _node = Object . clone ( nodeConfig [ i ] ) ;
143
142
144
143
if ( _node . children && ! _node . children . length ) {
145
144
delete _node . children ;
146
- node = new Ext . tree . AsyncTreeNode ( _node ) ; // eslint-disable-line no-undef
145
+ node = new Ext . tree . AsyncTreeNode ( _node ) ;
147
146
} else {
148
- node = new Ext . tree . TreeNode ( config [ i ] ) ; // eslint-disable-line no-undef
147
+ node = new Ext . tree . TreeNode ( nodeConfig [ i ] ) ;
149
148
}
150
149
parent . appendChild ( node ) ;
151
150
node . loader = node . getOwnerTree ( ) . loader ;
@@ -157,18 +156,19 @@ define([
157
156
158
157
/**
159
158
* @param {Object } parent
160
- * @param {Object } config
159
+ * @param {Object } nodeConfig
161
160
* @returns {void }
162
161
*/
163
- categoryLoader . buildCategoryTree = function ( parent , config ) { // eslint-disable-line no-shadow
164
- var i = 0 ;
165
- if ( ! config ) {
162
+ categoryLoader . buildCategoryTree = function ( parent , nodeConfig ) {
163
+ var j = 0 ;
164
+
165
+ if ( ! nodeConfig ) {
166
166
return null ;
167
167
}
168
168
169
- if ( parent && config && config . length ) {
170
- for ( i = 0 ; i < config . length ; i ++ ) {
171
- categoryLoader . processCategoryTree ( parent , config , i ) ;
169
+ if ( parent && nodeConfig && nodeConfig . length ) {
170
+ for ( j = 0 ; j < nodeConfig . length ; j ++ ) {
171
+ categoryLoader . processCategoryTree ( parent , nodeConfig , j ) ;
172
172
}
173
173
}
174
174
} ;
@@ -179,19 +179,15 @@ define([
179
179
* @param {Object } node
180
180
* @returns {Object }
181
181
*/
182
- categoryLoader . buildHashChildren = function ( hash , node ) { // eslint-disable-line no-shadow
183
- var i = 0 ;
184
- // eslint-disable-next-line no-extra-parens
185
- if ( ( node . childNodes . length > 0 ) || ( node . loaded === false && node . loading === false ) ) {
182
+ categoryLoader . buildHashChildren = function ( hash , node ) {
183
+ var j = 0 ;
184
+
185
+ if ( node . childNodes . length > 0 || node . loaded === false && node . loading === false ) {
186
186
hash . children = [ ] ;
187
187
188
- for ( i = 0 , len = node . childNodes . length ; i < len ; i ++ ) {
189
- /* eslint-disable */
190
- if ( ! hash . children ) {
191
- hash . children = [ ] ;
192
- }
193
- /* eslint-enable */
194
- hash . children . push ( this . buildHash ( node . childNodes [ i ] ) ) ;
188
+ for ( j = 0 , len = node . childNodes . length ; j < len ; j ++ ) {
189
+ hash . children = hash . children ? hash . children : [ ] ;
190
+ hash . children . push ( this . buildHash ( node . childNodes [ j ] ) ) ;
195
191
}
196
192
}
197
193
@@ -231,7 +227,6 @@ define([
231
227
treeLoader . baseParams . id = node . attributes . id ;
232
228
} ) ;
233
229
234
- /* eslint-disable */
235
230
categoryLoader . on ( 'load' , function ( ) {
236
231
varienWindowOnload ( ) ;
237
232
} ) ;
@@ -271,7 +266,6 @@ define([
271
266
tree . loadTree ( {
272
267
parameters : parameters , data : options . treeJson
273
268
} , true ) ;
274
- /* eslint-enable */
275
269
} ) ;
276
270
} ;
277
271
} ) ;
0 commit comments