summaryrefslogtreecommitdiff
path: root/static/saclay/js/interface.js
blob: 686e66eb3eb579b651437493e5be0dab8abc370e (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
$(function(){
    var update_editmarker = function(){
        $('#action-edit-event').removeClass('ui-state-active');
        $('#action-edit-route').removeClass('ui-state-active');
        $('#action-edit-marker').addClass('ui-state-active');
        $('#frm-edit-route').hide();
        $('#frm-edit-event').hide();
        $('#frm-edit-marker').show();
        $.ajax({url: edit_url,
                dataType: "html",
                success: function (data) {
                    $('#frm-edit-event').html('');
                    $('#frm-edit-route').html('');
                    $('#frm-edit-marker').html(data);
                    $("#main-map").chimere('activateMarkerEdit');
                },
                error: function (data) {
                    $('#frm-edit-marker').html("<p class='warning'>"+
                                        default_error_message+"</p>");
                }
            });
    };

    var update_editevent = function(){
        $('#action-edit-marker').removeClass('ui-state-active');
        $('#action-edit-route').removeClass('ui-state-active');
        $('#action-edit-event').addClass('ui-state-active');
        $('#frm-edit-marker').hide();
        $('#frm-edit-route').hide();
        $('#frm-edit-event').show();
        $.ajax({url: edit_event_url,
                dataType: "html",
                success: function (data) {
                    $('#frm-edit-marker').html('');
                    $('#frm-edit-route').html('');
                    $('#frm-edit-event').html(data);
                    $("#main-map").chimere('activateMarkerEdit');
                },
                error: function (data) {
                    $('#frm-edit-event').html("<p class='warning'>"+
                                        default_error_message+"</p>");
                }
            });
    };

    var update_editroute = function(){
        $('#action-edit-marker').removeClass('ui-state-active');
        $('#action-edit-event').removeClass('ui-state-active');
        $('#action-edit-route').addClass('ui-state-active');
        $('#frm-edit-marker').hide();
        $('#frm-edit-event').hide();
        $('#frm-edit-route').show();
        $.ajax({url: edit_route_url,
                dataType: "html",
                success: function (data) {
                    $('#frm-edit-marker').html('');
                    $('#frm-edit-event').html('');
                    $('#frm-edit-route').html(data);
                    $("#main-map").chimere('activateRouteEdit');
                },
                error: function (data) {
                    $('#frm-edit-route').html("<p class='warning'>"+
                                        default_error_message+"</p>");
                }
            });
    };

    $("#action-carte").click(function(){
        $("#main-map").chimere('activateContextMenu');
        if($("#itinerary_field").html()){
            $("#chimere_itinerary_form").appendTo("#chimere_itinerary_panel");
            if($("#chimere_itinerary").css('display') != 'none'){
                $("#chimere_itinerary_form").hide();
            }
        }
        $('#action-participate').removeClass('ui-state-active');
        $('#action-carte').addClass('ui-state-active');
        $('#edit-actions').hide();
        $('#map-actions').show();
        $('#edit-panel').hide();
        $('#map-panel').show();
    });

    $("#action-participate").click(function(){
        $('#action-carte').removeClass('ui-state-active');
        $('#action-participate').addClass('ui-state-active');
        $('#map-actions').hide();
        $('#edit-actions').show();
        $('#map-panel').hide();
        $('#edit-panel').show();
        update_editmarker();
    });

    $("#action-edit-event").click(update_editevent);
    $("#action-edit-marker").click(update_editmarker);
    $("#action-edit-route").click(update_editroute);
});