@@ -7,16 +7,6 @@ templates.resource_icon = function(resource)
77
88templates . resource_tree =
99{
10- _groupOrder :
11- [
12- ui_strings . S_HTTP_LABEL_FILTER_MARKUP ,
13- ui_strings . S_HTTP_LABEL_FILTER_STYLESHEETS ,
14- ui_strings . S_HTTP_LABEL_FILTER_SCRIPTS ,
15- ui_strings . S_HTTP_LABEL_FILTER_IMAGES ,
16- ui_strings . S_HTTP_LABEL_FILTER_FONTS ,
17- ui_strings . S_HTTP_LABEL_FILTER_OTHER
18- ] ,
19-
2010 URL_MATCH_CONTEXT_SIZE : 10 ,
2111 DEPTH_IDENTATION : 18 ,
2212 DISTINGUISHER_MAX_LENGTH : 64 ,
@@ -33,35 +23,33 @@ templates.resource_tree =
3323 _expander_extras :function ( context , pivotID , depth )
3424 {
3525 var hash = context . collapsed ;
26+
27+ // expand all pivots when searching
3628 if ( context . searchTerm != '' )
3729 hash [ pivotID ] = false ;
38- else if ( ! hash . hasOwnProperty ( pivotID ) )
39- hash [ pivotID ] = depth > 1 ;
4030
4131 var collapsed = hash [ pivotID ] ;
4232
43- return ( {
44- collapsed :collapsed ,
45- tpl :
46- {
47- li :
48- [
49- 'data-expand-collapse-id' , pivotID ,
50- 'class' , 'resource-tree-expand-collapse' + ( collapsed ?' close' :'' )
51- ] ,
52- h2 :
53- [
54- 'handler' , 'resources-expand-collapse'
55- ] ,
56- button :
57- [
58- 'input' ,
59- 'type' , 'button' ,
60- 'class' , 'button-expand-collapse' ,
61- 'style' , 'margin-left:' + depth * this . DEPTH_IDENTATION + 'px;'
62- ]
63- }
64- } ) ;
33+ var tpl = { } ;
34+
35+ tpl . h2 = [ 'handler' , 'resources-expand-collapse' ] ;
36+ tpl . li =
37+ [
38+ 'data-expand-collapse-id' , pivotID ,
39+ 'class' , 'resource-tree-expand-collapse' + ( collapsed ?' close' :'' )
40+ ] ;
41+ tpl . button =
42+ [
43+ 'input' ,
44+ 'type' , 'button' ,
45+ 'class' , 'button-expand-collapse'
46+ ] ;
47+
48+ if ( depth )
49+ tpl . button . push ( 'style' , 'margin-left:' + depth * this . DEPTH_IDENTATION + 'px;' ) ;
50+
51+
52+ return { collapsed :collapsed , tpl :tpl } ;
6553 } ,
6654
6755 update :function ( context )
@@ -169,7 +157,7 @@ templates.resource_tree =
169157
170158 resource_groups :function ( context , resources , d )
171159 {
172- var tpl = this . _groupOrder
160+ var tpl = context . groupOrder
173161 . map ( this . resource_group . bind ( this , context , resources , d ) )
174162 . filter ( function ( v ) {
175163 return v != null ;
@@ -195,7 +183,8 @@ templates.resource_tree =
195183 if ( ! resources . length )
196184 return [ ] ;
197185
198- var extras = this . _expander_extras ( context , d . pivotID + '_' + g , d . depth + 1 ) ;
186+ var depth = d . depth + 1 ;
187+ var extras = this . _expander_extras ( context , d . pivotID + '_' + g , depth ) ;
199188
200189 var tpl =
201190 [ 'li' ,
@@ -212,7 +201,7 @@ templates.resource_tree =
212201 ] ,
213202 'class' , 'resource-tree-group resource-tree-group-' + g . toLowerCase ( )
214203 ] . concat ( extras . tpl . h2 ) ,
215- extras . collapsed ?[ ] :this . resources ( context , resources , d . depth + 2 )
204+ extras . collapsed ?[ ] :this . resources ( context , resources , depth + 1 )
216205 ] . concat ( extras . tpl . li ) ;
217206
218207 return tpl ;
0 commit comments