1
|
/**
|
2
|
* Adds the functionality to toggle (hide/show) every second row by clicking on the first.
|
3
|
* All first rows must belong to the class "summary_row"
|
4
|
* and the second rows to the class "detail_row".
|
5
|
*
|
6
|
* @param selector the CSS selector for the table on which this functionality should be applied
|
7
|
*/
|
8
|
function addRowToggle(selector) {
|
9
|
|
10
|
//hide all detail rows and color them
|
11
|
jQuery(selector + " .detail_row").hide().css("background","#F9F9F9");
|
12
|
|
13
|
//register click on every summary row
|
14
|
jQuery(selector + " .summary_row").click(
|
15
|
function(event){
|
16
|
jQuery(event.target).parent(".summary_row").next().toggle(500);//toggle detail row when clicking on corresponding summary row
|
17
|
})
|
18
|
//color summary row when hovering over it
|
19
|
.mouseenter(
|
20
|
function(event){
|
21
|
jQuery(event.target).parent(".summary_row").css("background","#FFCC00");
|
22
|
})
|
23
|
.mouseleave(
|
24
|
function(event){
|
25
|
jQuery(event.target).parent(".summary_row").css("background","");
|
26
|
})
|
27
|
//show mouse cursor as a link
|
28
|
.css('cursor', 'hand').css('cursor', 'pointer');
|
29
|
}
|
30
|
//.hover(//register mouse hover on every summary row
|
31
|
// function(event){
|
32
|
// jQuery(event.target).parent(".summary_row").css("background","#FFCC00");
|
33
|
// }
|
34
|
// ,function(event){
|
35
|
// jQuery(event.target).parent(".summary_row").css("background","");
|
36
|
// })
|