Class: Effective::FormBuilderInputs::EffectiveTel
Constant Summary
collapse
- DEFAULT_TEL_MASK =
'(999) 999-9999? x99999'
- DEFAULT_CELL_MASK =
'(999) 999-9999'
Instance Method Summary
collapse
#field_name, #html_options, #initialize, #options, #value
Instance Method Details
#cellphone? ⇒ Boolean
38
39
40
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 38
def cellphone?
field_name.include?('cell') || options[:cellphone]
end
|
13
14
15
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 13
def default_input_html
{class: 'effective_tel tel', placeholder: '(555) 555-5555'}
end
|
17
18
19
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 17
def default_input_js
{mask: DEFAULT_TEL_MASK, placeholder: '_'}
end
|
#default_options ⇒ Object
9
10
11
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 9
def default_options
{cellphone: false, fax: false}
end
|
#fax? ⇒ Boolean
34
35
36
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 34
def fax?
field_name.include?('fax') || options[:fax]
end
|
#glyphicon ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 42
def glyphicon
icon = 'earphone'
icon = 'phone' if field_name.include?('cell')
icon = 'phone-alt' if field_name.include?('fax')
icon = 'phone' if options[:cellphone]
icon = 'phone-alt' if options[:fax]
icon
end
|
#js_options ⇒ Object
54
55
56
57
58
59
60
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 54
def js_options
super.tap do |js_options|
if (fax? || cellphone?) && js_options[:mask] == DEFAULT_TEL_MASK
js_options[:mask] = DEFAULT_CELL_MASK
end
end
end
|
#to_html ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/models/effective/form_builder_inputs/effective_tel.rb', line 21
def to_html
if options[:input_group] == false
return telephone_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-#{glyphicon}").html_safe
end +
telephone_field_tag(field_name, value, tag_options)
end
end
|