category toggling works

Oleg committed Aug 25, 2011
commit 30a204d08ea93476bfe9f9bcdb0c79a5c1d125d2
Showing 3 changed files with 18 additions and 7 deletions
app/assets/stylesheets/comfortable_mexican_sofa/content.css +7 -0
@@ @@ -103,6 +103,13 @@
padding: 3px 5px;
margin: 0px 5px 5px 0px;
}
+ #cms_body .categories_widget .category.active {
+ background-color: #f7f7f7;
+ }
+ #cms_body .categories_widget .category.active a,
+ #cms_body .categories_widget .category.active a:hover {
+ color: #000;
+ }
#cms_body .categories_widget .category a {
float: left;
color: #a3a3a3;
app/views/cms_admin/categories/_index.html.erb +1 -1
@@ @@ -8,7 +8,7 @@
<%= link_to t('.done'), '#', :class => 'action_link done', 'data-state' => 'done', :style => 'display:none' %>
<div class='categories read'>
- <div class='category all'>
+ <div class='category all <%= (params[:category].blank?? 'active' : nil ) %>'>
<%= link_to t('.all'), :category => nil %>
</div>
<% Cms::Category.of_type(type).each do |category| %>
app/views/cms_admin/categories/_show.html.erb +10 -6
@@ @@ -1,12 +1,16 @@
- <% category ||= show %>
- <% read ||= false %>
- <div class='category' id="<%= dom_id(category)%>">
-
+ <%
+ category ||= show
+ read ||= false
+ categories = [params[:category]].flatten.compact
+ active = categories.flatten.member?(category.label)
+ %>
+
+ <div class='category <%= read && active ? 'active' : nil %>' id="<%= dom_id(category)%>">
<% if read %>
- <%= link_to category.label, "?#{{:category => category.label}.to_param}" %>
+ <% categories = active ? categories.reject{|c| c == category.label} : categories << category.label %>
+ <%= link_to category.label, "?#{{:category => categories}.to_param}" %>
<% else %>
<%= link_to category.label, edit_cms_admin_site_category_path(@site, category), :remote => true %>
<%= link_to 'x', cms_admin_site_category_path(@site, category), :method => :delete, :remote => true, :confirm => t('.are_you_sure'), :class => 'delete' %>
<% end %>
-
</div>
\ No newline at end of file