]> git.openstreetmap.org Git - rails.git/commitdiff
Make close button on route dialogue return to index.
authorMatt Amos <zerebubuth@gmail.com>
Mon, 26 Jan 2015 15:02:55 +0000 (15:02 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 26 Jan 2015 15:02:55 +0000 (15:02 +0000)
app/assets/javascripts/index.js
app/assets/javascripts/index/directions.js.erb
app/views/layouts/_search.html.erb

index 66dfa5b6fac3975a2c00daa6b651d76034303ef0..afb6b3d6546b3de788bf0a834c0c6db72ac3b494 100644 (file)
@@ -236,6 +236,10 @@ $(document).ready(function () {
     };
 
     page.load = function() {
+      var params = querystring.parse(location.search.substring(1));
+      if (params.query) {
+        $("#sidebar .search_form input[name=query]").value(params.query);
+      }
       if (!("autofocus" in document.createElement("input"))) {
         $("#sidebar .search_form input[name=query]").focus();
       }
index b1f9e44b9be6dd1e346377cfe986fd08a45db9d4..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
index fb4f79eb66e8a039fdd75fb5857f3f47b08f9ed6..5b6806e3d8d9fa47dbd3aece8d324b863a822516 100644 (file)
@@ -9,7 +9,7 @@
   </form>
 
   <form method="GET" action="<%= directions_path %>" class="directions_form">
-    <div width="100%" align="right" style="height:30px"><%= link_to tag('span', { :class => "icon close"}), root_path, { :title => t('site.search.close_directions_title') } %></div>
+    <div width="100%" align="right" style="height:30px"><%= link_to tag('span', { :class => "icon close"}), root_path, { :title => t('site.search.close_directions_title'), :class => "directions_close" } %></div>
 
     <div class="line">
       <%= image_tag "marker-green.png", :class => 'routing_marker', :id => 'marker_from', :draggable => 'true' %>