Class: Inputs::EffectiveUrl::Input
Constant Summary
collapse
- FA_FIELD_NAMES =
['facebook', 'google', 'linkedin', 'twitter', 'vimeo', 'youtube']
Instance Method Summary
collapse
#field_name, #html_options, #initialize, #js_options, #options, #value
Instance Method Details
8
9
10
11
12
13
14
15
|
# File 'app/models/inputs/effective_url/input.rb', line 8
def default_input_html
{
class: 'effective_url url',
pattern: 'https?://[A-Za-z0-9]+.+',
placeholder: placeholder,
title: 'A URL starting with http:// or https://'
}
end
|
#fontawesome ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/models/inputs/effective_url/input.rb', line 62
def fontawesome
if options[:fontawesome] == false
''.html_safe
elsif options[:fontawesome].present? && options[:fontawesome] != true
content_tag(:i, '', class: "fa fa-#{options[:fontawesome].to_s.gsub('fa-', '')}")
elsif field_name.include?('facebook')
content_tag(:i, '', class: 'fa fa-facebook')
elsif field_name.include?('google')
content_tag(:i, '', class: 'fa fa-google')
elsif field_name.include?('linkedin')
content_tag(:i, '', class: 'fa fa-linkedin')
elsif field_name.include?('twitter')
content_tag(:i, '', class: 'fa fa-twitter')
elsif field_name.include?('vimeo')
content_tag(:i, '', class: 'fa fa-vimeo')
elsif field_name.include?('youtube')
content_tag(:i, '', class: 'fa fa-youtube')
else
''.html_safe
end
end
|
#glyphicon ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/models/inputs/effective_url/input.rb', line 48
def glyphicon
if options[:glyphicon] == false
''.html_safe
elsif options[:glyphicon] == true
content_tag(:i, '', class: 'glyphicon glyphicon-globe')
elsif options[:glyphicon].present?
content_tag(:i, '', class: "glyphicon glyphicon-#{options[:glyphicon].to_s.gsub('glyphicon-', '')}")
elsif defined?(FontAwesome) && FA_FIELD_NAMES.any? { |name| field_name.include?(name) } && options[:fontawesome] != false
''.html_safe
else
content_tag(:i, '', class: 'glyphicon glyphicon-globe')
end
end
|
#placeholder ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/models/inputs/effective_url/input.rb', line 30
def placeholder
if field_name.include?('facebook')
'https://www.facebook.com/MyProfile'
elsif field_name.include?('google')
'https://plus.google.com/+MyProfile'
elsif field_name.include?('linkedin')
'https://www.linkedin.com/in/MyProfile'
elsif field_name.include?('twitter')
'https://twitter.com/MyProfile'
elsif field_name.include?('vimeo')
'https://vimeo.com/MyProfile'
elsif field_name.include?('youtube')
'https://www.youtube.com/user/MyProfile'
else
'http://www.example.com'
end
end
|
#to_html ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/models/inputs/effective_url/input.rb', line 17
def to_html
if options[:input_group] == false
return url_field_tag(field_name, value, tag_options)
end
content_tag(:div, class: 'input-group') do
content_tag(:span, class: 'input-group-addon') do
glyphicon + fontawesome
end +
url_field_tag(field_name, value, tag_options)
end
end
|