diff --git a/lib/ransack/configuration.rb b/lib/ransack/configuration.rb index 21fdcf8..b33d22b 100644 --- a/lib/ransack/configuration.rb +++ b/lib/ransack/configuration.rb @@ -9,7 +9,9 @@ module Ransack self.options = { :search_key => :q, :ignore_unknown_conditions => true, - :hide_sort_order_indicators => false + :hide_sort_order_indicators => false, + :up_arrow => '▼'.freeze, + :down_arrow => '▲'.freeze } def configure @@ -75,6 +77,24 @@ module Ransack self.options[:ignore_unknown_conditions] = boolean end + # Ransack's default arrows are html-code snippets found options at the + # top of this file. Arrows may be anything wrapped in quotation marks. + # Both arrows or a single arrow may be globally overridden in an + # initializer file like `config/initializers/ransack.rb` as follows: + # + # Ransack.configure do |config| + # # Set the up_arrow as an icon, set the down arrow as unicode + # config.custom_arrows = { + # up_arrow: '', + # down_arrow: 'U+02193' + # } + # end + # + def custom_arrows=(opts = {}) + self.options[:up_arrow] = opts[:up_arrow].freeze if opts[:up_arrow] + self.options[:down_arrow] = opts[:down_arrow].freeze if opts[:down_arrow] + end + # By default, Ransack displays sort order indicator arrows in sort links. # The default may be globally overridden in an initializer file like # `config/initializers/ransack.rb` as follows: diff --git a/lib/ransack/helpers/form_helper.rb b/lib/ransack/helpers/form_helper.rb index c67547e..53a91e5 100644 --- a/lib/ransack/helpers/form_helper.rb +++ b/lib/ransack/helpers/form_helper.rb @@ -110,11 +110,11 @@ module Ransack end def up_arrow - '▼'.freeze + Ransack.options[:up_arrow] end def down_arrow - '▲'.freeze + Ransack.options[:down_arrow] end def name