.qi_header
  %h1="Liste des tags"



.qi_row
  .qi_pannel.qi_plain.padding
    %p
      =Tag.count
      tags
    =render :partial => "index_block"
    %br
    .qi_pagination
      = paginate @tags
      
%br
%br
.tag_bottom_bar
  =link_to ic(:arrows)+" déplacer", "#", :id => "move_link", :class => "btn btn-default"
:coffee
  @serialize_tags = ->
    result = []
    $("#sortable_tag input:checked").each ->
      result.push $(this).attr("value")
  
    return result
    
  $("#move_link").click ->
    tag_ids = serialize_tags()
    $(".tag_row").removeClass("no-receptable")
    $.each tag_ids, ( index, value ) ->
      
      $("#tag_row_"+value).addClass("no-receptable")
    $("#tag_index .receptable_link").show()
    
    return false
  
  $(document).on "click", "#tag_index .receptable_link", ->
  

    tag_ids = serialize_tags()
    $.ajax({url:"/admin/tags/"+$(this).data('tag-id')+"/reorder_by_group", type: "POST", data : { tag_ids : tag_ids}});
    
    $.each tag_ids, ( index, value ) ->
      
      $("#tag_row_"+value).remove()
      
    return false


:scss

  .receptable_link{
    display:none;
    
  }
  .no-receptable{
    opacity:0.5;
    
    .receptable_link{
      display:none !important;
    
    }
  }
  
  .tag_bottom_bar{
    position:fixed;
    bottom:0;
    left:0;
    right:0;
    padding:10px 20px ;
    background:rgba(255,255,255,0.8);
    border-top:1px solid rgba(0,0,0,0.1);
  }