var msg_edit_route = "Cliquez sur la carte pour tracer le trajet. Chaque nouveau clic rajoute un nœud. Double-cliquez pour terminer le trajet.
Pour modifier le trajet sélectionnez un nœud puis glissez-déposez pour le déplacer.";
var msg_edit = "Cliquez sur la carte pour placer le lieu. Pour modifier ce lieu sélectionnez-le puis glissez-déposez pour le déplacer.";
var storageAvailable = function (type) {
try {
var storage = window[type],
x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
return true;
}
catch(e) {
return e instanceof DOMException && (
// everything except Firefox
e.code === 22 ||
// Firefox
e.code === 1014 ||
// test name field too, because code might not be present
// everything except Firefox
e.name === 'QuotaExceededError' ||
// Firefox
e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
// acknowledge QuotaExceededError only if there's something already stored
storage.length !== 0;
}
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i
" + default_error_message + "
"); } }); }; var update_editmarker = function(item_id){ var url = edit_url; if(item_id){ url += item_id + "/"; } update_edit(url); }; var update_editroute = function(item_id){ var url = edit_route_url; if(item_id){ url += item_id + "/"; } update_edit(url); }; var update_editpolygon = function(item_id){ var url = edit_polygon_url; if(item_id){ url += item_id + "/"; } update_edit(url); }; var update_editevent = function(){ $("#main-map").chimere('cleanRoute'); $('.map_button').hide(); if($('#multimedia_form').length) $('#multimedia_form').remove(); $('#action-edit-marker').removeClass('state-active'); $('#action-edit-route').removeClass('state-active'); $('#action-edit-event').addClass('state-active'); $('#frm-edit-marker').hide(); $('#frm-edit-route').hide(); $('#frm-edit-event').show(); $('#message').removeClass(); $('#message').addClass('alert'); $('#message').addClass('alert-info'); $('#message .content').html(msg_edit); $('#message').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(""+ default_error_message+"
"); } }); }; var action_map = function(){ $('#main-map').chimere('deactivateEdition'); $('#message').hide(); $('.map_button').hide(); $("#main-map").chimere('cleanRoute'); $("#main-map").chimere('cleanMarker'); $("#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('state-active'); $('#action-carte').addClass('state-active'); $('#edit-actions').hide(); $('#map-actions').show(); $('#edit-panel').hide(); $('#map-panel').show(); }; var action_participate = function(){ /* $('.map_button').hide(); $('#message').hide(); $('#action-carte').removeClass('state-active'); $('#action-participate').addClass('state-active'); $('#map-actions').hide(); $('#edit-actions').show(); $('#map-panel').hide(); $('#edit-panel').show(); */ update_editmarker(); }; var routing_panel_open = function(){ action_map(); $('#frm_categories').hide(); $('#search-box').hide(); $('#frm-edit-marker').hide(); $('#chimere_itinerary_panel').show(); $('#back-categories').show(); }; var category_panel_open = function(){ action_map(); $("#main-map").chimere('razMap'); if($("#switch-menu").is(':visible')){ $("#switch-menu > div").removeClass('selected'); if (!$("#switch-search-result.disabled").length){ $("#switch-search-result").addClass('disabled'); } if ($("#switch-categories.disabled").length){ $("#switch-categories").removeClass('disabled'); } if (!$("#switch-categories.selected").length){ $("#switch-categories").addClass('selected'); } } $("#id_q").val(''); $('#chimere_itinerary_panel').hide(); $('#search-result').hide(); $('#frm-edit-marker').hide(); $('#back-categories').hide(); $('#search-box').show(); $('#frm_categories').show(); }; var search_panel_open = function(){ action_map(); $('#chimere_itinerary_panel').hide(); $('#frm_categories').hide(); $('#frm-edit-marker').hide(); $('#search-box').show(); $('#search-result').show(); $('#back-categories').show(); }; var edit_panel_open = function(){ action_participate(); /* $('#search-box').hide(); $('#search-result').hide(); $('#frm_categories').hide(); $('#edit-actions').show(); $('#back-categories').show(); */ }; var switch_map = function(){ if(!$("#switch-menu").is(':visible')){ return; } $("#switch-menu > div > div").removeClass('selected'); $("#switch-map").addClass('selected'); $("#panel").fadeOut(); }; var switch_search_result = function(){ if(!$("#switch-menu").is(':visible')){ return; } if ($("#switch-search-result.disabled").length){ return false; } $('#frm_categories').hide(); $('#search-listing').show(); $('#search-nav').show(); $("#switch-menu > div > div").removeClass('selected'); $("#switch-search-result").addClass('selected'); $("#panel").fadeIn(); }; var switch_categories = function(){ if(!$("#switch-menu").is(':visible')){ return; } $('#search-listing').hide(); $('#search-nav').hide(); $('#frm_categories').show(); $("#switch-menu > div > div").removeClass('selected'); $("#switch-categories").addClass('selected'); $("#panel").fadeIn(); $('#frm_categories').show(); }; var init_map_edit; var map_edit_init = function(){ // ol3 must be initialized after modal opening if (init_map_edit){ setTimeout( function(){ init_map_edit(); $('#map_edit').chimere('refresh'); $("#modal-edit").modal('handleUpdate'); }, 500); } else { setTimeout(map_edit_init, 500); } }; $(function(){ $('#action-routing').click(routing_panel_open); $('#routing-button').click(routing_panel_open); $('#action-categories').click(category_panel_open); $('#action-search').click(search_panel_open); $('#edit-button').click(edit_panel_open); $('#back-categories').click(category_panel_open); $('#sidebar-handler-hide').click(function(){$('#sidebar').hide();}); $('#sidebar-handler-show').click(function(){$('#sidebar').show();}); $('#message').hide(); $("[data-hide]").on("click", function(){ $("." + $(this).attr("data-hide")).hide(); }); $("#categories").fadeIn(); $(".buttonset label").click(function(){ $(".buttonset label").removeAttr("aria-pressed"); $(this).attr("aria-pressed", 'true'); }); $("#action-news").click(function(){ $('#modal-news').modal("show"); }); $("#modal-edit").on('shown.bs.modal', function () { map_edit_init(); }); $("#action-carte").click(action_map); $("#action-participate").click(action_participate); $("#action-edit-event").click(update_editevent); $("#action-edit-marker").click(update_editmarker); $("#action-edit-route").click(update_editroute); $('.dyn-page').click(function(){ var url = $(this).filter('a').attr('href'); if (!url){ url = $(this).children('a').attr('href'); } if (!url){ return false; } $.ajax({url: url, dataType: "html", success: function (content) { html = "