Class: Blacklight::Gallery::SlideshowPreviewComponent
- Inherits:
-
DocumentComponent
- Object
- DocumentComponent
- Blacklight::Gallery::SlideshowPreviewComponent
- Defined in:
- app/components/blacklight/gallery/slideshow_preview_component.rb
Instance Method Summary collapse
- #before_render ⇒ Object
- #data_attributes ⇒ Object
-
#initialize(document:, document_counter: nil, **args) ⇒ SlideshowPreviewComponent
constructor
A new instance of SlideshowPreviewComponent.
- #link_to_document ⇒ Object
-
#populate_thumbnail_slot ⇒ Object
populate the thumbnail slot with a value if one wasn’t explicitly provided.
- #presenter ⇒ Object
- #render_document_class(*args) ⇒ Object
Constructor Details
#initialize(document:, document_counter: nil, **args) ⇒ SlideshowPreviewComponent
Returns a new instance of SlideshowPreviewComponent.
8 9 10 11 12 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 8 def initialize(document:, document_counter: nil, **args) super(document: document, document_counter: document_counter, **args) @slide_to = @counter - 1 end |
Instance Method Details
#before_render ⇒ Object
14 15 16 17 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 14 def before_render populate_thumbnail_slot if thumbnail.blank? super end |
#data_attributes ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 44 def data_attributes # 'context-href': nil is for Blacklight < 7.38, :context_href is for those after 7.38 { 'context-href': nil, context_href: nil, 'slide-to': @slide_to, 'bs-slide-to': @slide_to, toggle: "modal", 'bs-toggle': "modal", target: "#slideshow-modal", 'bs-target': "#slideshow-modal" } end |
#link_to_document ⇒ Object
40 41 42 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 40 def link_to_document helpers.link_to_document(@document, thumbnail, class: 'thumbnail', data: data_attributes) end |
#populate_thumbnail_slot ⇒ Object
populate the thumbnail slot with a value if one wasn’t explicitly provided
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 20 def populate_thumbnail_slot thumbnail_content = presenter.thumbnail.render({ alt: presenter.heading }) if presenter.thumbnail.exists? unless thumbnail_content.present? thumbnail_content = content_tag( :div, t(:missing_image, scope: %i[blacklight_gallery catalog grid_slideshow]), class: 'thumbnail thumbnail-placeholder' ) end with_thumbnail(thumbnail_content) end |
#presenter ⇒ Object
32 33 34 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 32 def presenter @presenter ||= @view_context.document_presenter(@document) end |
#render_document_class(*args) ⇒ Object
36 37 38 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 36 def render_document_class(*args) @view_context.render_document_class(*args) end |