Skip to content

Commit 1455f9a

Browse files
author
p01
committed
fullwidth zebra
default expand/collapsed ( branches deeper than the window > document are collapsed )
1 parent 9826c3e commit 1455f9a

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

src/resource-manager/resource_service.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ cls.ResourceManagerService = function(view, network_logger)
5656
var ctx = {};
5757

5858
ctx.windowList = this._network_logger.get_window_contexts();
59-
if (ctx.windowList.length)
59+
if (ctx.windowList && ctx.windowList.length)
6060
{
6161
var typeGroupMapping =
6262
{
@@ -170,10 +170,11 @@ cls.ResourceManagerService = function(view, network_logger)
170170
{
171171
var hash = this. _collapsedHash;
172172
var pivotID = pivot.getAttribute('data-expand-collapse-id');
173-
if (hash[pivotID])
173+
174+
if (hash[pivotID] === true)
174175
{
176+
hash[pivotID] = false;
175177
pivot.classList.remove('close');
176-
delete hash[pivotID];
177178
}
178179
else
179180
{

src/resource-manager/resource_style.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,15 @@ a.external:hover
321321

322322
.resource-tree-documents, .resource-tree-groups, .resource-tree-resources
323323
{
324-
padding:0 0 0 18px;
324+
padding:0;
325325
margin:0;
326326
}
327327
/* zebra resources */
328-
.resource-tree-resources > li:nth-child(odd) > h2
328+
.resource-tree-windows
329329
{
330-
background-color:rgba(0,0,0,.05);
330+
background-image: linear-gradient(0deg, rgba(0,0,0,.05) 50%, transparent 0%);
331+
background-size: 100% 36px;
332+
background-repeat:repeat;
331333
}
332334

333335
.resource-tree li > h2:hover

src/resource-manager/resource_templates.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,57 @@ templates.resource_tree =
99
{
1010
_groupOrder:['markup','stylesheets','scripts','images','fonts','others'],
1111

12-
expandCollapseToggle:function(context, id, tpl)
12+
_init:function()
13+
{
14+
this._initialized = true;
15+
['document', 'resource_group', 'resource'].forEach(function(f)
16+
{
17+
var original = this[f];
18+
this[f] = function()
19+
{
20+
this._depth++;
21+
22+
var r = original.apply(this, arguments);
23+
if(r && r[1] && r[1][0] == 'h2')
24+
r[1].push( 'style','padding-left:'+this._depth*18+'px;' );
25+
26+
this._depth--;
27+
return r;
28+
};
29+
}, this);
30+
31+
},
32+
33+
expandCollapseToggle:function(context, pivotID, tpl)
1334
{
1435
var button = ['input',
1536
'type','button',
1637
'class','button-expand-collapse'
1738
];
18-
tpl.push('data-expand-collapse-id', id, 'class', 'resource-tree-expand-collapse'+(context.collapsed[id]?' close':''));
19-
tpl[1].push( 'handler','resources-expand-collapse' );
2039

40+
var hash = context.collapsed;
41+
if (!hash.hasOwnProperty(pivotID))
42+
hash[pivotID] = this._depth>1;
43+
44+
var collapsed = hash[pivotID];
45+
46+
tpl.push
47+
(
48+
'data-expand-collapse-id', pivotID,
49+
'class', 'resource-tree-expand-collapse'+(collapsed?' close':'')
50+
);
2151

52+
tpl[1].push( 'handler','resources-expand-collapse' );
2253
tpl[1].splice(1, 0, button);
2354

2455
return tpl;
2556
},
2657

2758
update:function(context)
2859
{
60+
if (!this._initialized)
61+
this._init();
62+
this._depth = 0;
2963
return this.windows(context);
3064
},
3165

@@ -109,7 +143,6 @@ templates.resource_tree =
109143
this.resource_groups(context, resources),
110144
this.documents(context, d.windowID, d.documentID)
111145
]
112-
// 'data-expand-collapse-id','d'+d.documentID
113146
]
114147
);
115148
},

0 commit comments

Comments
 (0)