summaryrefslogtreecommitdiff
path: root/chimere_example_project/static/chimere/js/interface.js
blob: c0c00bf6003d0b1f5b39d13eed5962c2e45dd05a (plain)
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
$(function(){

    if (has_search){
        $('a[href=#categories]').click(function(){
            show_panel(display_categories);
        });
        $('a[href=#search-box]').click(function(){
            show_panel(display_search);
        });
        $('a[href=#search-box]').click();
    } else {
        $("#categories").fadeIn();
    }
    highlight_selected_categories();
    $('.subcategory label').click(highlight_selected_categories);
    $('#categories-lnk, #search-lnk').click(function(){
        if($('.navbar-toggle').css('display') !='none'){
            $(".navbar-toggle").click();
        }
    });
    $('#hide-panel').click(hide_panel);
    $('#show-panel').click(show_panel);
    $('#close-detail').click(function(){
        $('#detail').fadeOut();
    });
});

function display_categories(){
    $('a[href=#categories]').parent().parent().children().removeClass('active');
    $('a[href=#categories]').parent().addClass('active');
    $("#search-box").fadeOut(400,
            function(){ $("#categories").fadeIn(); });
}

function display_search(){
    $('a[href=#search-box]').parent().parent().children().removeClass('active');
    $('a[href=#search-box]').parent().addClass('active');
    $("#categories").fadeOut(400,
            function(){ $("#search-box").fadeIn(); $('#id_q').focus(); });
}

function show_panel(fct){
    if(!fct) fct = function(){};
    if($('#panel').css('display') == 'none'){
        $('#show-panel').fadeOut(200, function(){
            $('#hide-panel').fadeIn(500);
            $("#panel").fadeIn(500);
            $("#panel").fadeIn(500, fct);
        });
    } else {
        fct();
    }
}

function hide_panel(){
    if($('#panel').css('display') != 'none'){
        $('#hide-panel').fadeOut(500);
        $("#panel").fadeOut(500, function(){
            $('#show-panel').fadeIn();
        });
    }
}

function highlight_selected_categories(){
    $('.subcategory input').each(function(){
        var lbl = $(this).parent();
        if($(this).is(':checked')){
            lbl.addClass('selected');
        }else{
            lbl.removeClass('selected');
        }
    });
}