Sha256: 986a68556f79c9513ed53fbbf1eabf74ccf7a0f169a8b06ac7b56bc600b2a73c

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

class ActionView::Helpers::FormBuilder

  include ActionView::Helpers::Tags
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::FormTagHelper
  include ActionView::Helpers::FormOptionsHelper
  include ActionView::Helpers::CaptureHelper
  include ActionView::Helpers::AssetTagHelper
  include ActionView::Helpers::NumberHelper

  def gallery method, options = {}
    # Build the association
    @object.send("build_#{method}") unless @object.present? and @object.send(method).present?
    # ID of the input wrapper
    options[:id] = field_id(method, options[:index])
    # The fieldname for the association
    fieldname = @object_name + "[#{method}_attributes][asset_ids][]"
    
    # Add the asset preview or the empty preview div
    if gallery = @object.send(method)
      asset_preview = ""
      gallery.assets.each do |a|
        asset_preview += asset_html(a, fieldname)
      end
    else
      asset_preview = content_tag(:div, "", class: "uploader-preview")
    end

    # Uploader HTML with the asset previews and actions
    uploader_html = content_tag(:div, (asset_preview.html_safe), class: "uploader-data-wrapper")

    # Wrap the previews and uploader in a div
    uploader_wrapper = content_tag(:div, uploader_html, class: "gallery-uploader", id: options[:id], :'data-uploader-input-name' => fieldname, :'data-uploader-directions' => get_directions(options), :'data-max-file-size' => get_max_file_size(options))
    return uploader_wrapper
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
assetable-0.3.1 config/initializers/gallery_input.rb
assetable-0.3.0 config/initializers/gallery_input.rb
assetable-0.2.4 config/initializers/gallery_input.rb
assetable-0.2.2 config/initializers/gallery_input.rb
assetable-0.2.1 config/initializers/gallery_input.rb
assetable-0.1.10 config/initializers/gallery_input.rb