From: Tom Hughes Date: Thu, 2 Sep 2010 22:00:44 +0000 (+0100) Subject: Use link_to and form_tag instead of link_to_remote and form_remote_tag X-Git-Tag: live~6139 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7b37f4cb62fca5fec3d3d41eacf4601595519c4a?hp=17f4e58e46b42e2b21704ff3293388ea9c11c77d Use link_to and form_tag instead of link_to_remote and form_remote_tag --- diff --git a/app/views/geocoder/_search.html.erb b/app/views/geocoder/_search.html.erb index b28feda09..7aac94f8e 100644 --- a/app/views/geocoder/_search.html.erb +++ b/app/views/geocoder/_search.html.erb @@ -4,6 +4,6 @@ <%= image_tag "searching.gif", :class => "search_searching" %> <% end %> diff --git a/app/views/geocoder/results.html.erb b/app/views/geocoder/results.html.erb index 694d0eadb..b4bbdc267 100644 --- a/app/views/geocoder/results.html.erb +++ b/app/views/geocoder/results.html.erb @@ -7,15 +7,11 @@ <% if @more_params %>

<%= - 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 - %>

+ 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 + %>

<% end %> <% end %> diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index 9bf39d9b9..3a8e1f1c0 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -44,11 +44,7 @@
  • <%= link_to t('layouts.view'), {:controller => 'site', :action => 'index'}, {:id => 'viewanchor', :title => t('layouts.view_tooltip'), :class => viewclass} %>
  • <%= link_to t('layouts.edit') + ' ▾', {:controller => 'site', :action => 'edit'}, {:id => 'editanchor', :title => t('javascripts.site.edit_tooltip'), :class => editclass} %>
  • <%= link_to t('layouts.history'), {:controller => 'changeset', :action => 'list' }, {:id => 'historyanchor', :title => t('javascripts.site.history_tooltip'), :class => historyclass} %>
  • - <% if params['controller'] == 'site' and (params['action'] == 'index' or params['action'] == 'export') %> -
  • <%= 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')} %>
  • - <% else %>
  • <%= link_to t('layouts.export'), {:controller => 'site', :action => 'export'}, {:id => 'exportanchor', :title => t('layouts.export_tooltip'), :class => exportclass} %>
  • - <% end %>
  • <%= 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} %>
  • <%= link_to t('layouts.user_diaries'), {:controller => 'diary_entry', :action => 'list', :display_name => nil}, {:id => 'diaryanchor', :title => t('layouts.user_diaries_tooltip'), :class => diaryclass} %>
  • diff --git a/app/views/site/_search.html.erb b/app/views/site/_search.html.erb index 8c5bd8b80..b1e5f4487 100644 --- a/app/views/site/_search.html.erb +++ b/app/views/site/_search.html.erb @@ -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 @@

    <%= t 'site.search.search' %>

    - <% 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 %> diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index d378a6ff7..8d0864f01 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -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 %> + }); +// -->