Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c19ff6f

Browse filesBrowse files
wouterjfabpot
authored andcommitted
Expand tree
1 parent 96c4486 commit c19ff6f
Copy full SHA for c19ff6f

File tree

Expand file treeCollapse file tree

1 file changed

+81
-13
lines changed
Filter options
  • src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector
Expand file treeCollapse file tree

1 file changed

+81
-13
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig
+81-13Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,42 @@
4545
padding: 0;
4646
width: 100%;
4747
}
48-
.tree a {
49-
text-decoration: none;
50-
display: block;
48+
.tree .tree-inner {
49+
width:100%;
5150
padding: 5px 7px;
5251
border-radius: 6px;
5352
color: #313131;
53+
cursor:pointer;
54+
55+
-webkit-box-sizing: border-box;
56+
-moz-box-sizing: border-box;
57+
box-sizing: border-box;
58+
}
59+
.tree a {
60+
text-decoration: none;
61+
}
62+
.tree button {
63+
width:10px;
64+
height:10px;
65+
background: none;
66+
border: none;
5467
}
55-
.tree ul ul a {
68+
.tree ul ul .tree-inner {
5669
padding-left: 22px;
5770
}
58-
.tree ul ul ul a {
71+
.tree ul ul ul .tree-inner {
5972
padding-left: 37px;
6073
}
61-
.tree ul ul ul ul a {
74+
.tree ul ul ul ul .tree-inner {
6275
padding-left: 52px;
6376
}
64-
.tree ul ul ul ul ul a {
77+
.tree ul ul ul ul ul .tree-inner {
6578
padding-left: 67px;
6679
}
67-
.tree a:hover {
80+
.tree .tree-inner:hover {
6881
background: #dfdfdf;
6982
}
70-
.tree a.active, a.active:hover {
83+
.tree .tree-inner.active, .tree .tree-inner.active:hover {
7184
background: #dfdfdf;
7285
font-weight: bold;
7386
color: #313131;
@@ -107,12 +120,63 @@
107120
{% endif %}
108121

109122
<script>
123+
function TreeView(tree) {
124+
this.collapseAll = function () {
125+
var children = tree.querySelectorAll('ul');
126+
127+
for (var i = 0, l = children.length; i < l; i++) {
128+
if (children[i].style.display != 'none') {
129+
children[i].style.display = 'none';
130+
} else {
131+
children[i].style.display = 'block';
132+
}
133+
}
134+
};
135+
136+
this.expand = function (element) {
137+
element.style.display = 'block';
138+
};
139+
140+
this.collapse = function (element) {
141+
element.style.display = 'none';
142+
};
143+
144+
this.toggle = function (element) {
145+
if (element.style.display !== 'none') {
146+
this.collapse(element);
147+
148+
return 'collapse';
149+
}
150+
151+
this.expand(element);
152+
153+
return 'expand';
154+
}
155+
}
156+
157+
var tree = document.querySelector('.tree ul');
158+
159+
var treeView = new TreeView(tree);
160+
treeView.collapseAll();
161+
treeView.expand(document.querySelector('.tree ul ul'));
162+
163+
var buttons = tree.querySelectorAll('button');
164+
for (var j = 0, l = buttons.length; j < l; j++) {
165+
buttons[j].addEventListener('click', function (e) {
166+
if ('collapse' === treeView.toggle(this.parentElement.parentElement.querySelector('ul'))) {
167+
this.textContent = '+';
168+
} else {
169+
this.textContent = '-';
170+
}
171+
}, false);
172+
}
173+
110174
function TabView() {
111175
var _activeLink = null,
112176
_activeView = null;
113177
114178
this.init = function () {
115-
var links = document.querySelectorAll('.tree a'),
179+
var links = document.querySelectorAll('.tree .tree-inner'),
116180
views = document.querySelectorAll('.tree-details'),
117181
i,
118182
l;
@@ -122,8 +186,7 @@
122186
var link = links[i];
123187
124188
link.addEventListener('click', function (e) {
125-
var href = link.getAttribute('href'),
126-
targetId = href.substr(href.indexOf('#') + 1),
189+
var targetId = 'details_' + link.dataset.targetId,
127190
view = document.getElementById(targetId);
128191
129192
if (view) {
@@ -173,7 +236,12 @@
173236

174237
{% macro form_tree_entry(name, data) %}
175238
<li>
176-
<a href="#details_{{ data.id }}">{{ name }}</a>
239+
<div class="tree-inner" data-target-id="{{ data.id }}">
240+
{% if data.children is not empty %}
241+
<button>+</button>
242+
{% endif %}
243+
{{ name }}
244+
</div>
177245

178246
{% if data.children is not empty %}
179247
<ul>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.