intl_phone_picker 0.0.5 → 0.0.6

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: 8f12dd6f8dc5d7096db917eee13b558c8deae683
4
- data.tar.gz: b4e7bec365d021a2d899fe390ca85137c76abd4c
3
+ metadata.gz: a6cdf4b24d7a2c8b32a80baf8bbf63b6f2988f09
4
+ data.tar.gz: 9276206796e12a52919c7cf1705489d01a1220c9
5
5
  SHA512:
6
- metadata.gz: 77c80d6defbd1167cd8e12ef90ba8aced39a58c77ab5e4f60e9df53c3d90009b3bfdcc8c5020d5f3a28e226cb2b075b673301ec09e1df11cc3be69f3c38623e4
7
- data.tar.gz: 8a6e7e75f2f5d6c121fdc256d9005ca2e572db644a35a6f93d2ec95de7d4f89c17d797fba1a5f8a51c3ca07cf5c154c5d71d8f5c1fc6c23a9b4407fdbe9384ec
6
+ metadata.gz: 7e26682c4c9977cebe4b12c44b611be367d51ca4418c0f385ac2ff7cf87be541e1ac28db68ddea2e200343418e54fcef6fc96bf29e8a71e41334fa852d98ed70
7
+ data.tar.gz: 94eab92d7a98a759807792e7b2d29e6404aa53ff446066401a1b66bb08309403607b25f109782011b57f09cce81f372403434d267d75e93eb8bef5000bf8f0d2
data/CHANGELOG.md CHANGED
@@ -27,3 +27,8 @@
27
27
 
28
28
  - Add Activerecord Helpers : 'intl_phone_input_fr' and 'intl_phone_input_us'
29
29
  - Change name of view methods to 'intl_phone_tag_fr' and 'intl_phone_tag_us'
30
+
31
+ # Version 0.0.6
32
+
33
+ - Select number picker country by locale of main application
34
+ - Only 2 helpers : 'intl_phone_tag' and 'intl_phone_input'
data/README.md CHANGED
@@ -7,7 +7,7 @@ IntlPhonePicker is a ruby gem which allow you to change your html5 "tel" fields
7
7
  Feel free to contribute and add your own config translation files through pull requests !
8
8
  If you want to add a tranlation file, just put it into config/locales ! Or if you can't just send us by email, we will do it for you.
9
9
 
10
- Currently supported languages : US, FR.
10
+ Currently supported languages : US (default), FR. The gem takes the language of the locale from your project.
11
11
 
12
12
  ## Sources
13
13
 
@@ -54,17 +54,17 @@ To use javascript and stylesheet libraries you need to add :
54
54
 
55
55
  - To call intlTelInput input :
56
56
  ```ruby
57
- <%= intl_phone_[lang_shortname]_tag([your_specific_name]) %>
57
+ <%= intl_phone_tag([your_specific_name]) %>
58
58
  ```
59
59
 
60
60
  - Example :
61
61
  ```ruby
62
- <%= intl_phone_tag_fr('test') %> # For french
62
+ <%= intl_phone_tag('test') %> # For french
63
63
  ```
64
64
 
65
- - To use with a model (Activerecord), use (choose your language):
65
+ - To use with a model (Activerecord) :
66
66
  ```ruby
67
- <%= f.intl_phone_input_fr(:phone)%>
67
+ <%= f.intl_phone_input(:phone)%>
68
68
  ```
69
69
 
70
70
  ## Development
@@ -5,7 +5,7 @@ require 'intl_phone_picker/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "intl_phone_picker"
8
- spec.version = "0.0.5"
8
+ spec.version = "0.0.6"
9
9
  spec.authors = ["Fabien Dobat\n\n"]
10
10
  spec.email = ["fabien.dobat@seniormedia.fr"]
11
11
 
@@ -1,11 +1,15 @@
1
1
  class IntlPhonePickerBuilder < ::ActionView::Helpers::FormBuilder
2
2
 
3
- def intl_phone_input_fr(object_name, options = {})
4
- telephone_field(object_name, options.merge(:class => 'intl_phone_input_fr'))
3
+ def self.available_languages
4
+ ['us', 'fr']
5
5
  end
6
6
 
7
- def intl_phone_input_us(object_name, options = {})
8
- telephone_field(object_name, options.merge(:class => 'intl_phone_input_us'))
7
+ def intl_phone_input(object_name, options = {})
8
+ if (I18n.locale && I18n.locale.to_s.in?(IntlPhonePickerBuilder.available_languages))
9
+ telephone_field(object_name, options.merge(:class => 'intl_phone_input_' + I18n.locale.to_s))
10
+ else
11
+ telephone_field(object_name, options.merge(:class => 'intl_phone_input_us'))
12
+ end
9
13
  end
10
14
 
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module IntlPhonePicker
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,16 +1,14 @@
1
1
  module IntlPhonePicker
2
2
  module ViewHelpers
3
3
 
4
- def intl_phone_tag_fr(name, value = nil, options = {})
5
- # options[:class] ||= String.new
6
- # options[:class] += ' intl_phone_input_fr'
7
- telephone_field_tag(name, value, options.merge(:class => 'intl_phone_input_fr'))
8
- end
4
+ def intl_phone_tag(name, value = nil, options = {})
5
+ available_languages = ['us', 'fr']
9
6
 
10
- def intl_phone_tag_us(name, value = nil, options = {})
11
- # options[:class] ||= String.new
12
- # options[:class] += ' intl_phone_input_us'
13
- telephone_field_tag(name, value, options.merge(:class => 'intl_phone_input_fr'))
7
+ if (I18n.locale && I18n.locale.to_s.in?(available_languages))
8
+ telephone_field_tag(name, value, options.merge(:class => 'intl_phone_input_' + I18n.locale.to_s))
9
+ else
10
+ telephone_field_tag(name, value, options.merge(:class => 'intl_phone_input_us'))
11
+ end
14
12
  end
15
13
 
16
14
  end
@@ -13,15 +13,15 @@ jQuery(document).ready(function($) {
13
13
  });
14
14
  }
15
15
 
16
-
17
16
  $(".intl_phone_input_fr").intlTelInput({
18
17
  defaultCountry: "fr",
19
18
  preferredCountries: ['fr', 'be', 'ch', 'lu', 'ca', 'mc'],
19
+ nationalMode: true
20
20
  });
21
21
 
22
22
  $(".intl_phone_input_us").intlTelInput({
23
- defaultCountry: "us"
24
- });
25
-
23
+ defaultCountry: "us",
24
+ nationalMode: true
25
+ });
26
26
 
27
27
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intl_phone_picker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - |+
@@ -86,7 +86,6 @@ files:
86
86
  - bin/setup
87
87
  - config/locales/fr.yml
88
88
  - config/locales/us.yml
89
- - config/settings.yml
90
89
  - intl_phone_picker.gemspec
91
90
  - lib/intl_phone_picker.rb
92
91
  - lib/intl_phone_picker/activerecord_helpers.rb
data/config/settings.yml DELETED
File without changes