From 22c3c95a485a99ca161c713afdcec3dc5df2fbd1 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 13 Apr 2022 15:04:00 +0200 Subject: [PATCH] hotline #143830 call links event binding on openSteetMap popup --- public/opac/js/openStreetMap/openStreetMap.js | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/public/opac/js/openStreetMap/openStreetMap.js b/public/opac/js/openStreetMap/openStreetMap.js index a6311c84c0e..02adc3fbc65 100644 --- a/public/opac/js/openStreetMap/openStreetMap.js +++ b/public/opac/js/openStreetMap/openStreetMap.js @@ -24,6 +24,11 @@ var loadMap = function() { var container = widget.find('.leaflet_osm'); + container.innerHTML = ''; + + if(null != (initialized = L.DomUtil.get(container.attr('id')))) + initialized._leaflet_id = null; + var disable_zoom_animation = container.data('osm-disable-zoom-animation'); var map = L.map(container.attr('id'), @@ -37,7 +42,7 @@ if (1 == container.attr('data-osm-layer')) L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', - {attribution: '©<a href="https://osm.org/copyright">OpenStreetMap</a> contributors'}) + {attribution: '©<a href="https://osm.org/copyright">OpenStreetMap</a> contributors'}) .addTo(map); var clusterize_markers = (undefined != L.markerClusterGroup); @@ -116,6 +121,14 @@ map.fitBounds(markers_group.getBounds(), {padding: [1, 1]}); } + var initBokehAnchors = function() { + if ( typeof initializePopups === 'function') + initializePopups(); + + if ( typeof setupAnchorsTarget === 'function') + setupAnchorsTarget(); + } + map.on('popupclose', function() { if (clusterize_markers || relative_zoom) return; @@ -125,20 +138,20 @@ map.on('popupopen', function(event) { - $('.leaflet-popup-content img').on('load', function() { + $('.leaflet-popup-content img').on('load', function(e) { event.popup.update(); - }) - - event.popup.update(); + }); + + widget.on('mouseover', function(e) { + if ( ! widget.find('.leaflet-popup-content a[data-popup]').length) + return; - if ( typeof initializePopups === 'function') - initializePopups(); + initBokehAnchors(); + }); - if ( typeof setupAnchorsTarget === 'function') - setupAnchorsTarget(); + initBokehAnchors(); }); - originalPosition(); if (relative_zoom) map.zoomIn(relative_zoom); -- GitLab