Class: Locomotive::LocaleInput
- Inherits:
-
Formtastic::Inputs::TextInput
- Object
- Formtastic::Inputs::TextInput
- Locomotive::LocaleInput
- Includes:
- Formtastic::Inputs::Base::Choices
- Defined in:
- app/inputs/locomotive/locale_input.rb
Instance Method Summary collapse
- #available_locales_to_html ⇒ Object
- #choice_input_dom_id(choice) ⇒ Object
- #locale_to_html(locale) ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#available_locales_to_html ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/inputs/locomotive/locale_input.rb', line 13 def available_locales_to_html template.content_tag(:div, Locomotive.config.locales.map do |locale| template.content_tag(:div, locale_to_html(locale).html_safe, :class => 'entry') end.join.html_safe + template.content_tag(:div, '', :class => 'clear'), :class => 'list') end |
#choice_input_dom_id(choice) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/inputs/locomotive/locale_input.rb', line 30 def choice_input_dom_id(choice) [ builder.custom_namespace, sanitized_object_name, association_primary_key || method, choice_html_safe_value(choice) ].compact.reject { |i| i.blank? }.join("_") end |
#locale_to_html(locale) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/inputs/locomotive/locale_input.rb', line 21 def locale_to_html(locale) text = I18n.t("locomotive.locales.#{locale}") builder.(:locale, locale, :id => choice_input_dom_id(locale)) + template.content_tag(:label, template.image_tag("locomotive/icons/flags/#{locale}.png", :alt => text, :size => '24x24') + text, :for => choice_input_dom_id(locale)) end |
#to_html ⇒ Object
6 7 8 9 10 11 |
# File 'app/inputs/locomotive/locale_input.rb', line 6 def to_html input_wrapping do label_html << self.available_locales_to_html end end |