Show a message when no features are found

This commit is contained in:
Tom Hughes 2014-03-09 13:11:35 +00:00
parent e329bf37c0
commit dedd87da28
3 changed files with 15 additions and 4 deletions

View file

@ -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 = $("<li>")
.addClass("query-result")
.data("geometry", featureGeometry(element, nodes))
.appendTo($ul);
var $p = $("<p>")
@ -175,6 +176,12 @@ OSM.Query = function(map) {
.appendTo($p);
}
}
if ($ul.find("li").length == 0) {
$("<li>")
.text(I18n.t("javascripts.query.nothing_found"))
.appendTo($ul);
}
}
});
}

View file

@ -1140,7 +1140,10 @@ header .search_form {
li {
padding: 15px 20px;
border-bottom: 1px solid #ddd;
&.query-result {
cursor: pointer;
}
&.selected {
background: #FFFFE6;

View file

@ -2125,6 +2125,7 @@ en:
node: Node
way: Way
relation: Relation
nothing_found: No features found
redaction:
edit:
description: "Description"