@@ -23,13 +23,7 @@ var extendDeep = Lib.extendDeep;
2323var extendDeepAll = Lib . extendDeepAll ;
2424
2525var 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' ;
3327
3428var plotSchema = {
3529 traces : { } ,
@@ -56,22 +50,9 @@ PlotSchema.get = function() {
5650 return plotSchema ;
5751} ;
5852
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 ;
6454
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 ;
7556
7657function getTraceAttributes ( type ) {
7758 var globalAttributes = Plots . attributes ,
@@ -131,13 +112,13 @@ function getLayoutAttributes() {
131112 // FIXME polar layout attributes
132113 layoutAttributes = assignPolarLayoutAttrs ( layoutAttributes ) ;
133114
134- // add IS_SUBPLOT_OBJ attribute
115+ // add crawler. IS_SUBPLOT_OBJ attribute
135116 layoutAttributes = handleSubplotObjs ( layoutAttributes ) ;
136117
137118 layoutAttributes = removeUnderscoreAttrs ( layoutAttributes ) ;
138119 mergeValTypeAndRole ( layoutAttributes ) ;
139120
140- // generate IS_LINKED_TO_ARRAY structure
121+ // generate crawler. IS_LINKED_TO_ARRAY structure
141122 handleLinkedToArray ( layoutAttributes ) ;
142123
143124 plotSchema . layout = { layoutAttributes : layoutAttributes } ;
@@ -158,7 +139,7 @@ function getTransformAttributes(name) {
158139function getDefs ( ) {
159140 plotSchema . defs = {
160141 valObjects : Lib . valObjects ,
161- metaKeys : UNDERSCORE_ATTRS . concat ( [ 'description' , 'role' ] )
142+ metaKeys : Lib . UNDERSCORE_ATTRS . concat ( [ 'description' , 'role' ] )
162143 } ;
163144}
164145
@@ -241,7 +222,7 @@ function mergeValTypeAndRole(attrs) {
241222 }
242223 }
243224
244- PlotSchema . crawl ( attrs , callback ) ;
225+ Lib . crawl ( attrs , callback ) ;
245226}
246227
247228// helper methods
@@ -267,7 +248,7 @@ function getModule(arg) {
267248function removeUnderscoreAttrs ( attributes ) {
268249 Object . keys ( attributes ) . forEach ( function ( k ) {
269250 if ( k . charAt ( 0 ) === '_' &&
270- UNDERSCORE_ATTRS . indexOf ( k ) === - 1 ) delete attributes [ k ] ;
251+ Lib . UNDERSCORE_ATTRS . indexOf ( k ) === - 1 ) delete attributes [ k ] ;
271252 } ) ;
272253 return attributes ;
273254}
@@ -321,7 +302,7 @@ function handleSubplotObjs(layoutAttributes) {
321302 isSubplotObj = subplotRegistry . attrRegex . test ( k ) ;
322303 }
323304
324- if ( isSubplotObj ) layoutAttributes [ k ] [ IS_SUBPLOT_OBJ ] = true ;
305+ if ( isSubplotObj ) layoutAttributes [ k ] [ Lib . IS_SUBPLOT_OBJ ] = true ;
325306 } ) ;
326307 } ) ;
327308
@@ -331,17 +312,17 @@ function handleSubplotObjs(layoutAttributes) {
331312function handleLinkedToArray ( layoutAttributes ) {
332313
333314 function callback ( attr , attrName , attrs ) {
334- if ( attr [ IS_LINKED_TO_ARRAY ] !== true ) return ;
315+ if ( attr [ Lib . IS_LINKED_TO_ARRAY ] !== true ) return ;
335316
336317 // TODO more robust logic
337318 var itemName = attrName . substr ( 0 , attrName . length - 1 ) ;
338319
339- delete attr [ IS_LINKED_TO_ARRAY ] ;
320+ delete attr [ Lib . IS_LINKED_TO_ARRAY ] ;
340321
341322 attrs [ attrName ] = { items : { } } ;
342323 attrs [ attrName ] . items [ itemName ] = attr ;
343324 attrs [ attrName ] . role = 'object' ;
344325 }
345326
346- PlotSchema . crawl ( layoutAttributes , callback ) ;
327+ Lib . crawl ( layoutAttributes , callback ) ;
347328}
0 commit comments