country_state_select 3.0.1 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc1e45ac3197072daa429452d164001f6e29ae40
4
- data.tar.gz: 4faff126bd82fd8a8a4f15305dfdaff2ba8921ec
3
+ metadata.gz: 361ffc00f971f4e6739ba653ec7ab36800aaef54
4
+ data.tar.gz: 3b0ad3d7908b8d973d40a975e84b186d78810eb6
5
5
  SHA512:
6
- metadata.gz: 72674f4b8ca1ba0becb2a7df2b4db2e48415ffaa89e815145de07c498a4d5d24977580c9ea64a6c3d427e6b2336ff9ebfd3c03cf986dad0f867587b54e05ce3b
7
- data.tar.gz: c9ccee4383931e5d2e8cca3845afb36d0db02c7a2b198d3b3c71dd83eea2d171d6bf17ee18dde8f78f012f23a5f00854b1cc939740afb8c910a5c7168b1643c9
6
+ metadata.gz: 7336813ead81567b3eef7963080f037e1a9859cd1e80ec2c8b61dbeb85265a3f3e39b05f75228990281f3aacdc339584685461192b61792c40495ddb4c998f21
7
+ data.tar.gz: 747c28f7f2a11763eb73950aec6404c6d33d496a42a6ab555f055d080fd1a51bfbe11d4a7ff36a31fb755fae5e91c13f62b0afc7faf1cd6c98392f8e057a9f08
data/README.md CHANGED
@@ -8,6 +8,9 @@ For instance, if a user chooses "United States of America" for a Country dropdow
8
8
 
9
9
  The data for Countries and States is populated by the excellent [city-state](https://github.com/loureirorg/city-state) gem.
10
10
 
11
+ #Demo Of the Gem
12
+ https://country-state-select.herokuapp.com
13
+
11
14
  #Getting Started
12
15
 
13
16
  Country State Select is released as a Ruby Gem and requires the Rails environment as well.
@@ -116,6 +119,10 @@ To turn it on, set it to true:
116
119
  $(document).on('ready page:load', function() {
117
120
  return CountryStateSelect({
118
121
  chosen_ui: true,
122
+ chosen_options: {
123
+ disable_search_threshold: 10,
124
+ width: '95%'
125
+ },
119
126
  ...
120
127
  ...
121
128
  ...
@@ -49,15 +49,19 @@ module CountryStateSelect
49
49
  #Return a hash for use in the simple_form
50
50
  def self.state_options(options)
51
51
  states = states_collection(options[:form], options[:field_names])
52
- options = options.merge(collection: states)
53
- options = options.merge(:as => :string) if states.class == String
54
- options
52
+ options = self.merge_hash(options, states)
55
53
  end
56
54
 
55
+ #Return a hash for use in the simple_form
57
56
  def self.city_options(options)
58
57
  cities = cities_collection(options[:form], options[:field_names])
59
- options = options.merge(collection: cities)
60
- options = options.merge(:as => :string) if cities.class == String
58
+ options = self.merge_hash(options, cities)
59
+ end
60
+
61
+ # Create hash to use in the simple_form
62
+ def self.merge_hash(options, collections)
63
+ options = options.merge(collection: collections)
64
+ options = options.merge(:as => :string) if collections.class == String
61
65
  options
62
66
  end
63
67
 
@@ -1,3 +1,3 @@
1
1
  module CountryStateSelect
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
@@ -28,7 +28,7 @@ group :test do
28
28
  end
29
29
 
30
30
  gem "rails", "~> 4.2"
31
- gem "sqlite3"
31
+ gem "pg"
32
32
  gem "sass-rails", "~> 5.0"
33
33
  gem "uglifier", "~> 2.7"
34
34
  gem "coffee-rails", "~> 4.1"
@@ -1,25 +1,15 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
1
 
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
2
+ development:
3
+ adapter: postgresql
4
+ encoding: unicode
5
+ database: cy_development_one
18
6
  pool: 5
19
- timeout: 5000
7
+ host: localhost
8
+ username: compass
9
+ password: test123
20
10
 
21
11
  production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
12
+ adapter: postgresql
13
+ encoding: unicode
14
+ database: cy_production
24
15
  pool: 5
25
- timeout: 5000
@@ -33,15 +33,14 @@ function CountryStateSelect(options) {
33
33
  }
34
34
 
35
35
  function addChosenToState(){
36
- if (chosenIsRequired && stateIsNotText()) {
37
- $('#' + state_id).chosen();
36
+ if (chosenIsRequired() && stateIsNotText()) {
37
+ $('#' + state_id).chosen(options['chosen_options']);
38
38
  }
39
39
  }
40
40
 
41
41
  function addChosenToCity(){
42
-
43
- if (chosenIsRequired && cityIsNotText()) {
44
- $('#' + city_id).chosen();
42
+ if (chosenIsRequired() && cityIsNotText()) {
43
+ $('#' + city_id).chosen(options['chosen_options']);
45
44
  }
46
45
  }
47
46
 
@@ -54,20 +53,20 @@ function CountryStateSelect(options) {
54
53
  }
55
54
 
56
55
  function addChosenToCountry(){
57
- if (chosenIsRequired) {
58
- $('#' + country_id).chosen();
56
+ if (chosenIsRequired()) {
57
+ $('#' + country_id).chosen(options['chosen_options']);
59
58
  }
60
59
  }
61
60
 
62
61
  function removeChosenFromFields(){
63
- if (chosenIsRequired) {
62
+ if (chosenIsRequired()) {
64
63
  $("#" + options['state_id'] + "_chosen").remove();
65
64
  $("#" + options['city_id'] + "_chosen").remove();
66
65
  }
67
66
  }
68
67
 
69
68
  function removeChosenFromCityFields(){
70
- if (chosenIsRequired) {
69
+ if (chosenIsRequired()) {
71
70
  $("#" + options['city_id'] + "_chosen").remove();
72
71
  }
73
72
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: country_state_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvind Vyas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler