state_select_plugin 0.1.1
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.
- data/MIT-LICENSE +20 -0
- data/README.md +46 -0
- data/doc/classes/ActionView.html +107 -0
- data/doc/classes/ActionView/Helpers.html +109 -0
- data/doc/classes/ActionView/Helpers/FormBuilder.html +146 -0
- data/doc/classes/ActionView/Helpers/FormBuilder.src/M000003.html +18 -0
- data/doc/classes/ActionView/Helpers/FormOptionsHelper.html +229 -0
- data/doc/classes/ActionView/Helpers/FormOptionsHelper.src/M000001.html +18 -0
- data/doc/classes/ActionView/Helpers/FormOptionsHelper.src/M000002.html +22 -0
- data/doc/classes/ActionView/Helpers/InstanceTag.html +150 -0
- data/doc/classes/ActionView/Helpers/InstanceTag.src/M000004.html +21 -0
- data/doc/created.rid +1 -0
- data/doc/dot/f_0.dot +14 -0
- data/doc/files/init_rb.html +114 -0
- data/doc/files/install_rb.html +107 -0
- data/doc/files/lib/state_select_rb.html +101 -0
- data/doc/files/test/state_select_test_rb.html +119 -0
- data/doc/fr_class_index.html +31 -0
- data/doc/fr_file_index.html +30 -0
- data/doc/fr_method_index.html +30 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/state_select.rb +163 -0
- data/lib/state_select_plugin.rb +163 -0
- data/state_select.gemspec +31 -0
- data/test/state_select_test.rb +8 -0
- metadata +100 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Files
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Files</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Files</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
<a href="files/init_rb.html">init.rb</a><br />
|
24
|
+
<a href="files/install_rb.html">install.rb</a><br />
|
25
|
+
<a href="files/lib/state_select_rb.html">lib/state_select.rb</a><br />
|
26
|
+
<a href="files/test/state_select_test_rb.html">test/state_select_test.rb</a><br />
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Methods
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Methods</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Methods</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
<a href="classes/ActionView/Helpers/FormOptionsHelper.html#M000002">state_options_for_select (ActionView::Helpers::FormOptionsHelper)</a><br />
|
24
|
+
<a href="classes/ActionView/Helpers/FormOptionsHelper.html#M000001">state_select (ActionView::Helpers::FormOptionsHelper)</a><br />
|
25
|
+
<a href="classes/ActionView/Helpers/FormBuilder.html#M000003">state_select (ActionView::Helpers::FormBuilder)</a><br />
|
26
|
+
<a href="classes/ActionView/Helpers/InstanceTag.html#M000004">to_state_select_tag (ActionView::Helpers::InstanceTag)</a><br />
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
5
|
+
|
6
|
+
<!--
|
7
|
+
|
8
|
+
RDoc Documentation
|
9
|
+
|
10
|
+
-->
|
11
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
|
+
<head>
|
13
|
+
<title>RDoc Documentation</title>
|
14
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
|
+
</head>
|
16
|
+
<frameset rows="20%, 80%">
|
17
|
+
<frameset cols="25%,35%,45%">
|
18
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
19
|
+
<frame src="fr_class_index.html" name="Classes" />
|
20
|
+
<frame src="fr_method_index.html" name="Methods" />
|
21
|
+
</frameset>
|
22
|
+
<frame src="files/init_rb.html" name="docwin" />
|
23
|
+
</frameset>
|
24
|
+
</html>
|
data/doc/rdoc-style.css
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
data/lib/state_select.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActionView::Helpers::FormOptionsHelper
|
4
|
+
|
5
|
+
# Return select and option tags for the given object and method, using state_options_for_select to generate the list of option tags.
|
6
|
+
def state_select(object, method, country='US', options = {}, html_options = {})
|
7
|
+
ActionView::Helpers::InstanceTag.new(object, method, self, options.delete(:object)).to_state_select_tag(country, options, html_options)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns a string of option tags for states in a country. Supply a state name as +selected+ to
|
11
|
+
# have it marked as the selected option tag.
|
12
|
+
#
|
13
|
+
# NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
|
14
|
+
|
15
|
+
def state_options_for_select(selected = nil, country = 'US')
|
16
|
+
state_options = "".html_safe
|
17
|
+
if country
|
18
|
+
state_options += options_for_select(eval(country.upcase+'_STATES'), selected)
|
19
|
+
end
|
20
|
+
return state_options
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
US_STATES = [
|
26
|
+
"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado",
|
27
|
+
"Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho",
|
28
|
+
"Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana",
|
29
|
+
"Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota",
|
30
|
+
"Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
|
31
|
+
"New Hampshire", "New Jersey", "New Mexico", "New York",
|
32
|
+
"North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon",
|
33
|
+
"Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina",
|
34
|
+
"South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia",
|
35
|
+
"Washington", "Washington D.C.", "West Virginia", "Wisconsin", "Wyoming"
|
36
|
+
] unless const_defined?("US_STATES")
|
37
|
+
|
38
|
+
UK_STATES = [
|
39
|
+
"Avon", "Bedfordshire", "Berkshire", "Borders", "Buckinghamshire",
|
40
|
+
"Cambridgeshire", "Central", "Cheshire", "Cleveland", "Clwyd",
|
41
|
+
"Cornwall", "County Antrim", "County Armagh", "County Down",
|
42
|
+
"County Fermanagh", "County Londonderry", "County Tyrone", "Cumbria",
|
43
|
+
"Derbyshire", "Devon", "Dorset", "Dumfries and Galloway", "Durham",
|
44
|
+
"Dyfed", "East Sussex", "Essex", "Fife", "Gloucestershire", "Grampian",
|
45
|
+
"Greater Manchester", "Gwent", "Gwynedd County", "Hampshire",
|
46
|
+
"Herefordshire", "Hertfordshire", "Highlands and Islands",
|
47
|
+
"Humberside", "Isle of Wight", "Kent", "Lancashire", "Leicestershire",
|
48
|
+
"Lincolnshire", "Lothian", "Merseyside", "Mid Glamorgan", "Norfolk",
|
49
|
+
"North Yorkshire", "Northamptonshire", "Northumberland",
|
50
|
+
"Nottinghamshire", "Oxfordshire", "Powys", "Rutland", "Shropshire",
|
51
|
+
"Somerset", "South Glamorgan", "South Yorkshire", "Staffordshire",
|
52
|
+
"Strathclyde", "Suffolk", "Surrey", "Tayside", "Tyne and Wear",
|
53
|
+
"Warwickshire", "West Glamorgan", "West Midlands", "West Sussex",
|
54
|
+
"West Yorkshire", "Wiltshire", "Worcestershire"
|
55
|
+
] unless const_defined?("UK_STATES")
|
56
|
+
|
57
|
+
INDIA_STATES = [
|
58
|
+
"Andhra Pradesh", "Arunachal Pradesh", "Assam", "Bihar",
|
59
|
+
"Chhattisgarh", "New Delhi", "Goa", "Gujarat", "Haryana",
|
60
|
+
"Himachal Pradesh", "Jammu and Kashmir", "Jharkhand", "Karnataka",
|
61
|
+
"Kerala", "Madhya Pradesh", "Maharashtra", "Manipur", "Meghalaya",
|
62
|
+
"Mizoram", "Nagaland", "Orissa", "Punjab", "Rajasthan", "Sikkim",
|
63
|
+
"Tamil Nadu", "Tripura", "Uttaranchal", "Uttar Pradesh", "West Bengal"
|
64
|
+
] unless const_defined?("INDIA_STATES")
|
65
|
+
|
66
|
+
CANADA_STATES = [
|
67
|
+
"Alberta", "British Columbia", "Manitoba", "New Brunswick",
|
68
|
+
"Newfoundland", "Northwest Territories", "Nova Scotia", "Nunavut",
|
69
|
+
"Ontario", "Prince Edward Island", "Quebec", "Saskatchewan", "Yukon"
|
70
|
+
] unless const_defined?("CANADA_STATES")
|
71
|
+
|
72
|
+
AUSTRALIA_STATES = [
|
73
|
+
"Australian Capital Territory", "New South Wales", "Northern Territory",
|
74
|
+
"Queensland", "South Australia", "Tasmania", "Victoria",
|
75
|
+
"Western Australia"
|
76
|
+
] unless const_defined?("AUSTRALIA_STATES")
|
77
|
+
|
78
|
+
SPAIN_STATES = [
|
79
|
+
"Alava", "Albacete", "Alicante", "Almeria", "Asturias", "Avila",
|
80
|
+
"Badajoz", "Barcelona", "Burgos", "Caceres", "Cadiz", "Cantrabria",
|
81
|
+
"Castellon", "Ceuta", "Ciudad Real", "Cordoba", "Cuenca", "Girona",
|
82
|
+
"Granada", "Guadalajara", "Guipuzcoa", "Huelva", "Huesca",
|
83
|
+
"Islas Baleares", "Jaen", "La Coruna", "Leon", "Lleida", "Lugo",
|
84
|
+
"Madrid", "Malaga", "Melilla", "Murcia", "Navarra", "Ourense",
|
85
|
+
"Palencia", "Palmas, Las", "Pontevedra", "Rioja, La", "Salamanda",
|
86
|
+
"Santa Cruz de Tenerife", "Segovia", "Sevila", "Soria", "Tarragona",
|
87
|
+
"Teruel", "Toledo", "Valencia", "Valladolid", "Vizcaya", "Zamora",
|
88
|
+
"Zaragoza"
|
89
|
+
] unless const_defined?("SPAIN_STATES")
|
90
|
+
|
91
|
+
UGANDA_STATES = [
|
92
|
+
"Abim", "Adjumani", "Amolatar", "Amuria", "Apac", "Arua", "Budaka",
|
93
|
+
"Bugiri", "Bukwa", "Bulisa", "Bundibugyo", "Bushenyi", "Busia", "Busiki",
|
94
|
+
"Butaleja", "Dokolo", "Gulu", "Hoima", "Ibanda", "Iganga", "Jinja",
|
95
|
+
"Kaabong", "Kabale", "Kabarole", "Kaberamaido", "Kabingo", "Kalangala",
|
96
|
+
"Kaliro", "Kampala", "Kamuli", "Kamwenge", "Kanungu", "Kapchorwa",
|
97
|
+
"Kasese", "Katakwi", "Kayunga", "Kibale", "Kiboga", "Kilak", "Kiruhura",
|
98
|
+
"Kisoro", "Kitgum", "Koboko", "Kotido", "Kumi", "Kyenjojo", "Lira",
|
99
|
+
"Luwero", "Manafwa", "Maracha", "Masaka", "Masindi", "Mayuge", "Mbale",
|
100
|
+
"Mbarara", "Mityana", "Moroto", "Moyo", "Mpigi", "Mubende", "Mukono",
|
101
|
+
"Nakapiripirit", "Nakaseke", "Nakasongola", "Nebbi", "Ntungamo", "Oyam",
|
102
|
+
"Pader", "Pallisa", "Rakai", "Rukungiri", "Sembabule", "Sironko",
|
103
|
+
"Soroti", "Tororo", "Wakiso", "Yumbe"
|
104
|
+
] unless const_defined?("UGANDA_STATES")
|
105
|
+
|
106
|
+
FRANCE_STATES = [
|
107
|
+
"Alsace", "Aquitaine", "Auvergne", "Bourgogne", "Bretagne", "Centre",
|
108
|
+
"Champagne-Ardenne", "Corse", "Franche-Comte", "Ile-de-France",
|
109
|
+
"Languedoc-Roussillon", "Limousin", "Lorraine", "Midi-Pyrenees",
|
110
|
+
"Nord-Pas-de-Calais", "Basse-Normandie", "Haute-Normandie",
|
111
|
+
"Pays de la Loire", "Picardie", "Poitou-Charentes",
|
112
|
+
"Provence-Alpes-Cote d'Azur", "Rhone-Alpes"
|
113
|
+
] unless const_defined?("FRANCE_STATES")
|
114
|
+
|
115
|
+
GERMANY_STATES = [
|
116
|
+
"Baden-Wurttemberg", "Bayern", "Berlin", "Brandenburg", "Bremen",
|
117
|
+
"Hamburg", "Hessen", "Mecklenburg-Vorpommern", "Niedersachsen",
|
118
|
+
"Nordrhein-Westfalen", "Rhineland-Pflaz", "Saarland", "Sachsen",
|
119
|
+
"Sachsen-Anhalt", "Schleswig-Holstein", "Thuringen"
|
120
|
+
] unless const_defined?("GERMANY_STATES")
|
121
|
+
|
122
|
+
NETHERLANDS_STATES = [
|
123
|
+
"Drenthe", "Flevoland", "Friesland", "Gelderland", "Groningen",
|
124
|
+
"Limburg", "Noord-Brabant", "Noord-Holland", "Overijssel", "Utrecht",
|
125
|
+
"Zeeland", "Zuid-Holland"
|
126
|
+
] unless const_defined?("NETHERLANDS_STATES")
|
127
|
+
|
128
|
+
MEXICO_STATES = [
|
129
|
+
"Aguascalientes", "Baja Californi", "Baja California Sur",
|
130
|
+
"Campeche", "Chiapas", "Chihuahua", "Coahuila", "Colima", "Durango",
|
131
|
+
"Guanajuato", "Guerrero", "Hidalgo", "Jalisco", "México", "Michoacán",
|
132
|
+
"Morelos", "Nayarit", "Nuevo León", "Oaxaca", "Puebla", "Querétaro",
|
133
|
+
"Quintana Roo", "San Luis Potosí", "Sinaloa", "Sonora", "Tabasco",
|
134
|
+
"Tamaulipas", "Tlaxcala", "Veracruz", "Yucatán", "Zacatecas"
|
135
|
+
] unless const_defined?("MEXICO_STATES")
|
136
|
+
|
137
|
+
POLAND_STATES = [
|
138
|
+
"dolnośląskie", "kujawsko-pomorskie", "lubelskie", "lubuskie", "łódzkie",
|
139
|
+
"małopolskie", "mazowieckie", "opolskie", "podkarpackie", "podlaskie",
|
140
|
+
"pomorskie", "śląskie", "świętokrzyskie", "warmińsko-mazurskie",
|
141
|
+
"wielkopolskie", "zachodniopomorskie"
|
142
|
+
] unless const_defined?("POLAND_STATES")
|
143
|
+
end
|
144
|
+
|
145
|
+
class ActionView::Helpers::InstanceTag
|
146
|
+
|
147
|
+
|
148
|
+
def to_state_select_tag(country, options, html_options)
|
149
|
+
html_options = html_options.stringify_keys
|
150
|
+
add_default_name_and_id(html_options)
|
151
|
+
value = value(object)
|
152
|
+
selected_value = options.has_key?(:selected) ? options[:selected] : value
|
153
|
+
content_tag("select", add_options(state_options_for_select(selected_value, country), options, value), html_options)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
class ActionView::Helpers::FormBuilder
|
159
|
+
def state_select(method, country = 'US', options = {}, html_options = {})
|
160
|
+
@template.state_select(@object_name, method, country, options.merge(:object => @object), html_options)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|