Class: Blacklight::Gallery::OpenseadragonEmbedComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/gallery/openseadragon_embed_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document:, presenter:, view_config: nil, classes: [], **kwargs) ⇒ OpenseadragonEmbedComponent

Returns a new instance of OpenseadragonEmbedComponent.



8
9
10
11
12
13
14
15
16
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 8

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

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



6
7
8
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 6

def classes
  @classes
end

#documentObject (readonly)

Returns the value of attribute document.



6
7
8
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 6

def document
  @document
end

#presenterObject (readonly)

Returns the value of attribute presenter.



6
7
8
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 6

def presenter
  @presenter
end

Instance Method Details

#countObject



22
23
24
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 22

def count
  Array(image).length
end

#id_prefixObject



55
56
57
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 55

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

#imageObject



18
19
20
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 18

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

#osd_configObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 34

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

#osd_config_referencestripObject



46
47
48
49
50
51
52
53
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 46

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

#render?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 30

def render?
  !image.nil?
end

#view_configObject



26
27
28
# File 'app/components/blacklight/gallery/openseadragon_embed_component.rb', line 26

def view_config
  @view_config || presenter.view_config
end