intl_phone_picker 0.0.7.1 → 0.0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,4 @@
1
+ require 'intl_phone_picker'
2
+ require 'minitest/autorun'
3
+ require 'minitest/unit'
4
+ require 'minitest/pride'