]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/search.js
Rename directions_engines to directions
[rails.git] / app / assets / javascripts / index / search.js
index 46f756f3bc017275fb0c1a51b112d54c65d0aea7..08d2dc96c92b178c7ee10e0d1640ff4b7347c083 100644 (file)
@@ -9,6 +9,16 @@ OSM.Search = function(map) {
     }
   });
 
     }
   });
 
+  $(".search_form a.button.switch_link").on("click", function(e) {
+    e.preventDefault();
+    var query = $(e.target).parent().parent().find("input[name=query]").val();
+    if (query) {
+      OSM.router.route("/directions?from=" + encodeURIComponent(query) + OSM.formatHash(map));
+    } else {
+      OSM.router.route("/directions" + OSM.formatHash(map));
+    }
+  });
+
   $(".search_form").on("submit", function(e) {
     e.preventDefault();
     $("header").addClass("closed");
   $(".search_form").on("submit", function(e) {
     e.preventDefault();
     $("header").addClass("closed");