Project

General

Profile

Download (2.22 KB) Statistics
| Branch: | Tag: | Revision:
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
    //hide all collapse icons
13
    jQuery(selector + " .collapse_icon").hide();
14

    
15
    //register click on every summary row
16
    jQuery(selector + " .summary_row").click(
17
        function(event){
18
            jQuery(event.target).parent(".summary_row").next().toggle(500);//toggle detail row when clicking on corresponding summary row
19
            jQuery(event.target).parent(".summary_row").find(".expand_icon").toggle();//toggle collapse/expand icons
20
            jQuery(event.target).parent(".summary_row").find(".collapse_icon").toggle();
21
        })
22
    //register click on every summary row icon
23
    jQuery(selector + " .summary_row_icon").click(
24
        function(event){
25
            jQuery(event.target).parent().parent(".summary_row").next().toggle(500);//toggle detail row when clicking on corresponding summary row
26
            jQuery(event.target).parent().parent(".summary_row").find(".expand_icon").toggle();//toggle collapse/expand icons
27
            jQuery(event.target).parent().parent(".summary_row").find(".collapse_icon").toggle();
28
        })
29

    
30
        //color summary row when hovering over it
31
    jQuery(selector + " .summary_row").mouseenter(
32
        function(event){
33
            jQuery(event.target).parent(".summary_row").addClass( "row-active" );
34
        })
35

    
36
    jQuery(selector + " .summary_row").mouseleave(
37
        function(event){
38
            jQuery(event.target).parent(".summary_row").removeClass("row-active");
39
        })
40
        //show mouse cursor as a link
41
        .css('cursor', 'hand').css('cursor', 'pointer');
42

    
43
}
44
//.hover(//register mouse hover on every summary row
45
//    function(event){
46
//        jQuery(event.target).parent(".summary_row").css("background","#FFCC00");
47
//    }
48
//    ,function(event){
49
//        jQuery(event.target).parent(".summary_row").css("background","");
50
//    })
51

    
52

    
(14-14/15)