X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/2e05669a22ce73fff3dc81aa99694bc893d249b7..501d13e1c0936cc3ba3d9639620517bae34e5784:/app/assets/javascripts/index/query.js diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 01a8a1f69..e2c8699ff 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -1,7 +1,9 @@ //= require jquery.simulate OSM.Query = function(map) { - var queryButton = $(".control-query .control-button"), + var protocol = document.location.protocol === "https:" ? "https:" : "http:", + url = protocol + OSM.OVERPASS_URL, + queryButton = $(".control-query .control-button"), uninterestingTags = ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid'], marker; @@ -20,9 +22,9 @@ OSM.Query = function(map) { if (queryButton.hasClass("disabled")) return; if (queryButton.hasClass("active")) { - disableQueryMode(); - - OSM.router.route("/"); + if ($("#content").hasClass("overlay-sidebar")) { + disableQueryMode(); + } } else { enableQueryMode(); } @@ -51,10 +53,20 @@ OSM.Query = function(map) { if (geometry) map.removeLayer(geometry); $(this).removeClass("selected"); }) - .on("click", ".query-results li.query-result", function (e) { - if (!$(e.target).is('a')) { - $(this).find("a").simulate("click", e); - } + .on("mousedown", ".query-results li.query-result", function (e) { + var moved = false; + $(this).one("click", function (e) { + if (!moved) { + var geometry = $(this).data("geometry") + if (geometry) map.removeLayer(geometry); + + if (!$(e.target).is('a')) { + $(this).find("a").simulate("click", e); + } + } + }).one("mousemove", function () { + moved = true; + }); }); function interestingFeature(feature, origin, radius) { @@ -163,7 +175,7 @@ OSM.Query = function(map) { } $section.data("ajax", $.ajax({ - url: OSM.OVERPASS_URL, + url: url, method: "POST", data: { data: "[timeout:5][out:json];" + query, @@ -203,7 +215,7 @@ OSM.Query = function(map) { $section.find(".loader").stopTime("loading").hide(); $("
  • ") - .text(I18n.t("javascripts.query." + status, { server: OSM.OVERPASS_URL, error: error })) + .text(I18n.t("javascripts.query." + status, { server: url, error: error })) .appendTo($ul); } }));