summaryrefslogtreecommitdiff
path: root/static/saclay/js/interface.js
blob: b8ab2d74de6735b20f75407a09e0bc8f5ea5849d (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
$(function(){
    $('#default-message').dialog({'autoOpen':false});

    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);

    $('.dyn-page').click(function(){
        url = $(this).filter('a').attr('href');
        $.ajax({url: url,
                dataType: "html",
                success: function (content) {
                    $('#default-message').html(content);
                    dialog_title = $("#default-message #dialog-title");
                    $('#default-message').dialog('option', 'title',
                                                 dialog_title.html());
                    dialog_title.remove();
                    $('#default-message').dialog('open');
                }
            });
        return false;
    });
});