From: Tom Hughes Date: Tue, 8 Nov 2022 18:32:18 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/3780' X-Git-Tag: live~1491 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/8e976fbac165155366923a66a93868b48d665f85?hp=6fb57a68b6f6f989e0e2f571e02ddab0a2541395 Merge remote-tracking branch 'upstream/pull/3780' --- diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index c81d035fb..e44db9fdf 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -39,17 +39,21 @@ OSM.Query = function (map) { } }); + function showResultGeometry() { + var geometry = $(this).data("geometry"); + if (geometry) map.addLayer(geometry); + $(this).addClass("selected"); + } + + function hideResultGeometry() { + var geometry = $(this).data("geometry"); + if (geometry) map.removeLayer(geometry); + $(this).removeClass("selected"); + } + $("#sidebar_content") - .on("mouseover", ".query-results li.query-result", function () { - var geometry = $(this).data("geometry"); - if (geometry) map.addLayer(geometry); - $(this).addClass("selected"); - }) - .on("mouseout", ".query-results li.query-result", function () { - var geometry = $(this).data("geometry"); - if (geometry) map.removeLayer(geometry); - $(this).removeClass("selected"); - }) + .on("mouseover", ".query-results li.query-result", showResultGeometry) + .on("mouseout", ".query-results li.query-result", hideResultGeometry) .on("mousedown", ".query-results li.query-result", function () { var moved = false; $(this).one("click", function (e) { @@ -363,6 +367,7 @@ OSM.Query = function (map) { page.unload = function (sameController) { if (!sameController) { disableQueryMode(); + $("#sidebar_content .query-results li.query-result.selected").each(hideResultGeometry); } };