module Searchgasm class Config # = Helpers Configuration # Provide configuration for searchgasm's rails helpers # # === Example # Searchgasm::Config.configure do |config| # config.helpers.order_by_link_asc_indicator = "ASC" # end class Helpers class << self # Which hidden fields to automatically include when creating a form with a Searchgasm object. See Searchgasm::Helpers::Form for more info. # # * Default: [:order_by, :order_as, :per_page] # * Accepts: Array, nil, false def hidden_fields @hidden_fields ||= (Searchgasm::Search::Base::SPECIAL_FIND_OPTIONS - [:page, :priority_order]) end attr_writer :hidden_fields # The class name for used in the order_as_link helper # # * Default: "order_as" # * Accepts: String def order_as_link_class_name @order_as_link_class_name ||= "order_as" end attr_writer :order_as_link_class_name # The class name for used in the order_as_select helper # # * Default: "order_as" # * Accepts: String def order_as_select_class_name @order_as_select_class_name ||= "order_as" end attr_writer :order_as_select_class_name # The indicator that is used when the sort of a column is ascending # # * Default:  ▲ # * Accepts: String or a Proc. # # === Examples # # config.asc_indicator = "(ASC)" # config.asc_indicator = Proc.new { |template| template.image_tag("asc.jpg") } def order_by_link_asc_indicator @order_by_link_asc_indicator ||= " ▲" end attr_writer :order_by_link_asc_indicator # The class name for used in the order_by_link helper # # * Default: "order_by" # * Accepts: String def order_by_link_class_name @order_by_link_class_name ||= "order_by" end attr_writer :order_by_link_class_name # See order_by_link_asc_indicator= def order_by_link_desc_indicator @order_by_link_desc_indicator ||= " ▼" end attr_writer :order_by_link_desc_indicator # The class name used in order_by_links for the link that it is currently ordering by # # * Default: "# The class name for used in the page_link helper # # * Default: "page" # * Accepts: String def order_by_links_ordering_by_class_name @order_by_links_ordering_by_class_name ||= "ordering_by" end attr_writer :order_by_links_ordering_by_class_name # The class name for used in the order_by_select helper # # * Default: "order_by" # * Accepts: String def order_by_select_class_name @order_by_select_class_name ||= "order_by" end attr_writer :order_by_select_class_name # The class name for used in the page_link helper # # * Default: "page" # * Accepts: String def page_link_class_name @page_link_class_name ||= "page" end attr_writer :page_link_class_name # The choices used in the per_page_links helper. Works just like per_page_select_choices. def per_page_links_choices @per_page_links_choices ||= per_page_select_choices end attr_writer :per_page_links_choices # The class that the current page link gets. # # * Default: "current_page" # * Accepts: String, set to nil to disable def page_links_current_page_class_name @page_links_current_page_class_name ||= "current_page" end attr_writer :page_links_current_page_class_name # The class that disabled page links get. Including the current page, prev page, next page, first page, and last page. # # * Default: "disabled_page" # * Accepts: String, set to nil to disable def page_links_disabled_class_name @page_links_disabled_class_name ||= "disabled_page" end attr_writer :page_links_disabled_class_name # The default for the :first option for the page_links helper. # # * Default: nil # * Accepts: Anything you want, text, html, etc. nil to disable def page_links_first @page_links_first end attr_writer :page_links_first # The default for the :inner_spread option for the page_links helper. # # * Default: 3 # * Accepts: Any integer >= 1, set to nil to show all pages def page_links_inner_spread @page_links_inner_spread ||= 3 end attr_writer :page_links_inner_spread # The class for the first page link # # * Default: "first_page" # * Accepts: String, nil to disable def page_links_first_page_class_name @page_links_first_page_class_name ||= "first_page" end attr_writer :page_links_first_page_class_name # The default for the :last option for the page_links helper. # # * Default: nil # * Accepts: Anything you want, text, html, etc. nil to disable def page_links_last @page_links_last end attr_writer :page_links_last # The class for the last page link # # * Default: "last_page" # * Accepts: String, nil to disable def page_links_last_page_class_name @page_links_last_page_class_name ||= "last_page" end attr_writer :page_links_last_page_class_name # The default for the :next option for the page_links helper. # # * Default: "Next >" # * Accepts: Anything you want, text, html, etc. nil to disable def page_links_next @page_links_next ||= "Next >" end attr_writer :page_links_next # The class for the next page link # # * Default: "next_page" # * Accepts: String, nil to disable def page_links_next_page_class_name @page_links_next_page_class_name ||= "next_page" end attr_writer :page_links_next_page_class_name # The default for the :outer_spread option for the page_links helper. # # * Default: 2 # * Accepts: Any integer >= 1, set to nil to display, 0 to only show the "..." separator def page_links_outer_spread @page_links_outer_spread ||= 1 end attr_writer :page_links_outer_spread # The class for the previous page link # # * Default: "prev_page" # * Accepts: String, nil to disable def page_links_prev_page_class_name @page_links_prev_page_class_name ||= "prev_page" end attr_writer :page_links_prev_page_class_name # The default for the :prev option for the page_links helper. # # * Default: "< Prev" # * Accepts: Anything you want, text, html, etc. nil to disable def page_links_prev @page_links_prev ||= "< Prev" end attr_writer :page_links_prev # The class name for used in the page_seect helper # # * Default: "page" # * Accepts: String def page_select_class_name @page_select_class_name ||= "page" end attr_writer :page_select_class_name # The class name for used in the per_page_link helper # # * Default: "per_page" # * Accepts: String def per_page_link_class_name @per_page_link_class_name ||= "per_page" end attr_writer :per_page_link_class_name # The choices used in the per_page_select helper # # * Default: [["10 per page", 10], ["25 per page", 25], ["50 per page", 50], ["100 per page", 100], ["150 per page", 150], ["200 per page", 200], ["Show all", nil]] # * Accepts: Array def per_page_select_choices return @per_page_select_choices if @per_page_select_choices @per_page_select_choices = [] [10, 25, 50, 100, 150, 200].each { |choice| @per_page_select_choices << ["#{choice} per page", choice] } @per_page_select_choices << ["Show all", nil] end attr_writer :per_page_select_choices # The class name for used in the per_page_select helper # # * Default: "per_page" # * Accepts: String def per_page_select_class_name @per_page_select_class_name ||= "per_page" end attr_writer :per_page_select_class_name # The default value for the :activate_text option for priority_order_by_link # # * Default: "Show %s first" # * Accepts: String with substitutions, using rubys % method for strings def priority_order_by_link_activate_text @priority_order_by_link_activate_text ||= "Show %s first" end attr_writer :priority_order_by_link_activate_text # The class name for used in the priority_order_by_link helper # # * Default: "priority_order_by" # * Accepts: String def priority_order_by_link_class_name @priority_order_by_link_class_name ||= "priority_order_by" end attr_writer :priority_order_by_link_class_name # The default value for the :deactivate_text option for priority_order_by_link # # * Default: "Dont' show %s first" # * Accepts: String with substitutions, using rubys % method for strings def priority_order_by_link_deactivate_text @priority_order_by_link_deactivate_text ||= "Don't show %s first" end attr_writer :priority_order_by_link_deactivate_text end end end end