Class: Locomotive::LocalesInput
- Inherits:
-
Formtastic::Inputs::CheckBoxesInput
- Object
- Formtastic::Inputs::CheckBoxesInput
- Locomotive::LocalesInput
- Defined in:
- app/inputs/locomotive/locales_input.rb
Instance Method Summary collapse
- #choice_html(choice) ⇒ Object
- #choice_label(choice) ⇒ Object
- #choice_wrapping(html_options, &block) ⇒ Object
- #choice_wrapping_html_options(choice) ⇒ Object
- #choices_group_wrapping(&block) ⇒ Object
- #choices_group_wrapping_html_options ⇒ Object
- #hidden_fields? ⇒ Boolean
- #to_html ⇒ Object
Instance Method Details
#choice_html(choice) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/inputs/locomotive/locales_input.rb', line 32 def choice_html(choice) check_box_without_hidden_input(choice) << template.content_tag(:label, choice_label(choice), .merge(for: choice_input_dom_id(choice), class: nil) ) end |
#choice_label(choice) ⇒ Object
40 41 42 43 |
# File 'app/inputs/locomotive/locales_input.rb', line 40 def choice_label(choice) text = I18n.t("locomotive.locales.#{choice}") template.image_tag("locomotive/icons/flags/#{choice}.png", alt: text, size: '24x24') << text end |
#choice_wrapping(html_options, &block) ⇒ Object
25 26 27 28 29 30 |
# File 'app/inputs/locomotive/locales_input.rb', line 25 def choice_wrapping(, &block) template.content_tag(:div, template.capture(&block), ) end |
#choice_wrapping_html_options(choice) ⇒ Object
49 50 51 52 53 |
# File 'app/inputs/locomotive/locales_input.rb', line 49 def (choice) super.tap do || [:class] = "entry #{checked?(choice) ? 'selected' : ''}" end end |
#choices_group_wrapping(&block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/inputs/locomotive/locales_input.rb', line 17 def choices_group_wrapping(&block) template.content_tag(:div, template.capture(&block) + template.content_tag(:div, '', class: 'clear'), ) end |
#choices_group_wrapping_html_options ⇒ Object
45 46 47 |
# File 'app/inputs/locomotive/locales_input.rb', line 45 def { class: 'list' } end |
#hidden_fields? ⇒ Boolean
55 56 57 |
# File 'app/inputs/locomotive/locales_input.rb', line 55 def hidden_fields? false end |
#to_html ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/inputs/locomotive/locales_input.rb', line 4 def to_html input_wrapping do label_html << choices_group_wrapping do collection.map { |choice| choice_wrapping((choice)) do choice_html(choice) end }.join("\n").html_safe end end end |