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 +4 -4
- data/README.md +7 -0
- data/lib/country_state_select.rb +9 -5
- data/lib/country_state_select/version.rb +1 -1
- data/test/dummy/Gemfile +1 -1
- data/test/dummy/config/database.yml +10 -20
- data/vendor/assets/javascript/country_state_select.js.erb +8 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 361ffc00f971f4e6739ba653ec7ab36800aaef54
|
4
|
+
data.tar.gz: 3b0ad3d7908b8d973d40a975e84b186d78810eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
...
|
data/lib/country_state_select.rb
CHANGED
@@ -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 =
|
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 =
|
60
|
-
|
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
|
|
data/test/dummy/Gemfile
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
7
|
+
host: localhost
|
8
|
+
username: compass
|
9
|
+
password: test123
|
20
10
|
|
21
11
|
production:
|
22
|
-
adapter:
|
23
|
-
|
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
|
-
|
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.
|
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:
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|