]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions.js.erb
Make close button on route dialogue return to index.
[rails.git] / app / assets / javascripts / index / directions.js.erb
index 3520f3ecdb43b236420d6236ca1267e8be22353d..f1f45814e3bf6ee4d54d4d7fda90f498f98abd3b 100644 (file)
@@ -2,6 +2,16 @@
 //= require_tree ./directions_engines
 
 OSM.Directions = function (map) {
+  $(".directions_form a.directions_close").on("click", function(e) {
+    e.preventDefault();
+    var route_from = $(e.target).parent().parent().parent().find("input[name=route_from]").val();
+    if (route_from) {
+      OSM.router.route("/?query=" + encodeURIComponent(route_from) + OSM.formatHash(map));
+    } else {
+      OSM.router.route("/" + OSM.formatHash(map));
+    }
+  });
+
   var awaitingGeocode; // true if the user has requested a route, but we're waiting on a geocode result
   var awaitingRoute;   // true if we've asked the engine for a route and are waiting to hear back
   var dragging;        // true if the user is dragging a start/end point
@@ -195,7 +205,7 @@ OSM.Directions = function (map) {
         }
 
         var row = $("<tr class='turn'/>");
-        row.append("<td class='direction i" + direction + "'> ");
+        row.append("<td><div class='direction i" + direction + "'/></td> ");
         row.append("<td class='instruction'>" + instruction);
         row.append("<td class='distance'>" + dist);
 
@@ -290,6 +300,10 @@ OSM.Directions = function (map) {
       setEngine(params.engine);
     }
 
+    if (params.from) {
+      $(".directions_form input[name='route_from']").val(params.from);
+    }
+
     var o = route[0] && L.latLng(route[0].split(',')),
         d = route[1] && L.latLng(route[1].split(','));