1 <script type="text/javascript">
3 function describeLocation() {
4 var args = getArgs($("viewanchor").href);
6 <%= remote_function(:loading => "startSearch()",
7 :url => { :controller => :geocoder, :action => :description },
8 :with => "'lat=' + args['lat'] + '&lon=' + args['lon'] + '&zoom=' + args['zoom']") %>
11 function setSearchViewbox() {
12 <% if params[:action] == 'index' %>
13 var extent = getMapExtent();
15 var minlon = document.createElement("input");
16 minlon.type = "hidden";
18 minlon.name = "minlon";
19 minlon.value = extent.left;
20 $("search_form").appendChild(minlon);
22 var minlat = document.createElement("input");
23 minlat.type = "hidden";
25 minlat.name = "minlat";
26 minlat.value = extent.bottom;
27 $("search_form").appendChild(minlat);
29 var maxlon = document.createElement("input");
30 maxlon.type = "hidden";
32 maxlon.name = "maxlon";
33 maxlon.value = extent.left;
34 $("search_form").appendChild(maxlon);
36 var maxlat = document.createElement("input");
37 maxlat.type = "hidden";
39 maxlat.name = "maxlat";
40 maxlat.value = extent.bottom;
41 $("search_form").appendChild(maxlat);
45 function startSearch() {
46 updateSidebar("<%= t 'site.sidebar.search_results' %>", "");
49 function endSearch() {
50 <% if params[:action] == 'index' %>
58 document.observe("dom:loaded", function () {
59 $("search_form").observe("ajax:before", setSearchViewbox);
60 $("search_form").observe("ajax:loading", startSearch);
61 $("search_form").observe("ajax:complete", endSearch);
64 <% if params[:query] %>
65 <%= remote_function(:loading => "startSearch()",
66 :url => { :controller => :geocoder, :action => :search, :query => h(params[:query]) }) %>
71 <% content_for :optionals do %>
72 <div class="optionalbox">
73 <span class="whereami"><a href="javascript:describeLocation()" title="<%= t 'site.search.where_am_i_title' %>"><%= t 'site.search.where_am_i' %></a></span>
74 <h1><%= t 'site.search.search' %></h1>
75 <div class="search_container">
76 <div id="search_field">
77 <%= form_tag({ :controller => :geocoder, :action => :search },
78 { :id => "search_form", :remote => true, :method => "get", :action => url_for(:action => "index") }) do %>
79 <%= text_field_tag :query, h(params[:query]), :tabindex => "1" %>
80 <%= submit_tag t('site.search.submit_text') %>
84 <p class="search_help">
85 <%= raw(t 'site.search.search_help') %>