Sha256: f6f0937fc2ab6e72ecffc6c6fdaf58351f97fedebf42f9b76ecec7fd042f8f85

Contents?: true

Size: 1.13 KB

Versions: 26

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Gallery
    class SlideshowComponent < Blacklight::DocumentComponent
      def count
        @document.response&.total
      end

      def render_document_class(*args)
        @view_context.render_document_class(*args)
      end

      def presenter
        @presenter ||= @view_context.document_presenter(@document)
      end

      def slideshow_tag(image_options = { alt: '' })
        if view_config.slideshow_method
          method_name = view_config.slideshow_method
          @view_context.send(method_name, @document, image_options)
        elsif view_config.slideshow_field
          return if slideshow_image_url.blank?
          image = image_tag slideshow_image_url, image_options
          helpers.link_to_document(@document, image)
        elsif presenter.thumbnail.exists?
          presenter.thumbnail.thumbnail_tag(image_options)
        end
      end

      def slideshow_image_url
        @document.first(view_config.slideshow_field) if @document.has? view_config.slideshow_field
      end

      def view_config
        presenter.thumbnail.view_config
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
blacklight-gallery-4.2.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-4.1.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-4.0.2 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-4.0.1 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-4.0.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.5.0 app/components/blacklight/gallery/slideshow_component.rb