flagstrap 0.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.
Binary file
@@ -0,0 +1,458 @@
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);
@@ -0,0 +1,9 @@
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(a){var b={buttonSize:"btn-md",buttonType:"btn-default",labelMargin:"10px",scrollable:!0,scrollableHeight:"250px",placeholder:{value:"",text:"Please select country"}},c={AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, the Democratic Republic of the",CK:"Cook Islands",CR:"Costa Rica",CI:"C&ocirc;te d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Cura&ccedil;ao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran, Islamic Republic of",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"Korea, Democratic People's Republic of",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia, the former Yugoslav Republic of",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestinian Territory, Occupied",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"R&eacute;union",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"};a.flagStrap=function(d,e){function f(a){var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".split("");a||(a=Math.floor(Math.random()*b.length));for(var c="",d=0;a>d;d++)c+=b[Math.floor(Math.random()*b.length)];return c}var g=this,h=f(8);g.countries={},g.selected={value:null,text:null},g.settings={inputName:"country-"+h};var i=a(d),j="flagstrap-"+h,k="#"+j;g.init=function(){g.countries=c,g.countries=c,g.settings=a.extend({},b,e,i.data()),void 0!==g.settings.countries&&(g.countries=g.settings.countries),void 0!==g.settings.inputId&&(j=g.settings.inputId,k="#"+j),i.addClass("flagstrap").append(l).append(m).append(n),void 0!==g.settings.onSelect&&g.settings.onSelect instanceof Function&&a(k).change(function(){var b=this;e.onSelect(a(b).val(),b)}),a(k).hide()};var l=function(){var b=a("<select/>").attr("id",j).attr("name",g.settings.inputName);return a.each(g.countries,function(c,d){var e={value:c};void 0!==g.settings.selectedCountry&&g.settings.selectedCountry===c&&(e={value:c,selected:"selected"},g.selected={value:c,text:d}),b.append(a("<option>",e).text(d))}),g.settings.placeholder!==!1&&b.prepend(a("<option>",{value:g.settings.placeholder.value,text:g.settings.placeholder.text})),b},m=function(){var b=a(k).find("option").first().text(),c=a(k).find("option").first().val();if(b=g.selected.text||b,c=g.selected.value||c,c!==g.settings.placeholder.value)var d=a("<i/>").addClass("flagstrap-icon flagstrap-"+c.toLowerCase()).css("margin-right",g.settings.labelMargin);else var d=a("<i/>").addClass("flagstrap-icon flagstrap-placeholder");var e=a("<span/>").addClass("flagstrap-selected-"+h).html(d).append(b),f=a("<button/>").attr("type","button").attr("data-toggle","dropdown").attr("id","flagstrap-drop-down-"+h).addClass("btn "+g.settings.buttonType+" "+g.settings.buttonSize+" dropdown-toggle").html(e);return a("<span/>").addClass("caret").css("margin-left",g.settings.labelMargin).insertAfter(e),f},n=function(){var b=a("<ul/>").attr("id","flagstrap-drop-down-"+h+"-list").attr("aria-labelled-by","flagstrap-drop-down-"+h).addClass("dropdown-menu");return g.settings.scrollable&&b.css("height","auto").css("max-height",g.settings.scrollableHeight).css("overflow-x","hidden"),a(k).find("option").each(function(){var c=a(this).text(),d=a(this).val();if(d!==g.settings.placeholder.value)var e=a("<i/>").addClass("flagstrap-icon flagstrap-"+d.toLowerCase()).css("margin-right",g.settings.labelMargin);else var e=null;var f=a("<a/>").attr("data-val",a(this).val()).html(e).append(c).on("click",function(b){a(k).find("option").removeAttr("selected"),a(k).find('option[value="'+a(this).data("val")+'"]').attr("selected","selected"),a(k).trigger("change"),a(".flagstrap-selected-"+h).html(a(this).html()),b.preventDefault()}),i=a("<li/>").prepend(f);b.append(i)}),b};g.init()},a.fn.flagStrap=function(b){return this.each(function(c){void 0===a(this).data("flagStrap")&&a(this).data("flagStrap",new a.flagStrap(this,b,c))})}}(jQuery);
data/flagstrap.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flagstrap/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flagstrap"
8
+ spec.version = Flagstrap::VERSION
9
+ spec.authors = ["paresharma"]
10
+ spec.email = ["paresharma@gmail.com"]
11
+
12
+ spec.summary = %q{ Gemify flagstrap js }
13
+ spec.description = %q{ Gemify flagstrap js }
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "boilerplate",
3
+ "title": "FlagStrap",
4
+ "description": "A lightwieght jQuery plugin for creating Bootstrap 3 compatible country select boxes with flags.",
5
+ "keywords": [
6
+ "jquery",
7
+ "bootstrap",
8
+ "country",
9
+ "flag",
10
+ "flagstrap",
11
+ "jquery-flagstrap"
12
+ ],
13
+ "version": "1.0",
14
+ "author": {
15
+ "name": "Alex Carter",
16
+ "email": "alex@blazeworx.com",
17
+ "url": "https://github.com/blazeworx"
18
+ },
19
+ "maintainers": [
20
+ {
21
+ "name": "Alex Carter",
22
+ "email": "alex@blazeworx.com",
23
+ "url": "https://github.com/blazeworx"
24
+ }
25
+ ],
26
+ "licenses": [
27
+ {
28
+ "type": "MIT",
29
+ "url": "http://blazeworx.mit-license.org/"
30
+ }
31
+ ],
32
+ "bugs": "https://github.com/blazeworx/flagstrap/issues",
33
+ "homepage": "http://www.blazeworx.com/flagstrap",
34
+ "docs": "https://github.com/blazeworx/flagstrap#readme",
35
+ "download": "https://github.com/blazeworx/flagstrap/archive/master.zip",
36
+ "dependencies": {
37
+ "jquery": ">=1.4"
38
+ }
39
+ }
@@ -0,0 +1,3 @@
1
+ module Flagstrap
2
+ VERSION = "0.0.2"
3
+ end
data/lib/flagstrap.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "flagstrap/version"
2
+
3
+ module Flagstrap
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
data/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "private": true,
3
+ "devDependencies": {
4
+ "grunt": "~0.4.5",
5
+ "grunt-cli": "~0.1.13",
6
+ "grunt-contrib-concat": "~0.4.0",
7
+ "grunt-contrib-jshint": "~0.10.0",
8
+ "grunt-contrib-uglify": "~0.4.0",
9
+ "grunt-contrib-watch": "^0.6.1"
10
+ }
11
+ }
12
+
13
+