Sha256: 1a38edeb0a37c7606b577c538aaa461c100963407316c61e22d5170faa261ef7

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 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
          url = slideshow_image_url

          image_tag url, image_options if url.present?
        elsif presenter.thumbnail.exists?
          presenter.thumbnail.thumbnail_tag(image_options, url_options.reverse_merge(suppress_link: true))
        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

10 entries across 10 versions & 1 rubygems

Version Path
blacklight-gallery-3.4.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.3.1 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.3.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.2.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.1.0 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.0.4 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.0.3 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.0.2 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.0.1 app/components/blacklight/gallery/slideshow_component.rb
blacklight-gallery-3.0.0 app/components/blacklight/gallery/slideshow_component.rb