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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
<script type="text/javascript">
jQuery(function($) {
/**
* Make so that all visible table rows would alternate colors
*/
var rebuildRowColoring = function() {
var a = 1;
$('.tableinfo tr:visible').each(function() {
a = a ? 0 : 1;
if (a) {
$(this).addClass('even_row');
}
else {
$(this).removeClass('even_row');
}
});
};
var initialize = function() {
// if at least one toggle group is opened
if ($('.app-list-toggle.icon-minus-9x9').length) {
$('.app-list-toggle-all').addClass('icon-minus-9x9').data('openState', 1);
}
rebuildRowColoring();
};
initialize();
// click event for main toggle (+-) button
$('.app-list-toggle-all').click(function() {
// this is for Opera browser with large tables, which renders table layout while showing/hiding rows
$('.tableinfo').fadeTo(0, 0);
var openState = $(this).data('openState'),
appIdList = [];
// switch between + and - icon
$(this).toggleClass('icon-minus-9x9');
if (openState) {
$('.app-list-toggle.icon-minus-9x9').each(function() {
$(this).toggleClass('icon-minus-9x9');
$(this).data('openState', 0);
var appId = $(this).attr('data-app-id');
$('tr[parent_app_id=' + appId + ']').hide();
appIdList.push(appId);
});
}
else {
$('.app-list-toggle').not('.icon-minus-9x9').each(function() {
$(this).toggleClass('icon-minus-9x9');
$(this).data('openState', 1);
var appId = $(this).attr('data-app-id');
$('tr[parent_app_id=' + appId + ']').show();
appIdList.push(appId);
});
}
// change and store new state
openState = openState ? 0 : 1;
$(this).data('openState', openState);
rebuildRowColoring();
// this is for Opera browser with large tables, which renders table layout while showing/hiding rows
$('.tableinfo').fadeTo(0, 1);
// store toggle state in DB
var url = new Curl('latest.php?output=ajax');
url.addSID();
$.post(url.getUrl(), {
favobj: 'toggle',
toggle_ids: appIdList,
toggle_open_state: openState
});
});
// click event for every toggle (+-) button
$('.app-list-toggle').click(function() {
var appId = $(this).attr('data-app-id'),
openState = $(this).data('openState');
// hide/show all corresponding toggle sub rows
$('tr[parent_app_id=' + appId + ']')[(openState ? 'hide' : 'show')]();
// switch between + and - icon
$(this).toggleClass('icon-minus-9x9');
// change and store new state
openState = openState ? 0 : 1;
$(this).data('openState', openState);
// if at least one toggle is opened, make main toggle as -
if (openState) {
$('.app-list-toggle-all').addClass('icon-minus-9x9').data('openState', 1);
}
// if all toggles are closed, make main toggle as +
else if (!$('.app-list-toggle.icon-minus-9x9').length) {
$('.app-list-toggle-all').removeClass('icon-minus-9x9').data('openState', 0);
}
rebuildRowColoring();
// store toggle state in DB
var url = new Curl('latest.php?output=ajax');
url.addSID();
$.post(url.getUrl(), {
favobj: 'toggle',
toggle_ids: appId,
toggle_open_state: openState
});
});
});
</script>
|