Remove duplicate search handlers
authorTom Hughes <tom@compton.nu>
Thu, 5 Mar 2015 00:34:06 +0000 (00:34 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 5 Mar 2015 00:34:06 +0000 (00:34 +0000)
Fixes #922

app/assets/javascripts/index.js
app/assets/javascripts/index/search.js

index 9a05b62c26ac2ca097e3e760d122b7ff97068ac1..9e386d54bf2bccef0b56c1e331d3fef0494c35dc 100644 (file)
@@ -355,24 +355,4 @@ $(document).ready(function () {
     if (OSM.router.route(this.pathname + this.search + this.hash))
       e.preventDefault();
   });
-
-  $(".search_form").on("submit", function(e) {
-    e.preventDefault();
-    $("header").addClass("closed");
-    var query = $(this).find("input[name=query]").val();
-    if (query) {
-      OSM.router.route("/search?query=" + encodeURIComponent(query) + OSM.formatHash(map));
-    } else {
-      OSM.router.route("/");
-    }
-  });
-
-  $(".describe_location").on("click", function(e) {
-    e.preventDefault();
-    var center = map.getCenter().wrap(),
-      precision = OSM.zoomPrecision(map.getZoom());
-    OSM.router.route("/search?query=" + encodeURIComponent(
-      center.lat.toFixed(precision) + "," + center.lng.toFixed(precision)
-    ));
-  });
 });
index b829b582c827289673480e7811f3e648dce9fd27..485920c8e1f901f93c1a04b1e29bdcdac4ba0146 100644 (file)
@@ -32,10 +32,11 @@ OSM.Search = function(map) {
 
   $(".describe_location").on("click", function(e) {
     e.preventDefault();
-    var precision = OSM.zoomPrecision(map.getZoom());
+    var center = map.getCenter().wrap(),
+      precision = OSM.zoomPrecision(map.getZoom());
     OSM.router.route("/search?query=" + encodeURIComponent(
-        map.getCenter().lat.toFixed(precision) + "," +
-        map.getCenter().lng.toFixed(precision)));
+      center.lat.toFixed(precision) + "," + center.lng.toFixed(precision)
+    ));
   });
 
   $("#sidebar_content")