Fix the "Where am I?" link

This commit is contained in:
Tom Hughes 2013-08-07 08:42:57 +01:00
parent acf419d000
commit 258e66299a
2 changed files with 16 additions and 16 deletions

View file

@ -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);
}
}

View file

@ -1,18 +1,3 @@
<script type="text/javascript">
<!--
function describeLocation() {
var args = querystring.parse($("#viewanchor").attr("href").split('?')[1]);
$("#sidebar_title").html("<%= t 'site.sidebar.search_results' %>");
$("#sidebar_content").load("<%= url_for :controller => :geocoder, :action => :description %>", {
lat: args["lat"],
lon: args["lon"],
zoom: args["zoom"]
}, openSidebar);
}
// -->
</script>
<% content_for :optionals do %>
<div class="optionalbox">
<div class="search_container">
@ -25,7 +10,7 @@
</div>
<p class='search_help deemphasize'>
<%= raw(t 'site.search.search_help') %>
<span class="whereami"><a href="javascript:describeLocation()" title="<%= t 'site.search.where_am_i_title' %>"><%= t 'site.search.where_am_i' %></a></span>
<%= link_to t('site.search.where_am_i'), { :controller => :geocoder, :action => :description }, { :id => "describe_location", :title => t('site.search.where_am_i_title') } %>
</p>
</div>
<% end %>