Use link_to and form_tag instead of link_to_remote and form_remote_tag

This commit is contained in:
Tom Hughes 2010-09-02 23:00:44 +01:00
parent 17f4e58e46
commit 7b37f4cb62
5 changed files with 25 additions and 22 deletions

View file

@ -4,6 +4,6 @@
<%= image_tag "searching.gif", :class => "search_searching" %>
</div>
<script type="text/javascript">
<%= remote_function :update => "search_#{source}", :url => { :action => "search_#{source}", :query => @query, :minlat => params[:minlat], :minlon => params[:minlon], :maxlat => params[:maxlat], :maxlon => params[:maxlon] } %>
<%= remote_function(:update => "search_#{source}", :url => raw(url_for(:action => "search_#{source}", :query => @query, :minlat => params[:minlat], :minlon => params[:minlon], :maxlat => params[:maxlat], :maxlon => params[:maxlon]))) %>
</script>
<% end %>

View file

@ -7,15 +7,11 @@
<% if @more_params %>
<div id="search_more_<%= @more_params.hash %>">
<p class="search_results_entry"><%=
startSpinner = update_page do |page|
page.replace_html "search_more_#{@more_params.hash}", image_tag("searching.gif", :class => "search_searching")
end
link_to_remote t('geocoder.results.more_results'),
:update => "search_more_#{@more_params.hash}",
:before => startSpinner,
:url => @more_params
%></p>
link_to_function(t('geocoder.results.more_results')) do |page|
page.replace_html "search_more_#{@more_params.hash}", image_tag("searching.gif", :class => "search_searching")
page << remote_function(:update => "search_more_#{@more_params.hash}", :url => raw(url_for(@more_params)))
end
%></p>
</div>
<% end %>
<% end %>

View file

@ -44,11 +44,7 @@
<li><%= link_to t('layouts.view'), {:controller => 'site', :action => 'index'}, {:id => 'viewanchor', :title => t('layouts.view_tooltip'), :class => viewclass} %></li>
<li><%= link_to t('layouts.edit') + '&nbsp;&#x25be;', {:controller => 'site', :action => 'edit'}, {:id => 'editanchor', :title => t('javascripts.site.edit_tooltip'), :class => editclass} %></li>
<li><%= link_to t('layouts.history'), {:controller => 'changeset', :action => 'list' }, {:id => 'historyanchor', :title => t('javascripts.site.history_tooltip'), :class => historyclass} %></li>
<% if params['controller'] == 'site' and (params['action'] == 'index' or params['action'] == 'export') %>
<li><%= link_to_remote t('layouts.export'), {:url => {:controller => 'export', :action => 'start'}}, {:id => 'exportanchor', :title => t('layouts.export_tooltip'), :class => exportclass, :href => url_for(:controller => 'site', :action => 'export')} %></li>
<% else %>
<li><%= link_to t('layouts.export'), {:controller => 'site', :action => 'export'}, {:id => 'exportanchor', :title => t('layouts.export_tooltip'), :class => exportclass} %></li>
<% end %>
<li><%= link_to t('layouts.gps_traces'), {:controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil}, {:id => 'traceanchor', :title => t('layouts.gps_traces_tooltip'), :class => traceclass} %></li>
<li><%= link_to t('layouts.user_diaries'), {:controller => 'diary_entry', :action => 'list', :display_name => nil}, {:id => 'diaryanchor', :title => t('layouts.user_diaries_tooltip'), :class => diaryclass} %></li>
</ul>

View file

@ -55,6 +55,12 @@
<% end %>
}
document.observe("dom:loaded", function () {
$("search_form").observe("ajax:before", setSearchViewbox);
$("search_form").observe("ajax:loading", startSearch);
$("search_form").observe("ajax:complete", endSearch);
});
<% if params[:query] %>
<%= remote_function(:loading => "startSearch()",
:url => { :controller => :geocoder, :action => :search, :query => h(params[:query]) }) %>
@ -68,11 +74,8 @@
<h1><%= t 'site.search.search' %></h1>
<div class="search_container">
<div id="search_field">
<% form_remote_tag(:before => "setSearchViewbox()",
:loading => "startSearch()",
:complete => "endSearch()",
:url => { :controller => :geocoder, :action => :search },
:html => { :id => "search_form", :method => "get", :action => url_for(:action => "index") }) do %>
<%= form_tag({ :controller => :geocoder, :action => :search },
{ :id => "search_form", :remote => true, :method => "get", :action => url_for(:action => "index") }) do %>
<%= text_field_tag :query, h(params[:query]), :tabindex => "1" %>
<%= submit_tag t('site.search.submit_text') %>
<% end %>

View file

@ -280,7 +280,15 @@ end
map.setCenter(centre, zoom);
});
<% if params[:action] == 'export' %>
<%= remote_function :url => { :controller => 'export', :action => 'start' } %>
<% end %>
document.observe("dom:loaded", function () {
$("exportanchor").observe("click", function (e) {
<%= remote_function :url => { :controller => 'export', :action => 'start' } %>;
Event.stop(e);
});
<% if params[:action] == 'export' %>
<%= remote_function :url => { :controller => 'export', :action => 'start' } %>;
<% end %>
});
// -->
</script>