Refactors search form

It only appears when the page asks for it.
Also, the i18n namespace and the path used for the form are parameters
now
This commit is contained in:
kikito
2015-09-12 18:32:13 +02:00
parent 3bcea097c6
commit c44e709f24
6 changed files with 35 additions and 17 deletions

View File

@@ -1,3 +1,9 @@
<% content_for :header_addon do %>
<%= render "shared/search_form_header",
search_path: debates_path(page: 1),
i18n_namespace: "debates.index.search_form" %>
<% end %>
<section role="main">
<div class="wrap row">

View File

@@ -43,7 +43,7 @@
<% end %>
</div>
<div class="small-12 medium-4 column right">
<%= render "shared/search_form_header" %>
<%= yield :header_addon %>
</div>
</section>
</div>

View File

@@ -1,21 +1,27 @@
<% # Params:
#
# search_path: for example debates_path
# i18n_namespace: for example "debates.index.search_form"
%>
<div class="search-form">
<div class="sidebar-divider"></div>
<h3><%= t("shared.search_form.search_title") %></h3>
<h3><%= t("#{i18n_namespace}.title") %></h3>
<br>
<div class="row">
<%= form_tag debates_path, method: :get do %>
<%= form_tag search_path, method: :get do %>
<div class="small-12 columns">
<div class="row collapse">
<div class="small-9 medium-12 large-9 columns">
<input type="text" name="search" placeholder="<%= t("shared.search_form.search_placeholder") %>" class="search-form">
<input type="text" name="search" placeholder="<%= t("#{i18n_namespace}.placeholder") %>" class="search-form">
</div>
<div class="small-3 medium-12 large-3 columns">
<input type="submit" class="button secondary postfix" value="<%= t('shared.search_form.search_button') %>">
<input type="submit" class="button secondary postfix" value="<%= t("#{i18n_namespace}.button") %>">
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>

View File

@@ -1,14 +1,20 @@
<% # Params:
#
# i18n_namespace: for example "debates.index.search_form"
# search_path: for example debates_path
%>
<div class="search-form">
<div class="row">
<%= form_tag debates_path, method: :get do %>
<%= form_tag search_path, method: :get do %>
<div class="small-12 columns">
<div class="row collapse">
<div class="small-10 column">
<input type="text" name="search" placeholder="<%= t("shared.search_form.search_placeholder") %>" class="search-form">
<input type="text" name="search" placeholder="<%= t("#{i18n_namespace}.placeholder") %>" class="search-form">
</div>
<div class="small-2 column">
<button type="submit" class="button postfix" title="<%= t('shared.search_form.search_button') %>">
<button type="submit" class="button postfix" title="<%= t("#{i18n_namespace}.button") %>">
<i class="icon-search"></i>
</button>
</div>