Module: FormtasticBootstrap::Inputs::Base::Timeish
- Included in:
- DateSelectInput, DatetimeSelectInput, TimeSelectInput
- Defined in:
- lib/formtastic-bootstrap/inputs/base/timeish.rb
Constant Summary collapse
- FRAGMENT_CLASSES =
{ :year => "col-xs-2", :month => "col-xs-3", :day => "col-xs-1", :hour => "col-xs-offset-3 col-xs-1", :minute => "col-xs-1", :second => "col-xs-1" }
Instance Method Summary collapse
- #fragment_class(fragment) ⇒ Object
- #fragment_html(fragment) ⇒ Object
- #fragment_input_html_options(fragment) ⇒ Object
- #fragment_placeholder(fragment) ⇒ Object
- #row_wrapping(&block) ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#fragment_class(fragment) ⇒ Object
47 48 49 |
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 47 def fragment_class(fragment) [:fragment_classes] || self.class::FRAGMENT_CLASSES[fragment] end |
#fragment_html(fragment) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 32 def fragment_html(fragment) template.content_tag(:div, :class => fragment_class(fragment)) do opts = .merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?) template.send(:"select_#{fragment}", value, opts, (fragment)) end end |
#fragment_input_html_options(fragment) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 39 def (fragment) .tap do || [:id] = fragment_id(fragment) [:class] = (([:class] || "").split << "form-control").join(" ") [:placeholder] = fragment_placeholder(fragment) end end |
#fragment_placeholder(fragment) ⇒ Object
51 52 53 54 |
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 51 def fragment_placeholder(fragment) # TODO This sets a useless placeholer right now. "." + fragment_class(fragment) end |
#row_wrapping(&block) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 25 def row_wrapping(&block) template.content_tag(:div, template.capture(&block).html_safe, :class => 'row' ) end |
#to_html ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 14 def to_html bootstrap_wrapping do hidden_fragments << row_wrapping do fragments.map do |fragment| fragment_html(fragment.to_sym) end.join.html_safe end end end |