From 321218f9b1b08451cd4fa4ea67b2a91189eeb37d Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 26 Jan 2015 15:02:55 +0000 Subject: [PATCH 1/1] Make close button on route dialogue return to index. --- app/assets/javascripts/index.js | 4 ++++ app/assets/javascripts/index/directions.js.erb | 10 ++++++++++ app/views/layouts/_search.html.erb | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 66dfa5b6f..afb6b3d65 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -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(); } diff --git a/app/assets/javascripts/index/directions.js.erb b/app/assets/javascripts/index/directions.js.erb index b1f9e44b9..f1f45814e 100644 --- a/app/assets/javascripts/index/directions.js.erb +++ b/app/assets/javascripts/index/directions.js.erb @@ -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 diff --git a/app/views/layouts/_search.html.erb b/app/views/layouts/_search.html.erb index fb4f79eb6..5b6806e3d 100644 --- a/app/views/layouts/_search.html.erb +++ b/app/views/layouts/_search.html.erb @@ -9,7 +9,7 @@
-
<%= link_to tag('span', { :class => "icon close"}), root_path, { :title => t('site.search.close_directions_title') } %>
+
<%= link_to tag('span', { :class => "icon close"}), root_path, { :title => t('site.search.close_directions_title'), :class => "directions_close" } %>
<%= image_tag "marker-green.png", :class => 'routing_marker', :id => 'marker_from', :draggable => 'true' %> -- 2.43.2