From 7007f99bfc8791f93bf36d9de691732812872b63 Mon Sep 17 00:00:00 2001 From: Thomas Schmidt Date: Fri, 9 Mar 2012 17:03:00 +0100 Subject: [PATCH] merge search pages --- app/controllers/search_controller.rb | 2 + app/views/search/_find_results.rhtml | 66 ++++++++++++++-------------- app/views/search/_search_form.rhtml | 28 ------------ app/views/search/find.rhtml | 8 +++- app/views/search/searchresult.rhtml | 18 -------- 5 files changed, 42 insertions(+), 80 deletions(-) delete mode 100644 app/views/search/_search_form.rhtml delete mode 100644 app/views/search/searchresult.rhtml diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 84fb5b5b5..1667b717e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -29,6 +29,8 @@ def searchresult } if request.xhr? render :partial => 'find_results' and return + else + render 'find' end end diff --git a/app/views/search/_find_results.rhtml b/app/views/search/_find_results.rhtml index b428519ae..6171d8214 100644 --- a/app/views/search/_find_results.rhtml +++ b/app/views/search/_find_results.rhtml @@ -3,39 +3,39 @@
diff --git a/app/views/search/_search_form.rhtml b/app/views/search/_search_form.rhtml deleted file mode 100644 index f03780961..000000000 --- a/app/views/search/_search_form.rhtml +++ /dev/null @@ -1,28 +0,0 @@ -<% content_for :ready_function do %> - $(function() { - var cache = {}, lastXhr; - $( "#search_form" ).autocomplete({ - minLength: 2, - source: function( request, response ) { - var term = request.term; - if ( term in cache ) { - response( cache[ term ] ); - return; - } - lastXhr = $.getJSON( "<%= url_for :controller => :search, :action => :autocomplete %>", request, function( data, status, xhr ) { - cache[ term ] = data; - if ( xhr === lastXhr ) { - response( data ); - } - }); - } - }); - }); -<% end -%> - - - -<% form_tag( {:controller => 'search', :action => :searchresult}, :method => :get ) do %> - <%= text_field_tag 'q', @query, :size => 40, :id => "search_form" %> - <%= submit_tag _('Search'), :name => nil, :class => "search-go-button" %> -<% end -%> \ No newline at end of file diff --git a/app/views/search/find.rhtml b/app/views/search/find.rhtml index 64a059def..24113f42b 100644 --- a/app/views/search/find.rhtml +++ b/app/views/search/find.rhtml @@ -5,4 +5,10 @@ <% content_for :content_for_head do %> <% end %> - <%= render :partial => 'search_form' %> \ No newline at end of file +<%= render :partial => 'find_form' %> + +
+ <% unless @result.blank? %> + <%= render :partial => 'find_results' %> + <% end %> +
\ No newline at end of file diff --git a/app/views/search/searchresult.rhtml b/app/views/search/searchresult.rhtml deleted file mode 100644 index 792a92189..000000000 --- a/app/views/search/searchresult.rhtml +++ /dev/null @@ -1,18 +0,0 @@ -<% @page_title = _("Search") -%> -<% @hide_side_box = true -%> -<% @hide_search_box = true -%> - -<% content_for :content_for_head do %> -<% end %> - - -<%= render :partial => 'find_form' %> - -
- <%= render :partial => 'find_results' %> -
- - - - -