]> git.openstreetmap.org Git - rails.git/commitdiff
Fix the "Where am I?" link
authorTom Hughes <tom@compton.nu>
Wed, 7 Aug 2013 07:42:57 +0000 (08:42 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 7 Aug 2013 07:42:57 +0000 (08:42 +0100)
app/assets/javascripts/index/search.js
app/views/site/_search.html.erb

index 486c9b36bbc521f3551635c34a755141365bd235..2f92e6282ec45fa49f13e3f4bd0e9bd4d8577428 100644 (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);    
+  }
 }
index 52adf66e1817e31df290976d10bb5f4883da5d21..c208b3219837fb184713b6c7d659769acaff6d07 100644 (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 %>