intl_phone_picker 0.0.7.1 → 0.0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +45 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +101 -0
- data/Rakefile +9 -0
- data/TODO.md +2 -0
- data/app/assets/images/flags.png +0 -0
- data/app/assets/images/flags@2x.png +0 -0
- data/app/assets/javascripts/intlTelInput.js +1183 -0
- data/app/assets/javascripts/intlTelInputLang.js +43 -0
- data/app/assets/stylesheets/intlTelInput.scss +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/locales/fr.yml +234 -0
- data/config/locales/us.yml +231 -0
- data/intl_phone_picker.gemspec +29 -0
- data/lib/intl_phone_picker/activerecord_helpers.rb +16 -0
- data/lib/intl_phone_picker/railtie.rb +13 -0
- data/lib/intl_phone_picker/version.rb +3 -0
- data/lib/intl_phone_picker/view_helpers.rb +18 -0
- data/lib/intl_phone_picker.rb +18 -0
- data/test/test_helper.rb +4 -0
- data/vendor/assets/javascripts/libphonenumber/utils.js +481 -0
- metadata +27 -2
@@ -0,0 +1,18 @@
|
|
1
|
+
module IntlPhonePicker
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
def intl_phone_tag(name, value = nil, options = {})
|
5
|
+
class_name = 'intl_phone_input_' + IntlPhonePicker::langage_to_use
|
6
|
+
options = IntlPhonePicker::options_keys_to_sym options
|
7
|
+
|
8
|
+
phones_fields = telephone_field_tag(name, value, options.merge(class: class_name).except(:hidden_intl_field))
|
9
|
+
|
10
|
+
# Can call this helper with option 'hidden_intl_field' set to true to toggle an hidden linked field which will store and return
|
11
|
+
# the phone number of the input with an international format, starts with '+33' for example
|
12
|
+
phones_fields << hidden_field_tag(options[:hidden_intl_field], value, {'data-phone-field' => name}) if options[:hidden_intl_field].presence
|
13
|
+
|
14
|
+
phones_fields
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'intl_phone_picker/version'
|
2
|
+
require 'intl_phone_picker/railtie' if defined?(Rails)
|
3
|
+
|
4
|
+
module IntlPhonePicker
|
5
|
+
|
6
|
+
AVAILABLE_LANGAGES = ['us', 'fr']
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def langage_to_use
|
10
|
+
I18n.locale && I18n.locale.to_s.in?(IntlPhonePicker::AVAILABLE_LANGAGES) ? I18n.locale.to_s : 'us'
|
11
|
+
end
|
12
|
+
|
13
|
+
def options_keys_to_sym options
|
14
|
+
ActiveSupport::HashWithIndifferentAccess.new options
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/test/test_helper.rb
ADDED