@@ -51,14 +51,17 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
5151 context . resource_list . forEach ( function ( r ) {
5252 r . is_hidden = context . collapsed [ r . pivot_id ] == true ;
5353
54- if ( ! r . is_hidden && context . search_term == "" || r . url . contains ( context . search_term ) )
55- context . resources . push ( r ) ;
54+ if ( context . search_term == "" )
55+ r . is_selectable = ! r . is_hidden ;
56+ else
57+ r . is_selectable = r . url . contains ( context . search_term ) ;
5658 } ) ;
5759
5860 flat_list = [ ] ;
5961 this . windows ( context ) ;
6062 var tpl = [ "div" , [ "ul" , flat_list ] , "class" , "resource-tree" ] ;
6163 flat_list = [ ] ;
64+ delete context . resources ;
6265
6366 return tpl ;
6467 } ;
@@ -109,42 +112,51 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
109112
110113 this . document = function ( context , d )
111114 {
112- var resources = context . resources . filter ( function ( r ) {
115+ var resources = context . resource_list . filter ( function ( r ) {
113116 return r . document_id == d . documentID ;
114117 } ) ;
115118
116- if ( resources . length > 0 )
119+ var resource_count = resources . length ;
120+ if ( context . search_term != "" )
117121 {
118- var extras = this . _expander_extras ( context , d . pivot_id , d . depth ) ;
119-
120- flat_list . push (
121- [ "li" ,
122- [ "h2" ,
123- extras . tpl . button ,
124- [ "span" ,
125- this . _get_short_distinguisher ( d . url ) ,
126- "class" , "resource-tree-document-label" ,
127- "data-tooltip" , "js-script-select" ,
128- "data-tooltip-text" , d . original_url
129- ] ,
130- " " ,
131- d . same_origin ? [ ] : [ "span" , d . url . host || d . url . protocol , "class" , "resource-different-origin" ] ,
132- " " ,
133- [ "span" ,
134- String ( resources . length ) ,
135- "class" , "resource-tree-count"
136- ]
137- ] . concat ( extras . tpl . h2 ) ,
138- ] . concat ( extras . tpl . li )
139- ) ;
140-
141- if ( ! extras . collapsed )
142- {
143- if ( resources . length )
144- this . resource_groups ( context , resources , d ) ;
145-
146- this . documents ( context , d . windowID , d . documentID ) ;
147- }
122+ resources . forEach ( function ( r ) {
123+ if ( ! r . is_selectable )
124+ resource_count -- ;
125+ } ) ;
126+ }
127+
128+ if ( resource_count == 0 )
129+ return ;
130+
131+ var extras = this . _expander_extras ( context , d . pivot_id , d . depth ) ;
132+
133+ flat_list . push (
134+ [ "li" ,
135+ [ "h2" ,
136+ extras . tpl . button ,
137+ [ "span" ,
138+ this . _get_short_distinguisher ( d . url ) ,
139+ "class" , "resource-tree-document-label" ,
140+ "data-tooltip" , "js-script-select" ,
141+ "data-tooltip-text" , d . original_url
142+ ] ,
143+ " " ,
144+ d . same_origin ? [ ] : [ "span" , d . url . host || d . url . protocol , "class" , "resource-different-origin" ] ,
145+ " " ,
146+ [ "span" ,
147+ String ( resource_count ) ,
148+ "class" , "resource-tree-count"
149+ ]
150+ ] . concat ( extras . tpl . h2 ) ,
151+ ] . concat ( extras . tpl . li )
152+ ) ;
153+
154+ if ( ! extras . collapsed )
155+ {
156+ if ( resources . length )
157+ this . resource_groups ( context , resources , d ) ;
158+
159+ this . documents ( context , d . windowID , d . documentID ) ;
148160 }
149161 } ;
150162
@@ -159,7 +171,16 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
159171 return r . group == g ;
160172 } ) ;
161173
162- if ( ! resources . length )
174+ var resource_count = resources . length ;
175+ if ( context . search_term != "" )
176+ {
177+ resources . forEach ( function ( r ) {
178+ if ( ! r . is_selectable )
179+ resource_count -- ;
180+ } ) ;
181+ }
182+
183+ if ( resource_count == 0 )
163184 return ;
164185
165186 var depth = d . depth + 1 ;
@@ -175,7 +196,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
175196 ] ,
176197 " " ,
177198 [ "span" ,
178- String ( resources . length ) ,
199+ String ( resource_count ) ,
179200 "class" , "resource-tree-count"
180201 ] ,
181202 "class" , "resource-tree-group resource-tree-group-" + g . toLowerCase ( )
@@ -194,6 +215,9 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
194215
195216 this . resource = function ( context , depth , r )
196217 {
218+ if ( ! r . is_selectable )
219+ return ;
220+
197221 var search = context . search_term ;
198222 var partial_url_match = "" ;
199223 if ( search != "" )
0 commit comments