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 |
# 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) @document_counter = document_counter || @counter end |
Instance Method Details
#before_render ⇒ Object
13 14 15 16 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 13 def before_render populate_thumbnail_slot if thumbnail.blank? super end |
#data_attributes ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 43 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': @document_counter, 'bs-slide-to': @document_counter, toggle: "modal", 'bs-toggle': "modal", target: "#slideshow-modal", 'bs-target': "#slideshow-modal" } end |
#link_to_document ⇒ Object
39 40 41 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 39 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
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 19 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
31 32 33 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 31 def presenter @presenter ||= @view_context.document_presenter(@document) end |
#render_document_class(*args) ⇒ Object
35 36 37 |
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 35 def render_document_class(*args) @view_context.render_document_class(*args) end |