From dedd87da28b291db044318c1c114df8266b6c181 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 9 Mar 2014 13:11:35 +0000 Subject: [PATCH] Show a message when no features are found --- app/assets/javascripts/index/query.js | 13 ++++++++++--- app/assets/stylesheets/common.css.scss | 5 ++++- config/locales/en.yml | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 6b64ee8ee..e264dcf31 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -20,17 +20,17 @@ OSM.Query = function(map) { }); $("#sidebar_content") - .on("mouseover", ".query-results li", function () { + .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", function () { + .on("mouseout", ".query-results li.query-result", function () { var geometry = $(this).data("geometry") if (geometry) map.removeLayer(geometry); $(this).removeClass("selected"); }) - .on("click", ".query-results li", function (e) { + .on("click", ".query-results li.query-result", function (e) { if (!$(e.target).is('a')) { $(this).find("a").simulate("click", e); } @@ -163,6 +163,7 @@ OSM.Query = function(map) { if (interestingFeature(element, latlng)) { var $li = $("
  • ") + .addClass("query-result") .data("geometry", featureGeometry(element, nodes)) .appendTo($ul); var $p = $("

    ") @@ -175,6 +176,12 @@ OSM.Query = function(map) { .appendTo($p); } } + + if ($ul.find("li").length == 0) { + $("

  • ") + .text(I18n.t("javascripts.query.nothing_found")) + .appendTo($ul); + } } }); } diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index ab94b5dc7..628096b9f 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -1140,7 +1140,10 @@ header .search_form { li { padding: 15px 20px; border-bottom: 1px solid #ddd; - cursor: pointer; + + &.query-result { + cursor: pointer; + } &.selected { background: #FFFFE6; diff --git a/config/locales/en.yml b/config/locales/en.yml index 4db668b38..a4049f9e0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2125,6 +2125,7 @@ en: node: Node way: Way relation: Relation + nothing_found: No features found redaction: edit: description: "Description" -- 2.39.5