
-if admin

  %h2=input.name
  .description
    =raw input.description
 
  .gallery_images  
    =render :collection => input.gallery_images, :partial => "portlet/gallery_images/gallery_image"
    
    =link_to "Ajouter des images dans cette galerie", "#", :onclick => "select_gallery_images_from_manager('#{input.id.to_s}');return false;", :class => "btn btn-default" 
    
    %p{:style => "clear:both;"}
  
  :coffeescript
  
    adjustment = ""
    
    $('.gallery_images').sortable({
      itemSelector:".gallery_image",
      containerSelector :".gallery_images",
      nested:true,
      placeholder:"<div class='placeholder' style='display:inline-block;width:50px;height:170px;'></div>",
      onDragStart: ($item, container, _super) ->
        $("body").addClass("dragging")
      
        offset = $item.offset()
        pointer = container.rootGroup.pointer
        adjustment = {
          left: pointer.left - offset.left,
          top: pointer.top - offset.top
          }
      onDrag: ($item, position, _super) ->
        
        $item.css({
          
          left: position.left - adjustment.left,
          top: position.top - adjustment.top - $(window).scrollTop()
          
        })
        
      onDrop: ($item, container, _super) ->
      
        $item.removeClass("dragged").removeAttr("style")
        $("body").removeClass("dragging")
      
        result = []
        container.el.find(".gallery_image").each ->
          result.push $(this).data("id")
        
      
    

        $.ajax({
          url:"/portlet/gallery_images/reorder.js", 
          type: "GET",
          data: { 
            order : result
            } 
    
        })
    });
  

  

-else
  
    
  
  -if input.style == 3
    .portlet.input
    
      
    
      .rea-gal  
        -input.gallery_images.each do |gallery_images|
          =link_to image_tag(gallery_images.image_file.file.square.url, :alt => "#{gallery_images.title}"), gallery_images.image_file.file.large.url, :title => gallery_images.title
        .clear
          

  -elsif input.style==2
 
    
    =raw "</div>"
    =raw "</div>"
  
    .slider




      .slides
        %ul.slides-container
          -input.gallery_images.each do |gallery_images|
            %li
              =image_tag gallery_images.image_file.file.large.url
          
              .desc
                -if gallery_images.title?
                  %h3
                    =gallery_images.title
                    ="/" if gallery_images.description?
                -if gallery_images.description?
                  =gallery_images.description
                  
    =raw "<div class='main'>"
    =raw "<div class='row-fluid'>"

             
    



  -elsif input.style==1
    .portlet.input
      %table.gallery_images  
        =raw "<tr>"
      
        - i = 0
        -input.gallery_images.each do |gallery_images|
          -if gallery_images.image_file
            - i = i+1
        
            %td=link_to image_tag(gallery_images.image_file.file.large.medium.small.thumb.url, :alt => "#{gallery_images.title}"), gallery_images.image_file.file.large.url, :rel => "prettyPhoto"
        
            -if i % 4 == 0
              =raw "</tr><tr>"
        
        
        =raw "</tr>"

  