3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/formtastic/globalize_inputs.rb', line 3
def globalize_inputs(*args, &proc)
index = options[:child_index] || "#{self.object.class.to_s}-#{self.object.object_id}"
linker = ActiveSupport::SafeBuffer.new
fields = ActiveSupport::SafeBuffer.new
::I18n.available_locales.each do |locale|
linker << self.template.content_tag(:li,
self.template.content_tag(:a,
::I18n.t("translation.#{locale}"),
:href => "#lang-#{locale}-#{index}"
)
)
fields << self.template.content_tag(:div,
self.semantic_fields_for(*(args.dup << self.object.translation_for(locale)), &proc),
:id => "lang-#{locale}-#{index}"
)
end
linker = self.template.content_tag(:ul, linker, :class => "language-selection")
self.template.content_tag(:div, linker + fields, :class => "language-tabs-#{index}") + self.template.content_tag(:script, "$('.language-tabs-#{index}').tabs();", :type => "text/javascript")
end
|