Module: BootstrapFormExtensions::Timespan

Defined in:
lib/bootstrap_form_extensions/timespan.rb

Constant Summary collapse

UNITS_IN_SECONDS =
ActiveSupport::OrderedHash[ :seconds, 1, :minutes, 60, :hours, 3600, :days, 86400, :weeks, 604800, :months, 18144000 ]
@@units =
UNITS_IN_SECONDS.keys

Instance Method Summary collapse

Instance Method Details

#timespan(method, units: @@units, quantity_options: {}, unit_options: {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/bootstrap_form_extensions/timespan.rb', line 10

def timespan method, units: @@units, quantity_options: {}, unit_options: {}
  quantity, selected, units = quantity_and_units_for_timespan method, units
  hidden = hidden_field method, class: 'timespan-seconds'
  field  = text_field_for_timespan method, quantity, quantity_options
  select = select_for_timespan method, selected, units, unit_options
   :span, hidden + field + ' '.html_safe + select, data: { timespan: true }
end