Sha256: 987974e2d29e99695e16d811e2bba26f0c98460c5a9abad991eeb82157ba2b62

Contents?: true

Size: 1.65 KB

Versions: 19

Compression:

Stored size: 1.65 KB

Contents

module Blacklight
  module GalleryHelper
    def render_gallery_collection documents
      index = -1
      documents.map do |object|
        index += 1
        template = gallery_wrapper_template(object)
        template.render(self, {document: object, document_counter: index}) if template

      end.join().html_safe
    end

    def render_slideshow_tag(document, image_options = {}, url_options = {})
      if blacklight_config.view_config(document_index_view_type).slideshow_method
        method_name = blacklight_config.view_config(document_index_view_type).slideshow_method
        send(method_name, document, image_options)
      elsif blacklight_config.view_config(document_index_view_type).slideshow_field
        url = slideshow_image_url(document)

        image_tag url, image_options if url.present?
      elsif has_thumbnail?(document)
        render_thumbnail_tag(document, image_options, url_options.reverse_merge(suppress_link: true))
      end
    end

    def slideshow_image_url(document)
      if document.has? blacklight_config.view_config(document_index_view_type).slideshow_field
        document.first(blacklight_config.view_config(document_index_view_type).slideshow_field)
      end
    end

    def gallery_wrapper_template(object)
      format = document_partial_name(object, nil)
      ['index_gallery_%{format}_wrapper', 'index_gallery'].each do |str|
        partial = str % { format: format }
        logger.debug "Looking for gallery document wrapper #{partial}"
        template = lookup_context.find_all(partial, lookup_context.prefixes, true, [:document, :document_counter], {}).first
        return template if template
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-gallery-2.1.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-2.0.2 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-2.0.1 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-2.0.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.7.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.6.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.5.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.4.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.3.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.2.1 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.2.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.1.1 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.1.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-0.12.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-1.0.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-0.11.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-0.10.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-0.9.0 app/helpers/blacklight/gallery_helper.rb
blacklight-gallery-0.8.0 app/helpers/blacklight/gallery_helper.rb