@@ -23,13 +23,7 @@ var extendDeep = Lib.extendDeep;
23
23
var extendDeepAll = Lib . extendDeepAll ;
24
24
25
25
var NESTED_MODULE = '_nestedModules' ,
26
- COMPOSED_MODULE = '_composedModules' ,
27
- IS_SUBPLOT_OBJ = '_isSubplotObj' ,
28
- IS_LINKED_TO_ARRAY = '_isLinkedToArray' ,
29
- DEPRECATED = '_deprecated' ;
30
-
31
- // list of underscore attributes to keep in schema as is
32
- var UNDERSCORE_ATTRS = [ IS_SUBPLOT_OBJ , IS_LINKED_TO_ARRAY , DEPRECATED ] ;
26
+ COMPOSED_MODULE = '_composedModules' ;
33
27
34
28
var plotSchema = {
35
29
traces : { } ,
@@ -56,22 +50,9 @@ PlotSchema.get = function() {
56
50
return plotSchema ;
57
51
} ;
58
52
59
- PlotSchema . crawl = function ( attrs , callback ) {
60
- Object . keys ( attrs ) . forEach ( function ( attrName ) {
61
- var attr = attrs [ attrName ] ;
62
-
63
- if ( UNDERSCORE_ATTRS . indexOf ( attrName ) !== - 1 ) return ;
53
+ PlotSchema . crawl = Lib . crawl ;
64
54
65
- callback ( attr , attrName , attrs ) ;
66
-
67
- if ( PlotSchema . isValObject ( attr ) ) return ;
68
- if ( Lib . isPlainObject ( attr ) ) PlotSchema . crawl ( attr , callback ) ;
69
- } ) ;
70
- } ;
71
-
72
- PlotSchema . isValObject = function ( obj ) {
73
- return obj && obj . valType !== undefined ;
74
- } ;
55
+ PlotSchema . isValObject = Lib . isValObject ;
75
56
76
57
function getTraceAttributes ( type ) {
77
58
var globalAttributes = Plots . attributes ,
@@ -131,13 +112,13 @@ function getLayoutAttributes() {
131
112
// FIXME polar layout attributes
132
113
layoutAttributes = assignPolarLayoutAttrs ( layoutAttributes ) ;
133
114
134
- // add IS_SUBPLOT_OBJ attribute
115
+ // add crawler. IS_SUBPLOT_OBJ attribute
135
116
layoutAttributes = handleSubplotObjs ( layoutAttributes ) ;
136
117
137
118
layoutAttributes = removeUnderscoreAttrs ( layoutAttributes ) ;
138
119
mergeValTypeAndRole ( layoutAttributes ) ;
139
120
140
- // generate IS_LINKED_TO_ARRAY structure
121
+ // generate crawler. IS_LINKED_TO_ARRAY structure
141
122
handleLinkedToArray ( layoutAttributes ) ;
142
123
143
124
plotSchema . layout = { layoutAttributes : layoutAttributes } ;
@@ -158,7 +139,7 @@ function getTransformAttributes(name) {
158
139
function getDefs ( ) {
159
140
plotSchema . defs = {
160
141
valObjects : Lib . valObjects ,
161
- metaKeys : UNDERSCORE_ATTRS . concat ( [ 'description' , 'role' ] )
142
+ metaKeys : Lib . UNDERSCORE_ATTRS . concat ( [ 'description' , 'role' ] )
162
143
} ;
163
144
}
164
145
@@ -241,7 +222,7 @@ function mergeValTypeAndRole(attrs) {
241
222
}
242
223
}
243
224
244
- PlotSchema . crawl ( attrs , callback ) ;
225
+ Lib . crawl ( attrs , callback ) ;
245
226
}
246
227
247
228
// helper methods
@@ -267,7 +248,7 @@ function getModule(arg) {
267
248
function removeUnderscoreAttrs ( attributes ) {
268
249
Object . keys ( attributes ) . forEach ( function ( k ) {
269
250
if ( k . charAt ( 0 ) === '_' &&
270
- UNDERSCORE_ATTRS . indexOf ( k ) === - 1 ) delete attributes [ k ] ;
251
+ Lib . UNDERSCORE_ATTRS . indexOf ( k ) === - 1 ) delete attributes [ k ] ;
271
252
} ) ;
272
253
return attributes ;
273
254
}
@@ -321,7 +302,7 @@ function handleSubplotObjs(layoutAttributes) {
321
302
isSubplotObj = subplotRegistry . attrRegex . test ( k ) ;
322
303
}
323
304
324
- if ( isSubplotObj ) layoutAttributes [ k ] [ IS_SUBPLOT_OBJ ] = true ;
305
+ if ( isSubplotObj ) layoutAttributes [ k ] [ Lib . IS_SUBPLOT_OBJ ] = true ;
325
306
} ) ;
326
307
} ) ;
327
308
@@ -331,17 +312,17 @@ function handleSubplotObjs(layoutAttributes) {
331
312
function handleLinkedToArray ( layoutAttributes ) {
332
313
333
314
function callback ( attr , attrName , attrs ) {
334
- if ( attr [ IS_LINKED_TO_ARRAY ] !== true ) return ;
315
+ if ( attr [ Lib . IS_LINKED_TO_ARRAY ] !== true ) return ;
335
316
336
317
// TODO more robust logic
337
318
var itemName = attrName . substr ( 0 , attrName . length - 1 ) ;
338
319
339
- delete attr [ IS_LINKED_TO_ARRAY ] ;
320
+ delete attr [ Lib . IS_LINKED_TO_ARRAY ] ;
340
321
341
322
attrs [ attrName ] = { items : { } } ;
342
323
attrs [ attrName ] . items [ itemName ] = attr ;
343
324
attrs [ attrName ] . role = 'object' ;
344
325
}
345
326
346
- PlotSchema . crawl ( layoutAttributes , callback ) ;
327
+ Lib . crawl ( layoutAttributes , callback ) ;
347
328
}
0 commit comments