One click filter in search view (#2865).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12080 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-08-05 17:19:49 +00:00
parent fd1b060705
commit bd4fba08e5
1 changed files with 16 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<h2><%= l(:label_search) %></h2> <h2><%= l(:label_search) %></h2>
<div class="box"> <div class="box">
<%= form_tag({}, :method => :get) do %> <%= form_tag({}, :method => :get, :id => 'search-form') do %>
<%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %> <%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %>
<p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %> <p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %>
<%= javascript_tag "$('#search-input').focus()" %> <%= javascript_tag "$('#search-input').focus()" %>
@ -11,13 +11,14 @@
<%= hidden_field_tag 'titles_only', '', :id => nil %> <%= hidden_field_tag 'titles_only', '', :id => nil %>
<label><%= check_box_tag 'titles_only', 1, @titles_only %> <%= l(:label_search_titles_only) %></label> <label><%= check_box_tag 'titles_only', 1, @titles_only %> <%= l(:label_search_titles_only) %></label>
</p> </p>
<p>
<p id="search-types">
<% @object_types.each do |t| %> <% @object_types.each do |t| %>
<label><%= check_box_tag t, 1, @scope.include?(t) %> <%= type_label(t) %></label> <label><%= check_box_tag t, 1, @scope.include?(t) %> <%= link_to type_label(t), "#" %></label>
<% end %> <% end %>
</p> </p>
<p><%= submit_tag l(:button_submit), :name => 'submit' %></p> <p><%= submit_tag l(:button_submit) %></p>
<% end %> <% end %>
</div> </div>
@ -50,3 +51,14 @@
</center></p> </center></p>
<% html_title(l(:label_search)) -%> <% html_title(l(:label_search)) -%>
<%= javascript_tag do %>
$("#search-types a").click(function(e){
e.preventDefault();
$("#search-types input[type=checkbox]").attr('checked', false);
$(this).siblings("input[type=checkbox]").attr('checked', true);
if ($("#search-input").val() != "") {
$("#search-form").submit();
}
});
<% end %>