Commit 5293de9484ebcbd06058898114463efb0b75760d

Authored by Rodrigo Souto
1 parent 35b00cd4

[search-improvements] Realize search through ajax and update only results

Missing update through ajax on sorting
app/views/search/_search_content.html.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<div id='search-content'>
  2 +<%= display_results(@searches, @asset) %>
  3 +<% if params[:display] != 'map' %>
  4 + <%= pagination_links @searches[@asset][:results] %>
  5 +<% end %>
  6 +<div>
... ...
app/views/search/articles.js.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +search.js.erb
0 2 \ No newline at end of file
... ...
app/views/search/communities.js.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +search.js.erb
0 2 \ No newline at end of file
... ...
app/views/search/enterprises.js.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +search.js.erb
0 2 \ No newline at end of file
... ...
app/views/search/people.js.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +search.js.erb
0 2 \ No newline at end of file
... ...
app/views/search/products.js.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +search.js.erb
0 2 \ No newline at end of file
... ...
app/views/search/search.js.erb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +jQuery('#search-content').html('<%= escape_javascript(render :partial => "search_content") %>');
... ...
app/views/search/search_page.html.erb
... ... @@ -3,10 +3,7 @@
3 3 <%= render :partial => 'search_form', :locals => { :hint => _("Type words about the %s you're looking for") % @asset.to_s.singularize } %>
4 4 <%= render :partial => 'results_header' %>
5 5  
6   -<%= display_results(@searches, @asset) %>
7   -<% if params[:display] != 'map' %>
8   - <%= pagination_links @searches[@asset][:results] %>
9   -<% end %>
  6 +<%= render :partial => 'search_content' %>
10 7  
11 8 <div style="clear: both"></div>
12 9  
... ... @@ -15,3 +12,5 @@
15 12 jQuery('.search-product-price-details').altBeautify();
16 13 <% end %>
17 14 <% end %>
  15 +
  16 +<%= javascript_include_tag 'search' %>
... ...
public/javascripts/search.js 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +(function($) {
  2 + //TODO Sorting
  3 + // Sorting and pagination links.
  4 + $('#search-content .pagination a').live('click',
  5 + function () {
  6 + $.getScript(this.href);
  7 + return false;
  8 + }
  9 + );
  10 +
  11 + // Search form
  12 + $('form.search_form').submit(function () {
  13 + $.ajax({
  14 + url: this.action,
  15 + data: $(this).serialize(),
  16 + beforeSend: function(){$('#search-content').addClass('searching')},
  17 + complete: function() {$('#search-content').removeClass('searching')},
  18 + dataType: 'script'
  19 + })
  20 + return false;
  21 + });
  22 +})(jQuery);
... ...
public/stylesheets/application.css
... ... @@ -6690,3 +6690,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img {
6690 6690 #signup-form #result-strong {
6691 6691 color: green;
6692 6692 }
  6693 +
  6694 +#search-content.searching {
  6695 + opacity: 0.3;
  6696 +}
... ...