]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Convert search to pushState
[rails.git] / app / assets / javascripts / index.js
index 62d47a3afc6de7093a51227f2edb6cd810750c1e..91855f823c295407dd9dce453f9e0c1cfc55db71 100644 (file)
@@ -210,7 +210,6 @@ $(document).ready(function () {
     });
   }
 
-  initializeSearch(map);
   initializeBrowse(map, params);
   initializeNotes(map, params);
 
@@ -249,6 +248,7 @@ $(document).ready(function () {
 
   var router = OSM.Router({
     "/":                           OSM.Index(map),
+    "/search":                     OSM.Search(map),
     "/export":                     OSM.Export(map),
     "/browse/changesets":          OSM.ChangesetList(map),
     "/browse/:type/:id(/history)": OSM.Browse(map)
@@ -257,4 +257,14 @@ $(document).ready(function () {
   $(document).on("click", "a", function(e) {
     if (router(this.pathname + this.search + this.hash)) e.preventDefault();
   });
+
+  $("#search_form").on("submit", function(e) {
+    e.preventDefault();
+    router("/search?query=" + encodeURIComponent($("#query").val()) + OSM.formatHash(map));
+  });
+
+  $("#describe_location").on("click", function(e) {
+    e.preventDefault();
+    router("/search?query=" + encodeURIComponent(map.getCenter().lat + "," + map.getCenter().lng));
+  });
 });