forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collapse.js
53 lines (48 loc) · 1.88 KB
/
collapse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$(function() {
$('#memtrackerstable').on('click', '.toggle', function() {
//Gets all <tr>'s of greater depth
//below element in the table
var findChildren = function(tr) {
var depth = tr.data('depth');
return tr.nextUntil($('tr').filter(function() {
return $(this).data('depth') <= depth;
}));
};
var el = $(this);
var tr = el.closest('tr'); //Get <tr> parent of toggle button
var children = findChildren(tr);
//Remove already collapsed nodes from children so that we don't
//make them visible.
var subnodes = children.filter('.expand');
subnodes.each(function() {
var subnode = $(this);
var subnodeChildren = findChildren(subnode);
children = children.not(subnodeChildren);
});
//Change icon and hide/show children
if (tr.hasClass('collapse')) {
tr.removeClass('collapse').addClass('expand');
children.hide();
} else {
tr.removeClass('expand').addClass('collapse');
children.show();
}
return children;
});
});
$(function() {
$(".level0 td:first-child").has(".toggle").css("padding-left", "6px");
$(".level1 td:first-child").has(".toggle").css("padding-left", "21px");
$(".level2 td:first-child").has(".toggle").css("padding-left", "36px");
$(".level3 td:first-child").has(".toggle").css("padding-left", "51px");
$(".level4 td:first-child").has(".toggle").css("padding-left", "66px");
$(".level5 td:first-child").has(".toggle").css("padding-left", "81px");
$(".level6 td:first-child").has(".toggle").css("padding-left", "96px");
});
$(function() {
$(".level6 td:first-child span.toggle").click();
$(".level5 td:first-child span.toggle").click();
$(".level4 td:first-child span.toggle").click();
$(".level3 td:first-child span.toggle").click();
$(".level2 td:first-child span.toggle").click();
});