From: Tom Hughes Date: Wed, 7 Aug 2013 07:42:57 +0000 (+0100) Subject: Fix the "Where am I?" link X-Git-Tag: live~4796 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/258e66299ac45c4dbb951dee0a92194301b31737 Fix the "Where am I?" link --- diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 486c9b36b..2f92e6282 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -1,5 +1,6 @@ function initializeSearch(map) { $("#search_form").submit(submitSearch); + $("#describe_location").click(describeLocation); if ($("#query").val()) { $("#search_form").submit(); @@ -58,4 +59,18 @@ function initializeSearch(map) { map.addObject(data, { zoom: false, style: { opacity: 0.2, fill: false } }); } } + + function describeLocation(e) { + e.preventDefault(); + + var center = map.getCenter(), + zoom = map.getZoom(); + + $("#sidebar_title").html(I18n.t('site.sidebar.search_results')); + $("#sidebar_content").load($(this).attr("href"), { + lat: center.lat, + lon: center.lng, + zoom: zoom + }, openSidebar); + } } diff --git a/app/views/site/_search.html.erb b/app/views/site/_search.html.erb index 52adf66e1..c208b3219 100644 --- a/app/views/site/_search.html.erb +++ b/app/views/site/_search.html.erb @@ -1,18 +1,3 @@ - - <% content_for :optionals do %>
@@ -25,7 +10,7 @@

<%= raw(t 'site.search.search_help') %> - <%= t 'site.search.where_am_i' %> + <%= link_to t('site.search.where_am_i'), { :controller => :geocoder, :action => :description }, { :id => "describe_location", :title => t('site.search.where_am_i_title') } %>

<% end %>