<%= stylesheet_link_tag "jquery.miniColors" %>

<%= javascript_include_tag "jquery.miniColors.min" %>

<%= javascript_include_tag "admin/categories" %>

<div id="categories_index">
 <table class="table main-list">
  <thead>
    <tr class="sort-header">
      <% @site_valid_locales.each_with_index do |locale, i| %>
        <th class="<%= 'span5' if i <= 1  %>"><a href="#"><%= t(:_locale, :locale => locale) %></a></th>
      <% end %>
      <th class="span2"><a href="#"><%= t('event_category.color') %></a></th>
    </tr>
  </thead>
  <tbody>
    <%= render partial: 'category', collection: @categories %>
  </tbody>
</table>

<div class="bottomnav clearfix">
  <div class="action pull-right">
    <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t(:add_category), id: 'new', module: @module_app_id.to_s } %>
  </div>
  <div class="pagination pagination-centered">
    <%= paginate @categories unless @categories.blank? %>
  </div>
</div>
</div>
<div id="pageslide">
  <div class="page-title clearfix">
    <a class="pull-right" href="javascript:$.pageslide.close()">
      <i class="icons-arrow-left-2"></i>
    </a>
    <span></span>
  </div>
  <div class="view-page">
    <div class="nano">
      <div class="content">
        <%= form_for :category, url: nil, html:{:id=>"color"}, remote: true do |f| %>
          <fieldset>
            <%= render :partial => "form", :locals => { :f => f } %>
            <div class="form-actions">
              <a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
              <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
            </div>
          </fieldset>
        <% end %>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
if($('.color-picker').length > 0){
    $('.color-picker').miniColors(); // just in category view
    $('.miniColors-trigger').addClass('btn');
}
$("form#color").bind("ajax:complete",function(){
  $.get("<%= panel_calendar_new_back_end_event_categories_list_path %>",function(data){
    $("#categories_index").html(data);
    openSlide();
  })
})
</script>