X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/357d32c57c921f1d7ee15491601e1639be17b04d..98b1e5f76ce400af3270c3350804d40e30fd7d53:/app/assets/javascripts/index/query.js 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); } };