]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_search.html.erb
Drop the username from the "new diary entry" link to avoid problems
[rails.git] / app / views / site / _search.html.erb
1 <script type="text/javascript">
2 <!--
3   function startSearch() {
4     updateSidebar("<%= t 'site.sidebar.search_results' %>", "");
5   }
6
7   function describeLocation() {
8     var position = getPosition();
9     var zoom = getZoom();
10
11     <%= remote_function(:loading => "startSearch()",
12                         :url => { :controller => :geocoder, :action => :description },
13                         :with => "'lat=' + position.lat + '&lon=' + position.lon + '&zoom=' + zoom") %>
14   }
15
16   function setSearchViewbox() {
17     <% if params[:action] == 'index' %>
18     var extent = getMapExtent();
19
20     $("minlon").value = extent.left;
21     $("minlat").value = extent.bottom;
22     $("maxlon").value = extent.right;
23     $("maxlat").value = extent.top;
24     <% end %>
25   }
26
27   <% if params[:query] %>
28   <%= remote_function(:loading => "startSearch()",
29                       :url => { :controller => :geocoder, :action => :search, :query => h(params[:query]) }) %>
30   <% end %>
31 // -->
32 </script>
33
34 <% content_for "optionals" do %>
35   <div class="optionalbox">
36     <span class="oboxheader"><%= t 'site.search.search' %></span>
37     <span class="whereami"><a href="javascript:describeLocation()" title="<%= t 'site.search.where_am_i_title' %>"><%= t 'site.search.where_am_i' %></a></span>
38     <div class="search_form">
39     <div id="search_field">
40     <% form_remote_tag(:before => "setSearchViewbox()",
41                        :loading => "startSearch()",
42                        :complete => "endSearch()",
43                        :url => { :controller => :geocoder, :action => :search },
44                        :html => { :method => "get", :action => url_for(:action => "index") }) do %>
45       <%= text_field_tag :query, h(params[:query]) %>
46       <% if params[:action] == 'index' %>
47         <%= hidden_field_tag :minlon %>
48         <%= hidden_field_tag :minlat %>
49         <%= hidden_field_tag :maxlon %>
50         <%= hidden_field_tag :maxlat %>
51       <% end %>
52       <%= submit_tag t('site.search.submit_text') %>
53     <% end %>
54     </div>
55     </div>
56     <p class="search_help">
57       <%= t 'site.search.search_help' %>
58     </p>
59   </div>
60 <% end %>