flagstrap 0.0.2 → 0.0.3
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/lib/flagstrap.rb +5 -0
- data/lib/flagstrap/version.rb +1 -1
- metadata +3 -8
- data/vendor/assets/images/flags.png +0 -0
- data/vendor/assets/javascripts/jquery.flagstrap.js +0 -458
- data/vendor/assets/javascripts/jquery.flagstrap.min.js +0 -9
- data/vendor/assets/stylesheets/flags.css +0 -1021
- data/vendor/assets/stylesheets/flags.png +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 591d9d5593d83fd89941b987edfd0ae53563b5e9
|
|
4
|
+
data.tar.gz: 2724c980c83b79b013121b2005b659759539f9d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 59df7bbe1a07378390c7526478ba6ea43d887c893f3533e7909506dcc3681e49a35dfe75b8a69185b0d040d4696e528557d0f11e4a8949867774b6db449d3965
|
|
7
|
+
data.tar.gz: 1e10a0af600f689e696dec3b62241a92c3458b62e208f55e7c252affbb22bd3fcd929963e8f8dbba1b59ca61b12bdddc6f9fe01faa41fe9bcc267a736221cb42
|
data/lib/flagstrap.rb
CHANGED
data/lib/flagstrap/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flagstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- paresharma
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-09-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -80,11 +80,6 @@ files:
|
|
|
80
80
|
- lib/flagstrap/version.rb
|
|
81
81
|
- package.json
|
|
82
82
|
- src/jquery.flagstrap.js
|
|
83
|
-
- vendor/assets/images/flags.png
|
|
84
|
-
- vendor/assets/javascripts/jquery.flagstrap.js
|
|
85
|
-
- vendor/assets/javascripts/jquery.flagstrap.min.js
|
|
86
|
-
- vendor/assets/stylesheets/flags.css
|
|
87
|
-
- vendor/assets/stylesheets/flags.png
|
|
88
83
|
homepage: ''
|
|
89
84
|
licenses:
|
|
90
85
|
- MIT
|
|
@@ -105,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
105
100
|
version: '0'
|
|
106
101
|
requirements: []
|
|
107
102
|
rubyforge_project:
|
|
108
|
-
rubygems_version: 2.6.
|
|
103
|
+
rubygems_version: 2.6.11
|
|
109
104
|
signing_key:
|
|
110
105
|
specification_version: 4
|
|
111
106
|
summary: Gemify flagstrap js
|
|
Binary file
|
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* FlagStrap - v1.0
|
|
3
|
-
* A lightwieght jQuery plugin for creating Bootstrap 3 compatible country select boxes with flags.
|
|
4
|
-
* http://www.blazeworx.com/flagstrap
|
|
5
|
-
*
|
|
6
|
-
* Made by Alex Carter
|
|
7
|
-
* Under MIT License
|
|
8
|
-
*/
|
|
9
|
-
(function ($) {
|
|
10
|
-
|
|
11
|
-
var defaults = {
|
|
12
|
-
buttonSize: "btn-md",
|
|
13
|
-
buttonType: "btn-default",
|
|
14
|
-
labelMargin: "10px",
|
|
15
|
-
scrollable: true,
|
|
16
|
-
scrollableHeight: "250px",
|
|
17
|
-
placeholder: {
|
|
18
|
-
value: '',
|
|
19
|
-
text: 'Please select country'
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
var countries = {
|
|
24
|
-
"AF": "Afghanistan",
|
|
25
|
-
"AL": "Albania",
|
|
26
|
-
"DZ": "Algeria",
|
|
27
|
-
"AS": "American Samoa",
|
|
28
|
-
"AD": "Andorra",
|
|
29
|
-
"AO": "Angola",
|
|
30
|
-
"AI": "Anguilla",
|
|
31
|
-
"AG": "Antigua and Barbuda",
|
|
32
|
-
"AR": "Argentina",
|
|
33
|
-
"AM": "Armenia",
|
|
34
|
-
"AW": "Aruba",
|
|
35
|
-
"AU": "Australia",
|
|
36
|
-
"AT": "Austria",
|
|
37
|
-
"AZ": "Azerbaijan",
|
|
38
|
-
"BS": "Bahamas",
|
|
39
|
-
"BH": "Bahrain",
|
|
40
|
-
"BD": "Bangladesh",
|
|
41
|
-
"BB": "Barbados",
|
|
42
|
-
"BY": "Belarus",
|
|
43
|
-
"BE": "Belgium",
|
|
44
|
-
"BZ": "Belize",
|
|
45
|
-
"BJ": "Benin",
|
|
46
|
-
"BM": "Bermuda",
|
|
47
|
-
"BT": "Bhutan",
|
|
48
|
-
"BO": "Bolivia, Plurinational State of",
|
|
49
|
-
"BA": "Bosnia and Herzegovina",
|
|
50
|
-
"BW": "Botswana",
|
|
51
|
-
"BV": "Bouvet Island",
|
|
52
|
-
"BR": "Brazil",
|
|
53
|
-
"IO": "British Indian Ocean Territory",
|
|
54
|
-
"BN": "Brunei Darussalam",
|
|
55
|
-
"BG": "Bulgaria",
|
|
56
|
-
"BF": "Burkina Faso",
|
|
57
|
-
"BI": "Burundi",
|
|
58
|
-
"KH": "Cambodia",
|
|
59
|
-
"CM": "Cameroon",
|
|
60
|
-
"CA": "Canada",
|
|
61
|
-
"CV": "Cape Verde",
|
|
62
|
-
"KY": "Cayman Islands",
|
|
63
|
-
"CF": "Central African Republic",
|
|
64
|
-
"TD": "Chad",
|
|
65
|
-
"CL": "Chile",
|
|
66
|
-
"CN": "China",
|
|
67
|
-
"CO": "Colombia",
|
|
68
|
-
"KM": "Comoros",
|
|
69
|
-
"CG": "Congo",
|
|
70
|
-
"CD": "Congo, the Democratic Republic of the",
|
|
71
|
-
"CK": "Cook Islands",
|
|
72
|
-
"CR": "Costa Rica",
|
|
73
|
-
"CI": "C" + "ô" + "te d'Ivoire",
|
|
74
|
-
"HR": "Croatia",
|
|
75
|
-
"CU": "Cuba",
|
|
76
|
-
"CW": "Cura" + "ç" + "ao",
|
|
77
|
-
"CY": "Cyprus",
|
|
78
|
-
"CZ": "Czech Republic",
|
|
79
|
-
"DK": "Denmark",
|
|
80
|
-
"DJ": "Djibouti",
|
|
81
|
-
"DM": "Dominica",
|
|
82
|
-
"DO": "Dominican Republic",
|
|
83
|
-
"EC": "Ecuador",
|
|
84
|
-
"EG": "Egypt",
|
|
85
|
-
"SV": "El Salvador",
|
|
86
|
-
"GQ": "Equatorial Guinea",
|
|
87
|
-
"ER": "Eritrea",
|
|
88
|
-
"EE": "Estonia",
|
|
89
|
-
"ET": "Ethiopia",
|
|
90
|
-
"FK": "Falkland Islands (Malvinas)",
|
|
91
|
-
"FO": "Faroe Islands",
|
|
92
|
-
"FJ": "Fiji",
|
|
93
|
-
"FI": "Finland",
|
|
94
|
-
"FR": "France",
|
|
95
|
-
"GF": "French Guiana",
|
|
96
|
-
"PF": "French Polynesia",
|
|
97
|
-
"TF": "French Southern Territories",
|
|
98
|
-
"GA": "Gabon",
|
|
99
|
-
"GM": "Gambia",
|
|
100
|
-
"GE": "Georgia",
|
|
101
|
-
"DE": "Germany",
|
|
102
|
-
"GH": "Ghana",
|
|
103
|
-
"GI": "Gibraltar",
|
|
104
|
-
"GR": "Greece",
|
|
105
|
-
"GL": "Greenland",
|
|
106
|
-
"GD": "Grenada",
|
|
107
|
-
"GP": "Guadeloupe",
|
|
108
|
-
"GU": "Guam",
|
|
109
|
-
"GT": "Guatemala",
|
|
110
|
-
"GG": "Guernsey",
|
|
111
|
-
"GN": "Guinea",
|
|
112
|
-
"GW": "Guinea-Bissau",
|
|
113
|
-
"GY": "Guyana",
|
|
114
|
-
"HT": "Haiti",
|
|
115
|
-
"HM": "Heard Island and McDonald Islands",
|
|
116
|
-
"VA": "Holy See (Vatican City State)",
|
|
117
|
-
"HN": "Honduras",
|
|
118
|
-
"HK": "Hong Kong",
|
|
119
|
-
"HU": "Hungary",
|
|
120
|
-
"IS": "Iceland",
|
|
121
|
-
"IN": "India",
|
|
122
|
-
"ID": "Indonesia",
|
|
123
|
-
"IR": "Iran, Islamic Republic of",
|
|
124
|
-
"IQ": "Iraq",
|
|
125
|
-
"IE": "Ireland",
|
|
126
|
-
"IM": "Isle of Man",
|
|
127
|
-
"IL": "Israel",
|
|
128
|
-
"IT": "Italy",
|
|
129
|
-
"JM": "Jamaica",
|
|
130
|
-
"JP": "Japan",
|
|
131
|
-
"JE": "Jersey",
|
|
132
|
-
"JO": "Jordan",
|
|
133
|
-
"KZ": "Kazakhstan",
|
|
134
|
-
"KE": "Kenya",
|
|
135
|
-
"KI": "Kiribati",
|
|
136
|
-
"KP": "Korea, Democratic People's Republic of",
|
|
137
|
-
"KR": "Korea, Republic of",
|
|
138
|
-
"KW": "Kuwait",
|
|
139
|
-
"KG": "Kyrgyzstan",
|
|
140
|
-
"LA": "Lao People's Democratic Republic",
|
|
141
|
-
"LV": "Latvia",
|
|
142
|
-
"LB": "Lebanon",
|
|
143
|
-
"LS": "Lesotho",
|
|
144
|
-
"LR": "Liberia",
|
|
145
|
-
"LY": "Libya",
|
|
146
|
-
"LI": "Liechtenstein",
|
|
147
|
-
"LT": "Lithuania",
|
|
148
|
-
"LU": "Luxembourg",
|
|
149
|
-
"MO": "Macao",
|
|
150
|
-
"MK": "Macedonia, the former Yugoslav Republic of",
|
|
151
|
-
"MG": "Madagascar",
|
|
152
|
-
"MW": "Malawi",
|
|
153
|
-
"MY": "Malaysia",
|
|
154
|
-
"MV": "Maldives",
|
|
155
|
-
"ML": "Mali",
|
|
156
|
-
"MT": "Malta",
|
|
157
|
-
"MH": "Marshall Islands",
|
|
158
|
-
"MQ": "Martinique",
|
|
159
|
-
"MR": "Mauritania",
|
|
160
|
-
"MU": "Mauritius",
|
|
161
|
-
"YT": "Mayotte",
|
|
162
|
-
"MX": "Mexico",
|
|
163
|
-
"FM": "Micronesia, Federated States of",
|
|
164
|
-
"MD": "Moldova, Republic of",
|
|
165
|
-
"MC": "Monaco",
|
|
166
|
-
"MN": "Mongolia",
|
|
167
|
-
"ME": "Montenegro",
|
|
168
|
-
"MS": "Montserrat",
|
|
169
|
-
"MA": "Morocco",
|
|
170
|
-
"MZ": "Mozambique",
|
|
171
|
-
"MM": "Myanmar",
|
|
172
|
-
"NA": "Namibia",
|
|
173
|
-
"NR": "Nauru",
|
|
174
|
-
"NP": "Nepal",
|
|
175
|
-
"NL": "Netherlands",
|
|
176
|
-
"NC": "New Caledonia",
|
|
177
|
-
"NZ": "New Zealand",
|
|
178
|
-
"NI": "Nicaragua",
|
|
179
|
-
"NE": "Niger",
|
|
180
|
-
"NG": "Nigeria",
|
|
181
|
-
"NU": "Niue",
|
|
182
|
-
"NF": "Norfolk Island",
|
|
183
|
-
"MP": "Northern Mariana Islands",
|
|
184
|
-
"NO": "Norway",
|
|
185
|
-
"OM": "Oman",
|
|
186
|
-
"PK": "Pakistan",
|
|
187
|
-
"PW": "Palau",
|
|
188
|
-
"PS": "Palestinian Territory, Occupied",
|
|
189
|
-
"PA": "Panama",
|
|
190
|
-
"PG": "Papua New Guinea",
|
|
191
|
-
"PY": "Paraguay",
|
|
192
|
-
"PE": "Peru",
|
|
193
|
-
"PH": "Philippines",
|
|
194
|
-
"PN": "Pitcairn",
|
|
195
|
-
"PL": "Poland",
|
|
196
|
-
"PT": "Portugal",
|
|
197
|
-
"PR": "Puerto Rico",
|
|
198
|
-
"QA": "Qatar",
|
|
199
|
-
"RE": "R" + "é" + "union",
|
|
200
|
-
"RO": "Romania",
|
|
201
|
-
"RU": "Russian Federation",
|
|
202
|
-
"RW": "Rwanda",
|
|
203
|
-
"SH": "Saint Helena, Ascension and Tristan da Cunha",
|
|
204
|
-
"KN": "Saint Kitts and Nevis",
|
|
205
|
-
"LC": "Saint Lucia",
|
|
206
|
-
"MF": "Saint Martin (French part)",
|
|
207
|
-
"PM": "Saint Pierre and Miquelon",
|
|
208
|
-
"VC": "Saint Vincent and the Grenadines",
|
|
209
|
-
"WS": "Samoa",
|
|
210
|
-
"SM": "San Marino",
|
|
211
|
-
"ST": "Sao Tome and Principe",
|
|
212
|
-
"SA": "Saudi Arabia",
|
|
213
|
-
"SN": "Senegal",
|
|
214
|
-
"RS": "Serbia",
|
|
215
|
-
"SC": "Seychelles",
|
|
216
|
-
"SL": "Sierra Leone",
|
|
217
|
-
"SG": "Singapore",
|
|
218
|
-
"SX": "Sint Maarten (Dutch part)",
|
|
219
|
-
"SK": "Slovakia",
|
|
220
|
-
"SI": "Slovenia",
|
|
221
|
-
"SB": "Solomon Islands",
|
|
222
|
-
"SO": "Somalia",
|
|
223
|
-
"ZA": "South Africa",
|
|
224
|
-
"GS": "South Georgia and the South Sandwich Islands",
|
|
225
|
-
"SS": "South Sudan",
|
|
226
|
-
"ES": "Spain",
|
|
227
|
-
"LK": "Sri Lanka",
|
|
228
|
-
"SD": "Sudan",
|
|
229
|
-
"SR": "Suriname",
|
|
230
|
-
"SZ": "Swaziland",
|
|
231
|
-
"SE": "Sweden",
|
|
232
|
-
"CH": "Switzerland",
|
|
233
|
-
"SY": "Syrian Arab Republic",
|
|
234
|
-
"TW": "Taiwan, Province of China",
|
|
235
|
-
"TJ": "Tajikistan",
|
|
236
|
-
"TZ": "Tanzania, United Republic of",
|
|
237
|
-
"TH": "Thailand",
|
|
238
|
-
"TL": "Timor-Leste",
|
|
239
|
-
"TG": "Togo",
|
|
240
|
-
"TK": "Tokelau",
|
|
241
|
-
"TO": "Tonga",
|
|
242
|
-
"TT": "Trinidad and Tobago",
|
|
243
|
-
"TN": "Tunisia",
|
|
244
|
-
"TR": "Turkey",
|
|
245
|
-
"TM": "Turkmenistan",
|
|
246
|
-
"TC": "Turks and Caicos Islands",
|
|
247
|
-
"TV": "Tuvalu",
|
|
248
|
-
"UG": "Uganda",
|
|
249
|
-
"UA": "Ukraine",
|
|
250
|
-
"AE": "United Arab Emirates",
|
|
251
|
-
"GB": "United Kingdom",
|
|
252
|
-
"US": "United States",
|
|
253
|
-
"UM": "United States Minor Outlying Islands",
|
|
254
|
-
"UY": "Uruguay",
|
|
255
|
-
"UZ": "Uzbekistan",
|
|
256
|
-
"VU": "Vanuatu",
|
|
257
|
-
"VE": "Venezuela, Bolivarian Republic of",
|
|
258
|
-
"VN": "Viet Nam",
|
|
259
|
-
"VG": "Virgin Islands, British",
|
|
260
|
-
"VI": "Virgin Islands, U.S.",
|
|
261
|
-
"WF": "Wallis and Futuna",
|
|
262
|
-
"EH": "Western Sahara",
|
|
263
|
-
"YE": "Yemen",
|
|
264
|
-
"ZM": "Zambia",
|
|
265
|
-
"ZW": "Zimbabwe"
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
$.flagStrap = function (element, options, i) {
|
|
269
|
-
|
|
270
|
-
var plugin = this;
|
|
271
|
-
|
|
272
|
-
var uniqueId = generateId(8);
|
|
273
|
-
|
|
274
|
-
plugin.countries = {};
|
|
275
|
-
plugin.selected = {value: null, text: null};
|
|
276
|
-
plugin.settings = {inputName: 'country-' + uniqueId};
|
|
277
|
-
|
|
278
|
-
var $container = $(element);
|
|
279
|
-
var htmlSelectId = 'flagstrap-' + uniqueId;
|
|
280
|
-
var htmlSelect = '#' + htmlSelectId;
|
|
281
|
-
|
|
282
|
-
plugin.init = function () {
|
|
283
|
-
|
|
284
|
-
// Merge in global settings then merge in individual settings via data attributes
|
|
285
|
-
plugin.countries = countries;
|
|
286
|
-
|
|
287
|
-
// Initialize Settings, priority: defaults, init options, data attributes
|
|
288
|
-
plugin.countries = countries;
|
|
289
|
-
plugin.settings = $.extend({}, defaults, options, $container.data());
|
|
290
|
-
|
|
291
|
-
if (undefined !== plugin.settings.countries) {
|
|
292
|
-
plugin.countries = plugin.settings.countries;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (undefined !== plugin.settings.inputId) {
|
|
296
|
-
htmlSelectId = plugin.settings.inputId;
|
|
297
|
-
htmlSelect = '#' + htmlSelectId;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Build HTML Select, Construct the drop down button, Assemble the drop down list items element and insert
|
|
301
|
-
$container
|
|
302
|
-
.addClass('flagstrap')
|
|
303
|
-
.append(buildHtmlSelect)
|
|
304
|
-
.append(buildDropDownButton)
|
|
305
|
-
.append(buildDropDownButtonItemList);
|
|
306
|
-
|
|
307
|
-
// Check to see if the onSelect callback method is assigned / callable, bind the change event for broadcast
|
|
308
|
-
if (plugin.settings.onSelect !== undefined && plugin.settings.onSelect instanceof Function) {
|
|
309
|
-
$(htmlSelect).change(function (event) {
|
|
310
|
-
var element = this;
|
|
311
|
-
options.onSelect($(element).val(), element);
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Hide the actual HTML select
|
|
316
|
-
$(htmlSelect).hide();
|
|
317
|
-
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
var buildHtmlSelect = function () {
|
|
321
|
-
var htmlSelectElement = $('<select/>').attr('id', htmlSelectId).attr('name', plugin.settings.inputName);
|
|
322
|
-
|
|
323
|
-
$.each(plugin.countries, function (code, country) {
|
|
324
|
-
var optionAttributes = {value: code};
|
|
325
|
-
if (plugin.settings.selectedCountry !== undefined) {
|
|
326
|
-
if (plugin.settings.selectedCountry === code) {
|
|
327
|
-
optionAttributes = {value: code, selected: "selected"};
|
|
328
|
-
plugin.selected = {value: code, text: country}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
htmlSelectElement.append($('<option>', optionAttributes).text(country));
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
if (plugin.settings.placeholder !== false) {
|
|
335
|
-
htmlSelectElement.prepend($('<option>', {
|
|
336
|
-
value: plugin.settings.placeholder.value,
|
|
337
|
-
text: plugin.settings.placeholder.text
|
|
338
|
-
}));
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return htmlSelectElement;
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
var buildDropDownButton = function () {
|
|
345
|
-
|
|
346
|
-
var selectedText = $(htmlSelect).find('option').first().text();
|
|
347
|
-
var selectedValue = $(htmlSelect).find('option').first().val();
|
|
348
|
-
|
|
349
|
-
selectedText = plugin.selected.text || selectedText;
|
|
350
|
-
selectedValue = plugin.selected.value || selectedValue;
|
|
351
|
-
|
|
352
|
-
if (selectedValue !== plugin.settings.placeholder.value) {
|
|
353
|
-
var $selectedLabel = $('<i/>').addClass('flagstrap-icon flagstrap-' + selectedValue.toLowerCase()).css('margin-right', plugin.settings.labelMargin);
|
|
354
|
-
} else {
|
|
355
|
-
var $selectedLabel = $('<i/>').addClass('flagstrap-icon flagstrap-placeholder');
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
var buttonLabel = $('<span/>')
|
|
359
|
-
.addClass('flagstrap-selected-' + uniqueId)
|
|
360
|
-
.html($selectedLabel)
|
|
361
|
-
.append(selectedText);
|
|
362
|
-
|
|
363
|
-
var button = $('<button/>')
|
|
364
|
-
.attr('type', 'button')
|
|
365
|
-
.attr('data-toggle', 'dropdown')
|
|
366
|
-
.attr('id', 'flagstrap-drop-down-' + uniqueId)
|
|
367
|
-
.addClass('btn ' + plugin.settings.buttonType + ' ' + plugin.settings.buttonSize + ' dropdown-toggle')
|
|
368
|
-
.html(buttonLabel);
|
|
369
|
-
|
|
370
|
-
$('<span/>')
|
|
371
|
-
.addClass('caret')
|
|
372
|
-
.css('margin-left', plugin.settings.labelMargin)
|
|
373
|
-
.insertAfter(buttonLabel);
|
|
374
|
-
|
|
375
|
-
return button;
|
|
376
|
-
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
var buildDropDownButtonItemList = function () {
|
|
380
|
-
var items = $('<ul/>')
|
|
381
|
-
.attr('id', 'flagstrap-drop-down-' + uniqueId + '-list')
|
|
382
|
-
.attr('aria-labelled-by', 'flagstrap-drop-down-' + uniqueId)
|
|
383
|
-
.addClass('dropdown-menu');
|
|
384
|
-
|
|
385
|
-
if (plugin.settings.scrollable) {
|
|
386
|
-
items.css('height', 'auto')
|
|
387
|
-
.css('max-height', plugin.settings.scrollableHeight)
|
|
388
|
-
.css('overflow-x', 'hidden');
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Populate the bootstrap dropdown item list
|
|
392
|
-
$(htmlSelect).find('option').each(function () {
|
|
393
|
-
|
|
394
|
-
// Get original select option values and labels
|
|
395
|
-
var text = $(this).text();
|
|
396
|
-
var value = $(this).val();
|
|
397
|
-
|
|
398
|
-
// Build the flag icon
|
|
399
|
-
if (value !== plugin.settings.placeholder.value) {
|
|
400
|
-
var flagIcon = $('<i/>').addClass('flagstrap-icon flagstrap-' + value.toLowerCase()).css('margin-right', plugin.settings.labelMargin);
|
|
401
|
-
} else {
|
|
402
|
-
var flagIcon = null;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
// Build a clickable drop down option item, insert the flag and label, attach click event
|
|
407
|
-
var flagStrapItem = $('<a/>')
|
|
408
|
-
.attr('data-val', $(this).val())
|
|
409
|
-
.html(flagIcon)
|
|
410
|
-
.append(text)
|
|
411
|
-
.on('click', function (e) {
|
|
412
|
-
$(htmlSelect).find('option').removeAttr('selected');
|
|
413
|
-
$(htmlSelect).find('option[value="' + $(this).data('val') + '"]').attr("selected", "selected");
|
|
414
|
-
$(htmlSelect).trigger('change');
|
|
415
|
-
$('.flagstrap-selected-' + uniqueId).html($(this).html());
|
|
416
|
-
e.preventDefault();
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
// Make it a list item
|
|
420
|
-
var listItem = $('<li/>').prepend(flagStrapItem);
|
|
421
|
-
|
|
422
|
-
// Append it to the drop down item list
|
|
423
|
-
items.append(listItem);
|
|
424
|
-
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
return items;
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
function generateId(length) {
|
|
431
|
-
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
|
|
432
|
-
|
|
433
|
-
if (!length) {
|
|
434
|
-
length = Math.floor(Math.random() * chars.length);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
var str = '';
|
|
438
|
-
for (var i = 0; i < length; i++) {
|
|
439
|
-
str += chars[Math.floor(Math.random() * chars.length)];
|
|
440
|
-
}
|
|
441
|
-
return str;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
plugin.init();
|
|
445
|
-
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
$.fn.flagStrap = function (options) {
|
|
449
|
-
|
|
450
|
-
return this.each(function (i) {
|
|
451
|
-
if ($(this).data('flagStrap') === undefined) {
|
|
452
|
-
$(this).data('flagStrap', new $.flagStrap(this, options, i));
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
})(jQuery);
|