diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 85453db..3512a31 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -23,6 +23,13 @@ module SearchHelper :products => 'full', } + FILTER_TRANSLATION = { + 'more_popular' => _('More popular'), + 'more_active' => _('More active'), + 'more_recent' => _('More recent'), + 'more_comments' => _('More comments') + } + # FIXME remove it after search_controler refactored include EventsHelper @@ -95,8 +102,20 @@ module SearchHelper full_link = display_full?(asset) ? (display == 'full' ? _('Full') : link_to(_('Full'), params.merge(:display => 'full'))) : nil content_tag('div', content_tag('strong', _('Display')) + ': ' + [compact_link, map_link, full_link].compact.join(' | '), - :id => 'search-display-filter', - :style => "float: #{float}" + :class => 'search-customize-options' + ) + end + end + + def filter_selector(asset, filter, float = 'right') + klass = asset_class(asset) + if klass::SEARCH_FILTERS.count > 1 + options = options_for_select(klass::SEARCH_FILTERS.map {|f| [FILTER_TRANSLATION[f], f]}, filter) + onchange = "document.location.href = document.location.search.replace(/filter=[^&]*|$/,'&filter='+this.value)" + select_field = select_tag(:filter, options, :onchange => onchange) + content_tag('div', + content_tag('strong', _('Filter')) + ': ' + select_field, + :class => "search-customize-options" ) end end diff --git a/app/views/search/_display_results.rhtml b/app/views/search/_display_results.rhtml index da62323..04b0bd8 100644 --- a/app/views/search/_display_results.rhtml +++ b/app/views/search/_display_results.rhtml @@ -10,7 +10,6 @@ <% if search[:results].total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %> <%= link_to(_('see all (%d)') % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %> <% end %> - <% params[:display] = 'compact' %> <% end %>
diff --git a/app/views/search/_results_header.rhtml b/app/views/search/_results_header.rhtml index 59bd7a1..6bc006e 100644 --- a/app/views/search/_results_header.rhtml +++ b/app/views/search/_results_header.rhtml @@ -1,5 +1,6 @@
">
<%= filter_title(@asset, @filter) %>
<%= display_selector(@asset, params[:display]) %> + <%= filter_selector(@asset, @filter)%>
diff --git a/public/stylesheets/search.css b/public/stylesheets/search.css index ccab214..3fe9762 100644 --- a/public/stylesheets/search.css +++ b/public/stylesheets/search.css @@ -6,6 +6,18 @@ position: relative; /* to the text appear on MSIE 6 */ width: 100%; } + +.controller-search .search-field .formfield { + width: 805px; + display: inline-block; +} + +.controller-search #content form input.button.submit { + display: inline-block; + height: 25px; + max-height: 25px; + width: 87px; +} .controller-search .current-cat-path { padding-left: 25px; } @@ -642,6 +654,7 @@ li.search-product-item hr { padding: 6px 0px 0px 0px; margin:0 0 5px 0; border-bottom: 2px dotted #999; + text-align: right; } #search-filter-title { font-weight: bold; @@ -666,8 +679,10 @@ li.search-product-item hr { color: #ff0000 } -#search-display-filter { - margin-top: 20px; +.search-customize-options { + display: inline-block; + margin-left: 8px; + margin-top: 10px; } /* Search field and button */ -- libgit2 0.21.2