.content
  %table{:style => "width:100%;"}
    %tr
      -@artwork.artwork_images.each do |artwork_image|
        %td{:style => "width:"+(100/@artwork.artwork_images.size).to_s+"%;height:400px;text-align:center;vertical-align:middle;"}

          =link_to image_tag(artwork_image.image.large.medium.url, :style => "max-width:100%;max-height:100%;"+("border:2px solid blue;" if artwork_image == artwork_image.artwork.artwork_image).to_s), admin_artwork_path(:id => @artwork, :"artwork[artwork_image_id]" =>artwork_image.id), :remote => true, :method => :put
    -if @artwork.artwork_images.size > 1
      %tr
        -@artwork.artwork_images.each do |artwork_image|
          %td=link_to i(:trash), admin_artwork_path(:id => @artwork.id, :artwork_image_id => artwork_image.id), :remote => true, :method => :delete
    
    %tr
      %td{:colspan => @artwork.artwork_images.size}
        =@artwork.title

  %div
    %div
      %div
        %form#artwork_fileupload{:action => admin_artworks_path(:portfolio_id => @artwork.portfolio.id, :artwork_id => @artwork.id, :multiple => params[:multiple]),:method=>"POST", :enctype=>"multipart/form-data", :style => "display:block;position:relative;"}
  
          %input{:name => "redirect", :type => "hidden", :value => "/"}/

          %a.btn{:href => "#", :onclick => "$(this).next('input').click();"}
            %span.fileinput-button{}
              %i.icon-plus.icon-white
              %span Ajouter des images
          %input{:multiple => "", :name => "files[]", :type => "file", :style => "display:none;"}


          .fileupload-progress.fade{:style => "float:right;"}
            .progress-extended{:style => "float:left;padding: 10px;font-size:14px;line-height:20px;"}


            .progress.progress-success.progress-striped.active{"aria-valuemax" => "100", "aria-valuemin" => "0", :role => "progressbar",:style => "width:200px;float:left;margin: 10px;height:20px;"}
              .bar{:style => "width:0%;"}

  






          :plain
             <!-- The template to display files available for upload -->
             <script id="template-upload" type="text/x-tmpl">
             {% for (var i=0, file; file=o.files[i]; i++) { %}
                 <tr class="template-upload fade">
                     <td>
                         <span class="preview"></span>
                     </td>
                     <td>
                         <p class="name">{%=file.name%}</p>
                         {% if (file.error) { %}
                             <div><span class="label label-important">Error</span> {%=file.error%}</div>
                         {% } %}
                     </td>
                     <td>
                         <p class="size">{%=o.formatFileSize(file.size)%}</p>
                         {% if (!o.files.error) { %}
                             <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
                         {% } %}
                     </td>
                     <td>
                         {% if (!o.files.error && !i && !o.options.autoUpload) { %}
                             <button class="btn btn-primary start">
                                 <i class="icon-upload icon-white"></i>
                                 <span>Start</span>
                             </button>
                         {% } %}
                         {% if (!i) { %}
                             <button class="btn btn-warning cancel">
                                 <i class="icon-ban-circle icon-white"></i>
                                 <span>Cancel</span>
                             </button>
                         {% } %}
                     </td>
                 </tr>
             {% } %}
             </script>
             <!-- The template to display files available for download -->
             <script id="template-download" type="text/x-tmpl">
             {% for (var i=0, file; file=o.files[i]; i++) { %}
                 <tr class="template-download fade", :style => "display:none;">

                 </tr>
             {% } %}
             </script>





    :coffeescript
      $('#artwork_fileupload').fileupload({
        paramName:"files",
        dataType:"script",
        autoUpload:true,
        filesContainer:".ulpoad_files"

      })

  =semantic_form_for [:admin, @artwork], :remote => true do |f| 
	
    = f.inputs do
  
      = f.input :title, :label => "Titre :"
      = f.input :description, :label => "Description :"
    
  
    =link_to raw(i(:trash, :icon => false))+" Supprimer", [:admin,@artwork], :method => :delete, :confirm => "voulez vous vraiment supprimer cette oeuvre ?", :class => "btn btn-danger", :remote => true
    = f.submit "Sauvegarder", :class => "btn btn-primary"
    
  
.actions

