- title :show, Cmtool::Directory
- content_for :onload_javascript do
  $('.add-image-container').dialog({modal: true, autoOpen: false, width: 400})
#add-image-container.modal.hide.fade
  .modal-header= t('cmtool.directory.add_file')
  = form_for [cmtool, Cmtool::Image.new(directory_id: @directory.id)], :html => { :multipart => true, :id => 'add_image_form' } do |f|
    .modal-body
      = f.hidden_field :directory_id
      = f.file_field :file
    .modal-footer
      %a.btn.btn-inverse{href: '#', role: :button, data: {dismiss: :modal}, 'aria-hidden' => true} x
      = f.submit t('cmtool.directory.add_image.label', image: Cmtool::Image.model_name.human), class: ['btn', 'btn-success']
.directory.caption= "/#{@directory.tree_path.map{|d| link_to(d.name, cmtool.directory_path(d))}.join('/')}".html_safe
%table#directory-view.table.table-striped.table-hover
  %thead
  %tbody
    %tr
      %td.directory.parent= link_to '..', (@directory.parent ? cmtool.directory_path(@directory.parent) : cmtool.directories_path)
      %td
      %td
      %td
    - for child in @directory.children
      %tr
        %td.directory.child= link_to child.name, cmtool.directory_path(child)
        %td
        %td
        %td.action.destroy.directory= link_to link_to_destroy_content(child), cmtool.directory_path(child), :method => :delete, :confirm => are_you_sure(child)
    - for image in @directory.images
      = render 'image', :image => image
- content_for :page_links do
  %ul
    - if @directory.parent
      %li= link_to '..', cmtool.directory_path(@directory.parent)
    %li= link_to link_to_edit_content(@directory), cmtool.edit_directory_path(@directory), class: ['btn', 'btn-warning']
    %li= link_to link_to_index_content(Cmtool::Directory), cmtool.directories_path, class: [:btn]
    %li= link_to t('cmtool.directory.add_file'), '#add-image-container', class: ['btn', 'btn-success'], role: :button, data: {toggle: :modal}
