class Interview::ImageGalleryAttribute

Attributes

image_style[RW]
light_box_image_style[RW]
object[RW]
submethod[RW]

Protected Instance Methods

build_read(b) click to toggle source
# File lib/interview/controls/image_gallery_attribute.rb, line 8
def build_read(b)
  submethod = @submethod || 'attachment'
  image_style = @image_style || :thumb
  images = value
  
  b.section html_class: 'image-gallery' do
    images.each do |image|
      b.link url: image.send(submethod).url(@light_box_image_style), html_class: 'img-link', 
             html_options: { title: image.subtitle } do
        b << h.image_tag(image.send(submethod).url(image_style), class: 'img-thumb')
      end
    end
  end
end
build_write(b) click to toggle source
# File lib/interview/controls/image_gallery_attribute.rb, line 23
def build_write(b) # todo: delete
  object = @object || find_attribute(:object)
  submethod = @submethod || 'attachment'
  image_style = @image_style || :thumb
  images = object.send @method
  model = images.klass.model_name.singular
  
  b.section html_class: 'image-upload-group' do
  
    b << form_builder.hidden_field("#{@method.singularize}_ids", class: 'image-ids')

    # render_gallery(html, images, submethod, image_style, @light_box_image_style)
    #
    # light_box_image_url = @light_box_image_style ? "#{@light_box_image_style}_url" : 'url'
    # html.script id: 'image-thumb-script', type: 'text/x-tmpl' do
    #   html.a href: "{%=o.#{light_box_image_url}%}", class: 'img-link' do
    #     html.img class: 'img-thumb', src: "{%=o.thumb_url%}"
    #   end
    # end

    b.section html_class: "clearfix" do
      b.section style: 'span', html_class: "btn btn-default fileinput-button" do
        b.text text: "Bilder hinzufügen", style: 'span' # todo
        b << h.file_field_tag("#{model}[#{submethod}]", class: 'multiple-image-upload', multiple: true,
          data: {url: "/#{model.pluralize}.json", type: 'POST'})
      end
    end

    b.section class: 'upload-progress' do
    end

    b.section style: 'script', html_options: { id: 'upload-progress-script', type: 'text/x-tmpl' } do
      b.section do
        b.section html_class: 'inline-block' do
          b << h.image_tag('missing_180x180.png', class: 'img-thumb')
        end
        b.section html_class: 'inline-block' do
          b.text text: "{%=o.name%}"
          b.section html_class: 'progress' do
            b.section html_class: 'progress-bar bar', html_options: { style: 'width: 0%' }
          end
        end
      end
    end
  end
  
  return html.target!
end