Module: Breeze::OptionsHelper
- Included in:
- BreezeHelper
- Defined in:
- app/helpers/breeze/options_helper.rb
Instance Method Summary collapse
- #background_option(section, clazz = "") ⇒ Object
- #column_option(section, clazz = "") ⇒ Object
- #date_precision(element, date_name) ⇒ Object
- #height_option(section, clazz = "") ⇒ Object
- #item_align_option(section, clazz = "") ⇒ Object
- #margin_option(section, clazz = "") ⇒ Object
-
#options(section, *args) ⇒ Object
use options with as many option names as neccessary.
- #order_option(section, clazz = "") ⇒ Object
-
#prose_option(section) ⇒ Object
adds prose irrespective of options.
- #shade_option(section, clazz = "") ⇒ Object
- #slider_columns_option(section, clazz = "") ⇒ Object
- #text_align_option(section, clazz = "") ⇒ Object
- #text_color_option(section, clazz = "") ⇒ Object
- #text_columns_option(section, clazz = "") ⇒ Object
Instance Method Details
#background_option(section, clazz = "") ⇒ Object
68 69 70 71 72 73 74 |
# File 'app/helpers/breeze/options_helper.rb', line 68 def background_option(section , clazz = "") if section.has_option?("background") option = section.option('background') clazz += " " + (Breeze.background[section.option('background')] || "") end {class: clazz} end |
#column_option(section, clazz = "") ⇒ Object
111 112 113 114 115 116 |
# File 'app/helpers/breeze/options_helper.rb', line 111 def column_option( section , clazz = "" ) if section.has_option?("columns") clazz += " " + (Breeze.columns[section.option("columns")] || "") end {class: clazz } end |
#date_precision(element, date_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/breeze/options_helper.rb', line 17 def date_precision(element , date_name) precision = element.option("date_precision") date = element.option(date_name) if( precision == "precise") return date.to_formatted_s(:short) + " " + date.year.to_s end return Date.today if date.blank? if(date.day < 10) attr = "Beginning" elsif date.day < 20 attr = "Middle" else attr = "End" end "#{attr} of #{date.strftime('%B')} #{date.year}" end |
#height_option(section, clazz = "") ⇒ Object
118 119 120 121 122 123 |
# File 'app/helpers/breeze/options_helper.rb', line 118 def height_option( section , clazz = "" ) if section.has_option?("height") clazz += " " + (section.option("height") || "") end {class: clazz } end |
#item_align_option(section, clazz = "") ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/breeze/options_helper.rb', line 54 def item_align_option(section , clazz = "") if section.has_option?("item_align") case section.option("item_align") when "left" clazz += " " + " justify-start" when "right" clazz += " " + " justify-end" else clazz += " " + " justify-center" end end {class: clazz } end |
#margin_option(section, clazz = "") ⇒ Object
76 77 78 79 80 |
# File 'app/helpers/breeze/options_helper.rb', line 76 def margin_option(section , clazz = "") return {class: clazz} unless section.has_option?("margin") margin = Breeze.margin[section.option("margin")] || "" {class: clazz + margin} end |
#options(section, *args) ⇒ Object
use options with as many option names as neccessary
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/breeze/options_helper.rb', line 5 def (section, *args ) all = {} extra_class = "" extra_class = args.pop if args.last.is_a?(String) args.each do |option_name| hash = send "#{option_name}_option".to_sym , section all.merge!(hash) { |key, one, two| one.to_s + " " + two.to_s } end all[:class] = all[:class] + " #{extra_class}" all end |
#order_option(section, clazz = "") ⇒ Object
39 40 41 42 43 44 |
# File 'app/helpers/breeze/options_helper.rb', line 39 def order_option(section , clazz = "") if section.has_option?("order") clazz += " order-last" if section.option('order') == "right" end {class: clazz} end |
#prose_option(section) ⇒ Object
adds prose irrespective of options
35 36 37 |
# File 'app/helpers/breeze/options_helper.rb', line 35 def prose_option(section) prose_classes end |
#shade_option(section, clazz = "") ⇒ Object
89 90 91 92 93 94 |
# File 'app/helpers/breeze/options_helper.rb', line 89 def shade_option(section , clazz = "") if section.has_option?("shade_color") clazz += " " + (Breeze.shade_color[section.option("shade_color")] || "") end {class: clazz } end |
#slider_columns_option(section, clazz = "") ⇒ Object
103 104 105 106 107 108 109 |
# File 'app/helpers/breeze/options_helper.rb', line 103 def ( section , clazz = "") if section.has_option?("slider_columns") Breeze.[section.option("slider_columns")] else Breeze.["1"] end end |
#text_align_option(section, clazz = "") ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/helpers/breeze/options_helper.rb', line 46 def text_align_option(section , clazz = "") if section.has_option?("text_align") # text-center , text-left , text-right , leave comment for tailwind clazz += " text-#{section.option('text_align')}" end {class: clazz} end |
#text_color_option(section, clazz = "") ⇒ Object
82 83 84 85 86 87 |
# File 'app/helpers/breeze/options_helper.rb', line 82 def text_color_option(section , clazz = "") if section.has_option?("text_color") clazz += " " + (Breeze.text_color[section.option("text_color")] || "") end {class: clazz } end |
#text_columns_option(section, clazz = "") ⇒ Object
96 97 98 99 100 101 |
# File 'app/helpers/breeze/options_helper.rb', line 96 def text_columns_option( section , clazz = "") if section.has_option?("text_columns") clazz += " " + (Breeze.text_columns[section.option("text_columns")] || "") end {class: clazz } end |