]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_search.rhtml
More search improvements - a "Where am I?" link that does a reverse
[rails.git] / app / views / site / _search.rhtml
1 <div id="search_results">
2   <table class="search_results_title" width="100%">
3     <tr>
4       <td align="left">Search Results</td>
5       <td align="right"><a href="javascript:closeSearchResults()">Close</a></td>
6     </tr>
7   </table>
8   <div id="search_results_content">
9   </div>
10 </div>
11
12 <script type="text/javascript">
13 <!--
14   function startSearch() {
15     $("search_results_content").innerHTML = "<p class='search_results_entry'>Searching...</p>";
16     $("search_field").style.display = "none";
17     $("search_active").style.display = "inline";
18   }
19
20   function endSearch() {
21     $("search_field").style.display = "inline";
22     $("search_active").style.display = "none";
23   }
24
25   function openSearchResults() {
26     $("search_results").style.display = "block";
27     <%= onopen %>
28   }
29
30   function closeSearchResults() {
31     $("search_results").style.display = "none";
32     <%= onclose %>
33   }
34
35   function describeLocation() {
36     var position = getPosition();
37
38     <%= remote_function(:loading => "startSearch()",
39                         :complete => "endSearch()",
40                         :url => { :controller => :geocoder, :action => :description },
41                         :with => "'lat=' + position.lat + '&lon=' + position.lon") %>
42   }
43
44   <% if params[:query] %>
45   <%= remote_function(:loading => "startSearch()",
46                       :complete => "endSearch()",
47                       :url => { :controller => :geocoder, :action => :search, :query => params[:query] }) %>
48   <% end %>
49 // -->
50 </script>
51
52 <% content_for "optionals" do %>
53   <div class="optionalbox">
54     <span class="oboxheader">Search</span>
55     <span class="whereami"><a href="javascript:describeLocation()">Where am I?</a></span>
56     <div class="search_form">
57     <span id="search_field">
58     <% form_remote_tag(:loading => "startSearch()",
59                        :complete => "endSearch()",
60                        :url => { :controller => :geocoder, :action => :search }) do %>
61       <%= text_field_tag :query, params[:query] %>
62     <% end %>
63     </span>
64     <p id="search_active">Searching...</p>
65     </div>
66     <p class="search_help">
67       examples: 'Alkmaar', 'Regent Street, Cambridge', 'CB2 5AQ',
68       or 'post offices near Lünen'
69       <a href="http://wiki.openstreetmap.org/index.php/Search_Help">more examples...</a>
70     </p>
71   </div>
72 <% end %>