diff options
-rw-r--r-- | chimere/static/chimere/css/styles.css | 18 | ||||
-rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 142 | ||||
-rw-r--r-- | chimere/templates/chimere/blocks/map.html | 80 | ||||
-rw-r--r-- | chimere/templates/chimere/detail.html | 2 | ||||
-rw-r--r-- | chimere/templatetags/chimere_tags.py | 3 | ||||
-rw-r--r-- | chimere/urls.py | 3 | ||||
-rw-r--r-- | chimere/views.py | 3 |
7 files changed, 176 insertions, 75 deletions
diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css index d6c7ca3..37c8b71 100644 --- a/chimere/static/chimere/css/styles.css +++ b/chimere/static/chimere/css/styles.css @@ -347,7 +347,7 @@ ul#action-2 { overflow:auto; } -.detail_content{ +#detail .detail_content{ overflow:auto; height:80%; bottom: 0; @@ -1481,10 +1481,7 @@ label.labelSpan.olButton{ margin:auto; } -#detail-wrapper div { -} - -#detail-wrapper{ +#detail #detail-wrapper{ padding: 4px 8px; padding-top:50px; position:absolute; @@ -1499,6 +1496,17 @@ label.labelSpan.olButton{ border-top:1px solid #E7E7E7; } +.inside-popup #detail-wrapper{ + max-height: 350px; + overflow-y: auto; + overflow-x: hidden; +} + +.inside-popup.popover{ + width: 350px; + max-width: 350px; +} + #categories input{ display:None; } diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index 9e62055..3f7c9bf 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -157,6 +157,54 @@ var invisibleStyleIcon = new ol.style.Style({ else return v; }; })( jQuery ); + +/* + * hovering management + */ + +var register_hovering = function(exp, handlers_to_deactivate){ + $(document).on({ + mouseenter: function(evt) { + $(evt.target).data('hovering', true); + if (handlers_to_deactivate){ + for (idx in handlers_to_deactivate){ + handlers_to_deactivate[idx].setActive(false); + } + } + }, + mouseleave: function(evt) { + $(evt.target).data('hovering', false); + if (handlers_to_deactivate){ + for (idx in handlers_to_deactivate){ + handlers_to_deactivate[idx].setActive(true); + } + } + } + }, exp); + $(exp).hover(function(){ + $(this).data('hovering', true); + if (handlers_to_deactivate){ + for (idx in handlers_to_deactivate){ + handlers_to_deactivate[idx].setActive(false); + } + } + }, function(){ + $(this).data('hover', false); + if (handlers_to_deactivate){ + for (idx in handlers_to_deactivate){ + handlers_to_deactivate[idx].setActive(true); + } + } + }); + +} + +// jQuery pseudo-expression :hovering +jQuery.expr[":"].hovering = function(elem) { + return $(elem).data('hovering') ? true : false; +}; + + (function ($) { /* * Chimere jQuery plugin @@ -343,14 +391,22 @@ var invisibleStyleIcon = new ol.style.Style({ view: settings.view, target: map_element, layers: settings.map_layers - // OL3-deprecated: theme: settings.theme }; - settings.current_position = null; /* Create map object */ settings.map = map = new ol.Map(map_options); + // get interactions + settings.map.getInteractions().forEach(function (interaction){ + if (interaction instanceof ol.interaction.MouseWheelZoom){ + settings.MouseWheelZoom = interaction; + } + if (interaction instanceof ol.interaction.DragPan){ + settings.DragPan = interaction; + } + }); + // only display the first layer $.each(settings.map.getLayers().getArray(), function(i, layer){ if (i > 0){ @@ -497,7 +553,7 @@ var invisibleStyleIcon = new ol.style.Style({ // popup management settings.popup_item = document.getElementById('popup'); - settings.popup = new ol.Overlay({ + var popup_options = { element: settings.popup_item, positioning: 'bottom-left', stopEvent: false/*, @@ -505,7 +561,12 @@ var invisibleStyleIcon = new ol.style.Style({ autoPanAnimation: { duration: 250 }*/ - }); + } + /*if (settings.popupContentFull){ + popup_options['autoPan'] = true; + popup_options['autoPanAnimation'] = 250; + }*/ + settings.popup = new ol.Overlay(popup_options); settings.map.addOverlay(settings.popup); // display marker on click @@ -518,6 +579,9 @@ var invisibleStyleIcon = new ol.style.Style({ ); settings.current_feature = feature; if (!settings.edition){ + if ($('.popover-content').is(":hovering")){ + return; + } if (feature) { $(settings.popup_item).popover('destroy'); @@ -539,6 +603,7 @@ var invisibleStyleIcon = new ol.style.Style({ methods.openPopup(feature); } } else { + settings.current_popup = null; $(settings.popup_item).popover('destroy'); } } @@ -853,18 +918,26 @@ var invisibleStyleIcon = new ol.style.Style({ methods.preload_images(); }, // end of init - update_permalink_activation:function(){ - if (settings.checked_categories.length || - settings.current_feature || - settings.routing_speed || - settings.routing_transport || - settings.routing_start || - settings.routing_end){ - $("#permalink a").removeAttr("disabled"); - } else { - $("#permalink a").attr("disabled", "disabled"); - } - }, + /* + _panAndZoom: function(map, zoom_in, coordinates){ + var view = map.getView(); + var currentResolution = view.getResolution(); + var delta = zoom_in ? 1 : -1; + var pan = ol.animation.pan({ + duration: 500, + source: view.getCenter(), + easing: ol.easing.easeOut + }); + var zoom = ol.animation.zoom({ + resolution: currentResolution, + duration: 500, + easing: ol.easing.easeOut + }); + map.beforeRender(pan,zoom); + var newResolution = view.constrainResolution(currentResolution, delta); + view.setResolution(newResolution); + view.setCenter(coordinates); + },*/ register_reload_on_move: function(){ var reload_on_move = function(evnt){ settings._revision += 1; @@ -1083,6 +1156,7 @@ var invisibleStyleIcon = new ol.style.Style({ return feature; }, openPopup: function(feature, offset_x, offset_y, alt_coordinates){ + settings.current_popup = feature.getId(); if (!offset_x){ offset_x = feature.get('popup_offset_x'); if (!offset_x) offset_x = 0; @@ -1112,9 +1186,23 @@ var invisibleStyleIcon = new ol.style.Style({ 'content': feature.get('name') }); $(settings.popup_item).popover('show'); - methods.display_feature_detail(feature.get('key')); + methods.display_feature_detail(feature.get('key'), feature.get('name')); + register_hovering('.popover-content', [settings.MouseWheelZoom, + settings.DragPan]); }, /* end of new ol3 */ + update_permalink_activation:function(){ + if (settings.checked_categories.length || + settings.current_feature || + settings.routing_speed || + settings.routing_transport || + settings.routing_start || + settings.routing_end){ + $("#permalink a").removeAttr("disabled"); + } else { + $("#permalink a").attr("disabled", "disabled"); + } + }, /* Preload icons */ preload_images: function(){ if (typeof extra_url == 'undefined') return; @@ -1172,9 +1260,10 @@ var invisibleStyleIcon = new ol.style.Style({ if ($('#chimere_map_menu').length){ $('#chimere_map_menu').hide(); } + /* if (settings.current_popup != null) { settings.current_popup.hide(); - } + }*/ // settings.map.events.unregister('click', settings.map, // methods.displayMapMenu); //settings.map.events.register('click', settings.map, @@ -2350,13 +2439,17 @@ var invisibleStyleIcon = new ol.style.Style({ settings.layerRoute.addFeatures([current_route]); return current_route; }, - display_feature_detail: function (key) { + display_feature_detail: function (key, name) { /* * update current detail panel with an AJAX request */ var uri = extra_url if (settings.area_id) uri += settings.area_id + "/" - uri += "getDetail/" + key; + uri += "getDetail/"; + if (settings.popupContentFull){ + uri += "popup/"; + } + uri += key; var params = {} if (settings.simple) { params["simple"] = 1; } $.ajax({url: uri, @@ -2364,7 +2457,6 @@ var invisibleStyleIcon = new ol.style.Style({ dataType: "html", success: function (data) { if ( settings.display_feature_detail_fx ) { - // Custom function ? settings.display_feature_detail_fx(data, settings); } else { @@ -2372,7 +2464,10 @@ var invisibleStyleIcon = new ol.style.Style({ $('#detail').html(data).fadeIn(); } else { - settings.current_popup.setContentHTML("<div class='cloud'>" + data + "</div>"); + $(".popover").addClass('inside-popup'); + $(".popover-title").html(name); + $(".popover-title").show(); + $(".popover-content").html(data); } } } @@ -2658,6 +2753,7 @@ var invisibleStyleIcon = new ol.style.Style({ settings.hide_popup_fx(evt, settings) } else { // Default behaviour + /* if (settings.current_popup) { settings.current_feature = null; @@ -2671,7 +2767,7 @@ var invisibleStyleIcon = new ol.style.Style({ methods.update_permalink_activation(); return true; } - } + }*/ } methods.update_permalink_activation(); return false; diff --git a/chimere/templates/chimere/blocks/map.html b/chimere/templates/chimere/blocks/map.html index 06e5269..10f1c97 100644 --- a/chimere/templates/chimere/blocks/map.html +++ b/chimere/templates/chimere/blocks/map.html @@ -15,13 +15,6 @@ <div id='{{map_id}}'></div> <script type="text/javascript"> $("#{{map_id}}").show(); -/* -$(function(){ - $('#cluster_list').dialog({'autoOpen':false, - 'resizable':false, - 'width':340, - 'dialogClass':'no-titlebar'}); -});*/ </script> <div id="waiting"> <div id="waiting-content"> @@ -41,49 +34,46 @@ $(function(){ $("#categories-lnk").hide(); });{% endif %} {{extra_js|safe}} - var chimere_init_options = {}; - {% if MOBILE %}chimere_init_options["mobile"] = true;{% endif %} - {% if enable_clustering %}chimere_init_options["enable_clustering"] = true;{% endif %} - chimere_init_options["default_icon"] = '{{STATIC_URL}}img/marker-green.png'; - {% if js_map_layers %}chimere_init_options["map_layers"] = [{{js_map_layers|safe|escape}}];{% endif %} - chimere_init_options['permalink_label'] = '{%trans "Permalink"%}'; - chimere_init_options['permalink_element'] = document.getElementById('permalink'); - chimere_init_options['routing'] = {{routing}}; - {% if dynamic_categories %}chimere_init_options['dynamic_categories'] = true;{% endif %} - {% if default_area %} - chimere_init_options["default_area"] = new Array({{default_area.upper_left_corner.x}}, {{default_area.upper_left_corner.y}}, {{default_area.lower_right_corner.x}}, {{default_area.lower_right_corner.y}}); - {% endif %} - {% if p_zoom %}chimere_init_options["zoom"] = {{ p_zoom }};{% endif %} - {% if p_lat %}chimere_init_options["lat"] = {{ p_lat }};{% endif %} - {% if p_lon %}chimere_init_options["lon"] = {{ p_lon }};{% endif %} - {% if p_routing_start_lon %}chimere_init_options["routing_start_lon"] = {{ p_routing_start_lon }};{% endif %} - {% if p_routing_start_lat %}chimere_init_options["routing_start_lat"] = {{ p_routing_start_lat }};{% endif %} - {% if p_routing_end_lon %}chimere_init_options["routing_end_lon"] = {{ p_routing_end_lon }};{% endif %} - {% if p_routing_end_lat %}chimere_init_options["routing_end_lat"] = {{ p_routing_end_lat }};{% endif %} - {% if p_routing_steps %}chimere_init_options["routing_steps_lonlat"] = [{{ p_routing_steps }}];{% endif %} - {% if p_routing_transport %}chimere_init_options["routing_transport"] = "{{ p_routing_transport }}";{% endif %} - {% if p_routing_speed %}chimere_init_options["routing_speed"] = "{{ p_routing_speed }}";{% endif %} - chimere_init_options["dynamic_categories"] = {{ dynamic_categories }}; - {% if p_display_submited %}chimere_init_options["display_submited"] = {{ p_display_submited }};{% endif %} - chimere_init_options["checked_categories"] = [{% for cc in checked_categories %}{% if forloop.counter0 > 0 %}, {% endif %}{{cc}}{% endfor %}]; - {% if area_id %}chimere_init_options['area_id'] = "{{area_id}}";{% endif %} - {% if p_current_feature %} - chimere_init_options["display_feature"] = {{ p_current_feature }};{% endif %} - {% if p_current_route %} - chimere_init_options["display_route"] = {{ p_current_route }};{% endif %} + var chimere_init_options = { + {% if MOBILE %}"mobile": true,{% endif %} + {% if enable_clustering %}"enable_clustering": true,{% endif %} + {% if js_map_layers %}"map_layers": [{{js_map_layers|safe|escape}}],{% endif %} + {% if dynamic_categories %}'dynamic_categories': true,{% endif %} + {% if default_area %}"default_area": new Array({{default_area.upper_left_corner.x}}, {{default_area.upper_left_corner.y}}, {{default_area.lower_right_corner.x}}, {{default_area.lower_right_corner.y}}),{% endif %} + {% if p_zoom %}"zoom": {{ p_zoom }},{% endif %} + {% if p_lat %}"lat": {{ p_lat }},{% endif %} + {% if p_lon %}"lon": {{ p_lon }},{% endif %} + {% if p_routing_start_lon %}"routing_start_lon": {{ p_routing_start_lon }},{% endif %} + {% if p_routing_start_lat %}"routing_start_lat": {{ p_routing_start_lat }},{% endif %} + {% if p_routing_end_lon %}"routing_end_lon": {{ p_routing_end_lon }},{% endif %} + {% if p_routing_end_lat %}"routing_end_lat": {{ p_routing_end_lat }},{% endif %} + {% if p_routing_steps %}"routing_steps_lonlat": [{{ p_routing_steps }}],{% endif %} + {% if p_routing_transport %}"routing_transport": "{{ p_routing_transport }}",{% endif %} + {% if p_routing_speed %}"routing_speed": "{{ p_routing_speed }}",{% endif %} + "dynamic_categories": {{ dynamic_categories }}, + {% if p_display_submited %}"display_submited": {{ p_display_submited }},{% endif %} + "checked_categories": [{% for cc in checked_categories %}{% if forloop.counter0 > 0 %}, {% endif %}{{cc}}{% endfor %}], + {% if area_id %}'area_id': "{{area_id}}",{% endif %} + {% if p_current_feature %} + "display_feature": {{ p_current_feature }},{% endif %} + {% if p_current_route %} + "display_route": {{ p_current_route }},{% endif %} + {% if popupContentFull %}"popupContentFull": true,{% endif %} + {% if selected_map_layer %}"selected_map_layer": {{selected_map_layer}},{% endif %} + "open_dialog_fx": function (title, content){ + $('#category_description-content').html(content); + $('#category_description-label').html(title); + $('#category_description').modal('show');}, + 'permalink_element': document.getElementById('permalink'), + "default_icon": '{{STATIC_URL}}img/marker-green.png', + 'routing': {{routing}}, + 'permalink_label': '{%trans "Permalink"%}' + }; {% if restricted_extent %}{{ restricted_extent }} chimere_init_options["restricted_extent"] = bounds; {% endif %} - {% if selected_map_layer %} - chimere_init_options["selected_map_layer"] = {{selected_map_layer}}; - {% endif %} $('#category_description').modal({show:false}); - chimere_init_options["open_dialog_fx"] = function (title, content){ - $('#category_description-content').html(content); - $('#category_description-label').html(title); - $('#category_description').modal('show'); - } $("#main-map").chimere(chimere_init_options); {% if zoom %} $('#maps').chimere('zoom', {'area':{{zoom}} }); diff --git a/chimere/templates/chimere/detail.html b/chimere/templates/chimere/detail.html index 93388b5..a89ab9a 100644 --- a/chimere/templates/chimere/detail.html +++ b/chimere/templates/chimere/detail.html @@ -1,7 +1,9 @@ {% load i18n sanitize chimere_tags %} <div id='detail-wrapper'> +{% if not popup %} <button onclick='$("#detail").fadeOut();return false;' type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h2>{{ marker.name }}</h2> +{% endif %} <div class='detail_content'> {% if marker.default_pictures or marker.default_pictures or marker.default_multimedia_items%} <div class='small-gallery'> diff --git a/chimere/templatetags/chimere_tags.py b/chimere/templatetags/chimere_tags.py index 27deebb..713f70d 100644 --- a/chimere/templatetags/chimere_tags.py +++ b/chimere/templatetags/chimere_tags.py @@ -215,7 +215,8 @@ def routing(context): def map(context, map_id='map'): context_data = {'map_id': map_id, "STATIC_URL": settings.STATIC_URL, - "enable_clustering": settings.CHIMERE_ENABLE_CLUSTERING} + "enable_clustering": settings.CHIMERE_ENABLE_CLUSTERING, + "popupContentFull": settings.CHIMERE_CONTENT_INSIDE_POPUP} context_data['MOBILE'] = context['MOBILE'] context_data['routing'] = 'true' \ if hasattr(settings, 'CHIMERE_ENABLE_ROUTING') and \ diff --git a/chimere/urls.py b/chimere/urls.py index 966ef4f..824c7ed 100644 --- a/chimere/urls.py +++ b/chimere/urls.py @@ -116,6 +116,9 @@ urlpatterns += patterns( url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?getDetail/' r'(?P<key>[a-zA-Z_-]*\d+)/?$', 'getDetail', name="get_detail"), + url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?getDetail/popup/' + r'(?P<key>[a-zA-Z_-]*\d+)/?$', + 'getDetail', {'popup': True}, name="get_detail"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?getDetail/undefined', 'getDetailUndefined', name="get_detail_undefined"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?getDescriptionDetail/' diff --git a/chimere/views.py b/chimere/views.py index 8de3b1d..8d32270 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -573,7 +573,7 @@ def getDetailUndefined(request, area_name): return HttpResponse('') -def getDetail(request, area_name, key): +def getDetail(request, area_name, key, popup=False): ''' Get the detail of a geographic item ''' @@ -596,6 +596,7 @@ def getDetail(request, area_name, key): if redir: return redir response_dct['marker'] = marker + response_dct['popup'] = popup if request.method == 'GET': if 'simple' in request.GET and request.GET['simple']: response_dct['simple'] = True |