]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_search.rhtml
Rework the new Go button on the search form so that it actually stands
[rails.git] / app / views / site / _search.rhtml
1 <script type="text/javascript">
2 <!--
3   function startSearch() {
4     updateSidebar("Search Results", "<p class='search_results_entry'>Searching...</p>");
5
6     $("search_field").style.display = "none";
7     $("search_active").style.display = "inline";
8   }
9
10   function endSearch() {
11     $("search_field").style.display = "inline";
12     $("search_active").style.display = "none";
13   }
14
15   function describeLocation() {
16     var position = getPosition();
17
18     <%= remote_function(:loading => "startSearch()",
19                         :complete => "endSearch()",
20                         :url => { :controller => :geocoder, :action => :description },
21                         :with => "'lat=' + position.lat + '&lon=' + position.lon") %>
22   }
23
24   <% if params[:query] %>
25   <%= remote_function(:loading => "startSearch()",
26                       :complete => "endSearch()",
27                       :url => { :controller => :geocoder, :action => :search, :query => h(params[:query]) }) %>
28   <% end %>
29 // -->
30 </script>
31
32 <% content_for "optionals" do %>
33   <div class="optionalbox">
34     <span class="oboxheader">Search</span>
35     <span class="whereami"><a href="javascript:describeLocation()">Where am I?</a></span>
36     <div class="search_form">
37     <span id="search_field">
38     <% form_remote_tag(:loading => "startSearch()",
39                        :complete => "endSearch()",
40                        :url => { :controller => :geocoder, :action => :search }) do %>
41       <table>
42         <tr>
43           <td><%= text_field_tag :query, h(params[:query]) %></td>
44           <td></td>
45           <td><%= submit_tag 'Go' %></td>
46         </tr>
47       </table>
48     <% end %>
49     </span>
50     <p id="search_active">Searching...</p>
51     </div>
52     <p class="search_help">
53       examples: 'Alkmaar', 'Regent Street, Cambridge', 'CB2 5AQ',
54       or 'post offices near Lünen'
55       <a href="http://wiki.openstreetmap.org/index.php/Search">more examples...</a>
56     </p>
57   </div>
58 <% end %>