
-if admin
  %h2 Galerie photos
  %h2=input.name
  .description
    =raw input.description
 
  .gallery_images  
    =render :collection => input.gallery_images, :partial => "portlet/gallery_images/gallery_image"
    %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.img_gallery 
        -input.gallery_images.each do |gallery_images|
          -if gallery_images.image_file.file
            =link_to image_tag("http#{("s" if Rails.env.production?)}://"+HOSTNAME+gallery_images.image_file.file.square.url, :alt => "#{gallery_images.title}"), "http#{("s" if Rails.env.production?)}://"+HOSTNAME+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|
            -if gallery_images.image_file.file
              %li
                =image_tag "http#{("s" if Rails.env.production?)}://"+HOSTNAME+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
    
      .rea-gal.img_gallery 
        -input.gallery_images.each do |gallery_images|
          -if gallery_images.image_file.file
            =link_to image_tag("http#{("s" if Rails.env.production?)}://"+HOSTNAME+gallery_images.image_file.file.large.medium.small.thumb.url, :alt => "#{gallery_images.title}"), "http#{("s" if Rails.env.production?)}://"+HOSTNAME+gallery_images.image_file.file.large.url, :title => (gallery_images.title if input.show_title)
        
        