Class: Effective::FormBuilderInputs::EffectiveTimePicker
Instance Method Summary
collapse
#field_name, #initialize, #js_options, #options
Instance Method Details
10
11
12
|
# File 'app/models/effective/form_builder_inputs/effective_time_picker.rb', line 10
def default_input_html
{class: 'effective_time_picker time'}
end
|
6
7
8
|
# File 'app/models/effective/form_builder_inputs/effective_time_picker.rb', line 6
def default_input_js
{ format: 'LT', showClear: false, useCurrent: 'hour' }
end
|
#html_options ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/models/effective/form_builder_inputs/effective_time_picker.rb', line 32
def html_options
super.tap do |html_options|
if js_options[:format] == default_input_js[:format] html_options[:pattern] = '\d\d?:\d{2} \D{2}' end
if options[:date_linked] == false
html_options[:class] << 'not-date-linked'
end
end
end
|
#to_html ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/effective/form_builder_inputs/effective_time_picker.rb', line 14
def to_html
if options[:input_group] == false
return text_field_tag(field_name, value, tag_options)
end
content_tag(:div, class: 'input-group') do
content_tag(:span, class: 'input-group-addon') do
content_tag(:i, '', class: 'glyphicon glyphicon-time').html_safe
end +
text_field_tag(field_name, value, tag_options)
end
end
|
#value ⇒ Object
27
28
29
30
|
# File 'app/models/effective/form_builder_inputs/effective_time_picker.rb', line 27
def value
val = super
val.respond_to?(:strftime) ? val.strftime('%H:%M') : val
end
|