Sha256: 4a7be5495648420935599bcaa3ccd0e516af474ac22665140928b7cabb7339a4

Contents?: true

Size: 1.84 KB

Versions: 52

Compression:

Stored size: 1.84 KB

Contents

<%
p = @product
%>
<%= render :partial => 'caboose/products/admin_header' %>

<div id='categories'>
<table>
  <tr>
    <% @top_categories.each do |cat| %>
      <% next if cat.children && cat.children.count > 0 %>
      <td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
    <% end %>
  </tr>
  <tr>
    <% @top_categories.each do |cat| %>
      <% next if cat.children.nil? || cat.children.count == 0 %>
      <td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
    <% end %>
  </tr>
</table>
</div>

<%= render :partial => 'caboose/products/admin_footer' %>

<% content_for :caboose_css do %>
<style type='text/css'>
#categories input[type='checkbox'] { position: relative; }
#categories ul { list-style: none; margin: 0; padding: 0; }
#categories ul ul ul { margin-left: 20px; }
#categories li { list-style: none; }
#categories h3 { margin: 0; padding: 0; font-weight: bold; display: inline; }
#categories td { padding: 10px; }
</style>
<% end %>
<% content_for :caboose_js do %>
<script type='text/javascript'>

$(document).ready(function() {
  $('#categories input').click(function() {
    var cat_id = $(this).attr('id').split('_')[1];
    if ($(this).is(':checked'))
      add_product_to_category(<%= p.id %>, cat_id);
    else
      remove_product_from_category(<%= p.id %>, cat_id);        
  });  
});

var modal = false;
$(window).load(function() {
  modal = new CabooseModal(800);
});

function add_product_to_category(product_id, cat_id)
{
  $.ajax({
    url: '/admin/products/' + product_id + '/categories',
    type: 'post',
    data: { category_id: cat_id },
    success: function(resp) {}
  });
}

function remove_product_from_category(product_id, cat_id)
{
  $.ajax({
    url: '/admin/products/' + product_id + '/categories/' + cat_id,
    type: 'delete',
    success: function(resp) {}
  });
}

</script>
<% end %>

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
caboose-cms-0.5.55 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.54 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.53 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.52 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.51 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.50 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.49 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.48 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.47 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.46 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.45 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.44 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.43 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.42 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.41 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.40 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.39 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.38 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.37 app/views/caboose/products/admin_edit_categories.html.erb
caboose-cms-0.5.36 app/views/caboose/products/admin_edit_categories.html.erb