Sha256: 0c504b9e5a11a603843d3bc93f1292be1f41f238c6dab2611d52b1e1f78b5fd4

Contents?: true

Size: 1.23 KB

Versions: 23

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Blacklight
  class SearchBarPresenter
    attr_reader :configuration, :view_context, :controller

    # Set the partial this presenter draws
    class_attribute :partial
    self.partial = 'catalog/search_form'

    def initialize(controller, configuration = view_context.blacklight_config)
      @controller = controller
      @view_context = controller.view_context
      @configuration = configuration
    end

    def render
      view_context.render partial, presenter: self
    end

    ##
    # @return [Boolean] should autocomplete be enabled in the UI
    def autocomplete_enabled?
      configuration.autocomplete_enabled.present? &&
        configuration.autocomplete_path.present?
    end

    ##
    # If no search parameters have been given, we should
    # auto-focus the user's cursor into the searchbox
    #
    # @return [Boolean]
    def autofocus?
      configuration.enable_search_bar_autofocus.present? &&
        configuration.enable_search_bar_autofocus &&
        controller.is_a?(Blacklight::Catalog) &&
        controller.action_name == "index" &&
        !controller.has_search_parameters?
    end

    def advanced_search_enabled?
      configuration.advanced_search.enabled
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
blacklight-7.24.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.23.0.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.23.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.22.2 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.22.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.22.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.21.2 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.21.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.21.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.20.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.20.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.19.2 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.19.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.19.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.18.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.18.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.17.2 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.17.1 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.17.0 app/presenters/blacklight/search_bar_presenter.rb
blacklight-7.16.0 app/presenters/blacklight/search_bar_presenter.rb