Sha256: 75aa50414101e6f4904210d549a9abf665c735f6b49064e9d1e516c09204363b

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Gallery
    class OpenseadragonEmbedComponent < Blacklight::Component
      attr_reader :document, :presenter, :classes

      def initialize(document:, presenter:, view_config: nil, classes: [], **kwargs)
        super

        @document = document
        @presenter = presenter
        @view_config = view_config
        @classes = classes
        @id_prefix = id_prefix
      end

      def image
        @image ||= document.to_openseadragon(view_config)
      end

      def count
        Array(image).length
      end

      def view_config
        @view_config || presenter.view_config
      end

      def render?
        !image.nil?
      end

      def osd_config
        {
          crossOriginPolicy: false,
          zoomInButton: "#{@id_prefix}-zoom-in",
          zoomOutButton: "#{@id_prefix}-zoom-out",
          homeButton: "#{@id_prefix}-home",
          fullPageButton: "#{@id_prefix}-full-page",
          nextButton: "#{@id_prefix}-next",
          previousButton: "#{@id_prefix}-previous"
        }
      end

      def osd_config_referencestrip
        {
          showReferenceStrip: true,
          sequenceMode: true,
          referenceStripScroll: 'vertical',
          referenceStripBackgroundColor: 'transparent'
        }
      end

      def id_prefix
        "osd-#{Blacklight::OpenseadragonHelper.mint_id}".to_param
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-gallery-4.8.3 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.8.2 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.8.1 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.8.0 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.7.0 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.6.4 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.6.3 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.6.2 app/components/blacklight/gallery/openseadragon_embed_component.rb
blacklight-gallery-4.6.1 app/components/blacklight/gallery/openseadragon_embed_component.rb