From: Tom Hughes Date: Sat, 3 Feb 2018 16:12:51 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/1693' X-Git-Tag: live~3706 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/9d2f920feb9dce028b985e8d452538d3df7a1d9c?hp=6648d3a2a6202566099423472665d3072eb02ae9 Merge remote-tracking branch 'upstream/pull/1693' --- diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 94f9bb1f0..ee195af41 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -32,6 +32,8 @@ OSM.Directions = function (map) { function Endpoint(input, iconUrl) { var endpoint = {}; + endpoint.input = input; + endpoint.marker = L.marker([0, 0], { icon: L.icon({ iconUrl: iconUrl, @@ -111,6 +113,20 @@ OSM.Directions = function (map) { return endpoint; } + $(".directions_form .reverse_directions").on("click", function() { + var input_from = endpoints[0].input.val(); + var input_to = endpoints[1].input.val(); + var latlng_from = endpoints[0].latlng; + var latlng_to = endpoints[1].latlng; + + endpoints[0].setLatLng(latlng_to); + endpoints[1].setLatLng(latlng_from); + endpoints[0].input.val(input_to); + endpoints[1].input.val(input_from); + + getRoute(); + }); + $(".directions_form .close").on("click", function(e) { e.preventDefault(); var route_from = endpoints[0].value; diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 00e970e30..6df4c14ac 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1002,6 +1002,11 @@ header .search_forms, vertical-align: middle; } } + + a.reverse_directions { + cursor: pointer; + margin: 0px 0px 5px 25px; + } } /* Rules for the map key which appears in the popout sidebar */ diff --git a/app/views/layouts/_search.html.erb b/app/views/layouts/_search.html.erb index 2637d28b2..98b3c6c54 100644 --- a/app/views/layouts/_search.html.erb +++ b/app/views/layouts/_search.html.erb @@ -23,6 +23,9 @@ <%= submit_tag t('site.search.submit_text'), :class => "routing_go", :data => { disable_with: false } %> +
+ <%= t('site.search.reverse_directions_text') %> +
<%= image_tag "searching.gif" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 000e4c435..036f8de35 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1483,6 +1483,7 @@ en: where_am_i: "Where is this?" where_am_i_title: Describe the current location using the search engine submit_text: "Go" + reverse_directions_text: "Reverse Directions" key: table: entry: