effective_form_inputs 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e84a838832b598cc3b8261c04f468d304ae5d6ce
4
- data.tar.gz: 9a1ce4d38760e24e0ff95a59db675cc94e98d97b
3
+ metadata.gz: accc0fe7bd2c46e9ef6623d7c68683a77dc1f5f7
4
+ data.tar.gz: 029d82f57a52ec949f525d914fda00476fcc015e
5
5
  SHA512:
6
- metadata.gz: 5e357f9a67eb8ff7d33932117681d9552306db028835ec39fb71641b52ef2fd25431ea27f16582098a9e336c4c60df3b404ccca780c786672200501594b59669
7
- data.tar.gz: 08f29d5e3bf603b181b3696519e7e4d67111598b1324be2592a8740bb0d3a97ebb43db5c9b803999a7dbc5c52fddc40a8abedd458b6b8c53df2b446d3b05514b
6
+ metadata.gz: 269ddf7bd1da80e1daeab5a6f2174b57f87c43c52d55d483dd40bcf894eeeb941358b80d489f035ec8dc38c163530befe630a16cc37b665bf488ceaac700083f
7
+ data.tar.gz: e29783d2fe62b7a9380683fd31478e664f12eb2a0f36699ead1337ae6d1540c2bd10676a577f48781e8d6426083856fdff1c0239b87539f6a385b2ad86a397d5
@@ -16,7 +16,14 @@ module Inputs
16
16
  end
17
17
 
18
18
  def to_html
19
- collection_select(@object_name, @method, options[:collection], options[:label_method], options[:value_method], options, tag_options)
19
+ collection_select(@object_name, @method, collection, options[:value_method], options[:label_method], options, tag_options)
20
+ end
21
+
22
+ def collection
23
+ @collection ||= begin
24
+ collection = options.delete(:collection)
25
+ collection.respond_to?(:call) ? collection.call : collection.to_a
26
+ end
20
27
  end
21
28
 
22
29
  def options
@@ -7,7 +7,7 @@ module Inputs
7
7
  DEFAULT_CELL_MASK = '(999) 999-9999'
8
8
 
9
9
  def default_options
10
- {cellphone: false}
10
+ {cellphone: false, fax: false}
11
11
  end
12
12
 
13
13
  def default_input_html
@@ -25,15 +25,35 @@ module Inputs
25
25
 
26
26
  content_tag(:div, class: 'input-group') do
27
27
  content_tag(:span, class: 'input-group-addon') do
28
- content_tag(:i, '', class: "glyphicon glyphicon-#{options[:cellphone] ? 'phone' : 'earphone'}").html_safe
28
+ content_tag(:i, '', class: "glyphicon glyphicon-#{glyphicon}").html_safe
29
29
  end +
30
30
  text_field_tag(field_name, value, tag_options)
31
31
  end
32
32
  end
33
33
 
34
+ def fax?
35
+ field_name.include?('fax') || options[:fax]
36
+ end
37
+
38
+ def cellphone?
39
+ field_name.include?('cell') || options[:cellphone]
40
+ end
41
+
42
+ def glyphicon
43
+ icon = 'earphone' # default
44
+
45
+ icon = 'phone' if field_name.include?('cell')
46
+ icon = 'phone-alt' if field_name.include?('fax')
47
+
48
+ icon = 'phone' if options[:cellphone]
49
+ icon = 'phone-alt' if options[:fax]
50
+
51
+ icon
52
+ end
53
+
34
54
  def js_options
35
55
  super.tap do |js_options|
36
- if options[:cellphone] == true && js_options[:mask] == DEFAULT_TEL_MASK
56
+ if (fax? || cellphone?) && js_options[:mask] == DEFAULT_TEL_MASK
37
57
  js_options[:mask] = DEFAULT_CELL_MASK
38
58
  end
39
59
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveFormInputs
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_form_inputs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails