Class: Blacklight::SearchBarPresenter
- Inherits:
-
Object
- Object
- Blacklight::SearchBarPresenter
- Extended by:
- Deprecation
- Defined in:
- app/presenters/blacklight/search_bar_presenter.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Instance Method Summary collapse
- #advanced_search_enabled? ⇒ Boolean
-
#autocomplete_enabled? ⇒ Boolean
Should autocomplete be enabled in the UI.
-
#autofocus? ⇒ Boolean
If no search parameters have been given, we should auto-focus the user's cursor into the searchbox.
-
#initialize(controller, configuration = view_context.blacklight_config) ⇒ SearchBarPresenter
constructor
A new instance of SearchBarPresenter.
- #render ⇒ Object
Constructor Details
#initialize(controller, configuration = view_context.blacklight_config) ⇒ SearchBarPresenter
Returns a new instance of SearchBarPresenter.
12 13 14 15 16 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 12 def initialize(controller, configuration = view_context.blacklight_config) @controller = controller @view_context = controller.view_context @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
6 7 8 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 6 def configuration @configuration end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
6 7 8 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 6 def controller @controller end |
#view_context ⇒ Object (readonly)
Returns the value of attribute view_context.
6 7 8 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 6 def view_context @view_context end |
Instance Method Details
#advanced_search_enabled? ⇒ Boolean
43 44 45 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 43 def advanced_search_enabled? configuration.advanced_search.enabled end |
#autocomplete_enabled? ⇒ Boolean
Returns should autocomplete be enabled in the UI.
25 26 27 28 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 25 def autocomplete_enabled? configuration.autocomplete_enabled.present? && configuration.autocomplete_path.present? end |
#autofocus? ⇒ Boolean
If no search parameters have been given, we should auto-focus the user's cursor into the searchbox
35 36 37 38 39 40 41 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 35 def autofocus? configuration..present? && configuration. && controller.is_a?(Blacklight::Catalog) && controller.action_name == "index" && !controller.has_search_parameters? end |
#render ⇒ Object
18 19 20 |
# File 'app/presenters/blacklight/search_bar_presenter.rb', line 18 def render view_context.render partial, presenter: self end |