From: J Guthrie Date: Fri, 1 Dec 2017 01:38:23 +0000 (+0000) Subject: Added 'Reverse Directions' link X-Git-Tag: live~3757^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/7a933cf928cfca83e5448c699fa84d1e209ba0a7 Added 'Reverse Directions' link Added a text link that reverses the directions of the planned route --- diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index bb835f2fb..03e023bc1 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 6b99662a4..2f1215b5d 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 062fd95d4..70b67a24e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1424,6 +1424,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: