Sha256: 54214653de1b8364ec52f934b2e62d0fa46f3df7036b9e7a87dbc04f93f305a1

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

module Georgia
  class MediaLibraryPresenter

    attr_accessor :view_context

    delegate :content_tag, :link_to, :picture_tag, :hidden_field_tag, :icon_tag, to: :view_context

    def initialize view_context, imageable, args={}
      @view_context = view_context
      @imageable = imageable
      @target = args.fetch(:target, 'media_library_image')
      @input = args.fetch(:input, image_input_tag)
    end

    def to_s
      content_tag(:div, class: 'media-library-image', id: @target) do
        media_featured_tag + choose_image_button_tag + @input
      end
    end

    def choose_image_button_tag
      link_to("#{icon_tag('picture-o')} Choose Image".html_safe, '#', class: 'btn btn-primary js-media-library', data: {media: "##{@target}", toggle: 'modal', target: '#media_library'})
    end

    def media_featured_tag
      content_tag :div, class: 'media-featured js-media-image' do
        picture_tag(image, format: :thumb)
      end
    end

    def image_input_tag
      hidden_field_tag(:image, image_id)
    end

    def image
      @imageable.image
    end

    def image_id
      @imageable.image_id
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
georgia-0.8.0 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.8 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.7 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.6 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.5 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.4 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.3 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.2 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.1 app/presenters/georgia/media_library_presenter.rb
georgia-0.7.0 app/presenters/georgia/media_library_presenter.rb