mirror of
https://github.com/adnexus/shuttle-select.git
synced 2026-07-26 22:08:50 +00:00
hooking up some interactivity, formatting json
This commit is contained in:
+8
-2
@@ -54,14 +54,14 @@ body {
|
||||
|
||||
.shuttle-select .tier {
|
||||
border: 1px solid #999;
|
||||
min-height: 300px;
|
||||
min-height: 350px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.shuttle-select .title-bar {
|
||||
background: #ddd;
|
||||
position: absolute;
|
||||
height: 300px;
|
||||
height: 350px;
|
||||
width: 20px;
|
||||
}
|
||||
.shuttle-select .title-bar h3 {
|
||||
@@ -75,6 +75,7 @@ body {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.shuttle-select .tier .content {
|
||||
height: 310px;
|
||||
margin: 20px 20px 20px 40px;
|
||||
}
|
||||
.shuttle-select .tier .content label {
|
||||
@@ -82,6 +83,11 @@ body {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.shuttle-select ul.items {
|
||||
border-top: 1px solid #999;
|
||||
height: 285px;
|
||||
overflow: auto;
|
||||
}
|
||||
.shuttle-select ul.items li {
|
||||
border-top: 1px solid #999;
|
||||
border-bottom: 1px solid #999;
|
||||
|
||||
@@ -1,3 +1,291 @@
|
||||
/* Objects */
|
||||
{
|
||||
"AF": {
|
||||
"name": "Africa",
|
||||
"countries": {
|
||||
"DZ":"Algeria, People's Democratic Republic of",
|
||||
"AO":"Angola, Republic of",
|
||||
"BW":"Botswana, Republic of",
|
||||
"BI":"Burundi, Republic of",
|
||||
"CM":"Cameroon, Republic of",
|
||||
"CV":"Cape Verde, Republic of",
|
||||
"CF":"Central African Republic",
|
||||
"TD":"Chad, Republic of",
|
||||
"KM":"Comoros, Union of the",
|
||||
"YT":"Mayotte",
|
||||
"CG":"Congo, Republic of the",
|
||||
"CD":"Congo, Democratic Republic of the",
|
||||
"BJ":"Benin, Republic of",
|
||||
"GQ":"Equatorial Guinea, Republic of",
|
||||
"ET":"Ethiopia, Federal Democratic Republic of",
|
||||
"ER":"Eritrea, State of",
|
||||
"DJ":"Djibouti, Republic of",
|
||||
"GA":"Gabon, Gabonese Republic",
|
||||
"GM":"Gambia, Republic of the",
|
||||
"GH":"Ghana, Republic of",
|
||||
"GN":"Guinea, Republic of",
|
||||
"CI":"Cote d'Ivoire, Republic of",
|
||||
"KE":"Kenya, Republic of",
|
||||
"LS":"Lesotho, Kingdom of",
|
||||
"LR":"Liberia, Republic of",
|
||||
"LY":"Libyan Arab Jamahiriya",
|
||||
"MG":"Madagascar, Republic of",
|
||||
"MW":"Malawi, Republic of",
|
||||
"ML":"Mali, Republic of",
|
||||
"MR":"Mauritania, Islamic Republic of",
|
||||
"MU":"Mauritius, Republic of",
|
||||
"MA":"Morocco, Kingdom of",
|
||||
"MZ":"Mozambique, Republic of",
|
||||
"NA":"Namibia, Republic of",
|
||||
"NE":"Niger, Republic of",
|
||||
"NG":"Nigeria, Federal Republic of",
|
||||
"GW":"Guinea-Bissau, Republic of",
|
||||
"RE":"Reunion",
|
||||
"RW":"Rwanda, Republic of",
|
||||
"SH":"Saint Helena",
|
||||
"ST":"Sao Tome and Principe, Democratic Republic of",
|
||||
"SN":"Senegal, Republic of",
|
||||
"SC":"Seychelles, Republic of",
|
||||
"SL":"Sierra Leone, Republic of",
|
||||
"SO":"Somalia, Somali Republic",
|
||||
"ZA":"South Africa, Republic of",
|
||||
"ZW":"Zimbabwe, Republic of",
|
||||
"EH":"Western Sahara",
|
||||
"SD":"Sudan, Republic of",
|
||||
"SZ":"Swaziland, Kingdom of",
|
||||
"TG":"Togo, Togolese Republic",
|
||||
"TN":"Tunisia, Tunisian Republic",
|
||||
"UG":"Uganda, Republic of",
|
||||
"EG":"Egypt, Arab Republic of",
|
||||
"TZ":"Tanzania, United Republic of",
|
||||
"BF":"Burkina Faso",
|
||||
"ZM":"Zambia, Republic of"
|
||||
}
|
||||
},
|
||||
"AS": {
|
||||
"name": "Asia",
|
||||
"countries": {
|
||||
"AF":"Afghanistan, Islamic Republic of",
|
||||
"AZ":"Azerbaijan, Republic of",
|
||||
"BH":"Bahrain, Kingdom of",
|
||||
"BD":"Bangladesh, People's Republic of",
|
||||
"AM":"Armenia, Republic of",
|
||||
"BT":"Bhutan, Kingdom of",
|
||||
"IO":"British Indian Ocean Territory (Chagos Archipelago)",
|
||||
"BN":"Brunei Darussalam",
|
||||
"MM":"Myanmar, Union of",
|
||||
"KH":"Cambodia, Kingdom of",
|
||||
"LK":"Sri Lanka, Democratic Socialist Republic of",
|
||||
"CN":"China, People's Republic of",
|
||||
"TW":"Taiwan",
|
||||
"CX":"Christmas Island",
|
||||
"CC":"Cocos (Keeling) Islands",
|
||||
"CY":"Cyprus, Republic of",
|
||||
"GE":"Georgia",
|
||||
"PS":"Palestinian Territory, Occupied",
|
||||
"HK":"Hong Kong, Special Administrative Region of China",
|
||||
"IN":"India, Republic of",
|
||||
"ID":"Indonesia, Republic of",
|
||||
"IR":"Iran, Islamic Republic of",
|
||||
"IQ":"Iraq, Republic of",
|
||||
"IL":"Israel, State of",
|
||||
"JP":"Japan",
|
||||
"KZ":"Kazakhstan, Republic of",
|
||||
"JO":"Jordan, Hashemite Kingdom of",
|
||||
"KP":"Korea, Democratic People's Republic of",
|
||||
"KR":"Korea, Republic of",
|
||||
"KW":"Kuwait, State of",
|
||||
"KG":"Kyrgyz Republic",
|
||||
"LA":"Lao People's Democratic Republic",
|
||||
"LB":"Lebanon, Lebanese Republic",
|
||||
"MO":"Macao, Special Administrative Region of China",
|
||||
"MY":"Malaysia",
|
||||
"MV":"Maldives, Republic of",
|
||||
"MN":"Mongolia",
|
||||
"OM":"Oman, Sultanate of",
|
||||
"NP":"Nepal, State of",
|
||||
"PK":"Pakistan, Islamic Republic of",
|
||||
"PH":"Philippines, Republic of the",
|
||||
"TL":"Timor-Leste, Democratic Republic of",
|
||||
"QA":"Qatar, State of",
|
||||
"RU":"Russian Federation",
|
||||
"SA":"Saudi Arabia, Kingdom of",
|
||||
"SG":"Singapore, Republic of",
|
||||
"VN":"Vietnam, Socialist Republic of",
|
||||
"SY":"Syrian Arab Republic",
|
||||
"TJ":"Tajikistan, Republic of",
|
||||
"TH":"Thailand, Kingdom of",
|
||||
"AE":"United Arab Emirates",
|
||||
"TR":"Turkey, Republic of",
|
||||
"TM":"Turkmenistan",
|
||||
"UZ":"Uzbekistan, Republic of",
|
||||
"YE":"Yemen"
|
||||
}
|
||||
},
|
||||
"EU": {
|
||||
"name": "Europe",
|
||||
"countries": {
|
||||
"AL":"Albania, Republic of",
|
||||
"AD":"Andorra, Principality of",
|
||||
"AZ":"Azerbaijan, Republic of",
|
||||
"AT":"Austria, Republic of",
|
||||
"AM":"Armenia, Republic of",
|
||||
"BE":"Belgium, Kingdom of",
|
||||
"BA":"Bosnia and Herzegovina",
|
||||
"BG":"Bulgaria, Republic of",
|
||||
"BY":"Belarus, Republic of",
|
||||
"HR":"Croatia, Republic of",
|
||||
"CY":"Cyprus, Republic of",
|
||||
"CZ":"Czech Republic",
|
||||
"DK":"Denmark, Kingdom of",
|
||||
"EE":"Estonia, Republic of",
|
||||
"FO":"Faroe Islands",
|
||||
"FI":"Finland, Republic of",
|
||||
"AX":"Åland Islands",
|
||||
"FR":"France, French Republic",
|
||||
"GE":"Georgia",
|
||||
"DE":"Germany, Federal Republic of",
|
||||
"GI":"Gibraltar",
|
||||
"GR":"Greece, Hellenic Republic",
|
||||
"VA":"Holy See (Vatican City State)",
|
||||
"HU":"Hungary, Republic of",
|
||||
"IS":"Iceland, Republic of",
|
||||
"IE":"Ireland",
|
||||
"IT":"Italy, Italian Republic",
|
||||
"KZ":"Kazakhstan, Republic of",
|
||||
"LV":"Latvia, Republic of",
|
||||
"LI":"Liechtenstein, Principality of",
|
||||
"LT":"Lithuania, Republic of",
|
||||
"LU":"Luxembourg, Grand Duchy of",
|
||||
"MT":"Malta, Republic of",
|
||||
"MC":"Monaco, Principality of",
|
||||
"MD":"Moldova, Republic of",
|
||||
"ME":"Montenegro, Republic of",
|
||||
"NL":"Netherlands, Kingdom of the",
|
||||
"NO":"Norway, Kingdom of",
|
||||
"PL":"Poland, Republic of",
|
||||
"PT":"Portugal, Portuguese Republic",
|
||||
"RO":"Romania",
|
||||
"RU":"Russian Federation",
|
||||
"SM":"San Marino, Republic of",
|
||||
"RS":"Serbia, Republic of",
|
||||
"SK":"Slovakia (Slovak Republic)",
|
||||
"SI":"Slovenia, Republic of",
|
||||
"ES":"Spain, Kingdom of",
|
||||
"SJ":"Svalbard & Jan Mayen Islands",
|
||||
"SE":"Sweden, Kingdom of",
|
||||
"CH":"Switzerland, Swiss Confederation",
|
||||
"TR":"Turkey, Republic of",
|
||||
"UA":"Ukraine",
|
||||
"MK":"Macedonia, Republic of",
|
||||
"GB":"United Kingdom of Great Britain & Northern Ireland",
|
||||
"GG":"Guernsey, Bailiwick of",
|
||||
"JE":"Jersey, Bailiwick of",
|
||||
"IM":"Isle of Man"
|
||||
}
|
||||
},
|
||||
"NA": {
|
||||
"name": "North America",
|
||||
"countries": {
|
||||
"AG":"Antigua and Barbuda",
|
||||
"BS":"Bahamas, Commonwealth of the",
|
||||
"BB":"Barbados",
|
||||
"BM":"Bermuda",
|
||||
"BZ":"Belize",
|
||||
"VG":"British Virgin Islands",
|
||||
"CA":"Canada",
|
||||
"KY":"Cayman Islands",
|
||||
"CR":"Costa Rica, Republic of",
|
||||
"CU":"Cuba, Republic of",
|
||||
"DM":"Dominica, Commonwealth of",
|
||||
"DO":"Dominican Republic",
|
||||
"SV":"El Salvador, Republic of",
|
||||
"GL":"Greenland",
|
||||
"GD":"Grenada",
|
||||
"GP":"Guadeloupe",
|
||||
"GT":"Guatemala, Republic of",
|
||||
"HT":"Haiti, Republic of",
|
||||
"HN":"Honduras, Republic of",
|
||||
"JM":"Jamaica",
|
||||
"MQ":"Martinique",
|
||||
"MX":"Mexico, United Mexican States",
|
||||
"MS":"Montserrat",
|
||||
"AN":"Netherlands Antilles",
|
||||
"CW":"Curaçao",
|
||||
"AW":"Aruba",
|
||||
"SX":"Sint Maarten (Netherlands)",
|
||||
"BQ":"Bonaire, Saint Eustatius and Saba",
|
||||
"NI":"Nicaragua, Republic of",
|
||||
"UM":"United States Minor Outlying Islands",
|
||||
"PA":"Panama, Republic of",
|
||||
"PR":"Puerto Rico, Commonwealth of",
|
||||
"BL":"Saint Barthelemy",
|
||||
"KN":"Saint Kitts and Nevis, Federation of",
|
||||
"AI":"Anguilla",
|
||||
"LC":"Saint Lucia",
|
||||
"MF":"Saint Martin",
|
||||
"PM":"Saint Pierre and Miquelon",
|
||||
"VC":"Saint Vincent and the Grenadines",
|
||||
"TT":"Trinidad and Tobago, Republic of",
|
||||
"TC":"Turks and Caicos Islands",
|
||||
"US":"United States of America",
|
||||
"VI":"United States Virgin Islands"
|
||||
}
|
||||
},
|
||||
"OC": {
|
||||
"name": "Oceania",
|
||||
"countries": {
|
||||
"OC":"American Samoa",
|
||||
"OC":"Australia, Commonwealth of",
|
||||
"OC":"Solomon Islands",
|
||||
"OC":"Cook Islands",
|
||||
"OC":"Fiji, Republic of the Fiji Islands",
|
||||
"OC":"French Polynesia",
|
||||
"OC":"Kiribati, Republic of",
|
||||
"OC":"Guam",
|
||||
"OC":"Nauru, Republic of",
|
||||
"OC":"New Caledonia",
|
||||
"OC":"Vanuatu, Republic of",
|
||||
"OC":"New Zealand",
|
||||
"OC":"Niue",
|
||||
"OC":"Norfolk Island",
|
||||
"OC":"Northern Mariana Islands, Commonwealth of the",
|
||||
"OC":"United States Minor Outlying Islands",
|
||||
"OC":"Micronesia, Federated States of",
|
||||
"OC":"Marshall Islands, Republic of the",
|
||||
"OC":"Palau, Republic of",
|
||||
"OC":"Papua New Guinea, Independent State of",
|
||||
"OC":"Pitcairn Islands",
|
||||
"OC":"Tokelau",
|
||||
"OC":"Tonga, Kingdom of",
|
||||
"OC":"Tuvalu",
|
||||
"OC":"Wallis and Futuna",
|
||||
"OC":"Samoa, Independent State of"
|
||||
}
|
||||
},
|
||||
"SA": {
|
||||
"name": "South America",
|
||||
"countries": {
|
||||
"SA":"Argentina, Argentine Republic",
|
||||
"SA":"Bolivia, Republic of",
|
||||
"SA":"Brazil, Federative Republic of",
|
||||
"SA":"Chile, Republic of",
|
||||
"SA":"Colombia, Republic of",
|
||||
"SA":"Ecuador, Republic of",
|
||||
"SA":"Falkland Islands (Malvinas)",
|
||||
"SA":"French Guiana",
|
||||
"SA":"Guyana, Co-operative Republic of",
|
||||
"SA":"Paraguay, Republic of",
|
||||
"SA":"Peru, Republic of",
|
||||
"SA":"Suriname, Republic of",
|
||||
"SA":"Uruguay, Eastern Republic of",
|
||||
"SA":"Venezuela, Bolivarian Republic of"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Arrays */
|
||||
|
||||
{
|
||||
"Africa": [
|
||||
"Algeria, People's Democratic Republic of",
|
||||
|
||||
+77
-6
@@ -36,15 +36,15 @@
|
||||
<h3><div>All Locations</div></h3>
|
||||
</div>
|
||||
<div class="content">
|
||||
<label for="UNIQUE-NAME-include-all"><input type="checkbox" name="include_all" id="UNIQUE-NAME-include-all" /> Include all</label>
|
||||
<label for="UNIQUE-NAME-include-all"><input type="checkbox" name="include_all" id="UNIQUE-NAME-include-all" checked="checked" /> Include all</label>
|
||||
<ul class="items">
|
||||
<li>Africa <span class="arrows">>></span></li>
|
||||
<!-- <li>Africa <span class="arrows">>></span></li>
|
||||
<li>Asia & Middle East <span class="arrows">>></span></li>
|
||||
<li>Canada & United States <span class="arrows">>></span></li>
|
||||
<li>Europe <span class="arrows">>></span></li>
|
||||
<li>Latin America <span class="arrows">>></span></li>
|
||||
<li>Oceania <span class="arrows">>></span></li>
|
||||
<li>South America <span class="arrows">>></span></li>
|
||||
<li>South America <span class="arrows">>></span></li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,6 +56,10 @@
|
||||
(function(){
|
||||
var ShuttleSelect = function(element) {
|
||||
var _$el = null;
|
||||
var _$list = null;
|
||||
var _$items = null;
|
||||
var hasChildren = true;
|
||||
var location = null;
|
||||
|
||||
var formatVerticalText = function() {
|
||||
var title = _$el.find('.title-bar h3');
|
||||
@@ -65,19 +69,86 @@
|
||||
});
|
||||
}
|
||||
|
||||
var formatItem = function(item) {
|
||||
return '<li>'+item+' <span class="arrows">>></span></li>';
|
||||
var formatItem = function(item, bool) {
|
||||
if (bool) {
|
||||
item += '<span class="arrows">>></span>';
|
||||
} else {
|
||||
item = '<input type="checkbox" checked="checked" /> ' + item;
|
||||
}
|
||||
return '<li>'+item+'</li>';
|
||||
}
|
||||
|
||||
var buildItemList = function(items) {
|
||||
|
||||
var formattedItems = [];
|
||||
for (var i in items) {
|
||||
formattedItems.push(formatItem(i, hasChildren));
|
||||
}
|
||||
_$list.html(formattedItems.join('\n'));
|
||||
_$items = _$el.find('ul.items li');
|
||||
hasChildren = false;
|
||||
}
|
||||
|
||||
var getItemsForLocation = function(location) {
|
||||
var formattedItems = [];
|
||||
for (var i=0; i < countries[location].length; i++) {
|
||||
formattedItems.push(formatItem(countries[location][i], hasChildren));
|
||||
};
|
||||
_$list.html(formattedItems.join('\n'));
|
||||
_$items = _$el.find('ul.items li');
|
||||
bindCheckboxEvents();
|
||||
}
|
||||
|
||||
var bindItemEvents = function() {
|
||||
_$items.bind('click', function(event){
|
||||
location = this.firstChild.textContent;
|
||||
getItemsForLocation(location);
|
||||
});
|
||||
}
|
||||
|
||||
var bindCheckboxEvents = function() {
|
||||
var _$itemCheckboxes = _$items.find(':checkbox');
|
||||
_$itemCheckboxes.bind('click', function(event){
|
||||
addItemToSelectedList($(this).parent().text(), this.checked);
|
||||
});
|
||||
_$el.find('input[name="include_all"]').bind('click', function(){
|
||||
if (!this.checked) {
|
||||
clearList();
|
||||
} else {
|
||||
setLocation();
|
||||
}
|
||||
_$itemCheckboxes.attr('checked', this.checked);
|
||||
});
|
||||
}
|
||||
|
||||
var setLocation = function() {
|
||||
_$selectedList.append('<li>'+location+'</li>');
|
||||
}
|
||||
|
||||
var clearList = function() {
|
||||
_$selectedList.empty();
|
||||
}
|
||||
|
||||
var addItemToSelectedList = function(item, bool) {
|
||||
if (bool) {
|
||||
var li = '<li>'+item+'</li>';
|
||||
_$selectedList.append(li);
|
||||
} else {
|
||||
var selector = ':contains('+item+')';
|
||||
_$selectedList.find(selector).remove();
|
||||
}
|
||||
}
|
||||
this.addItemToSelectedList = addItemToSelectedList;
|
||||
|
||||
this.init = function(element) {
|
||||
_$el = $(element);
|
||||
_$list = _$el.find('ul.items');
|
||||
_$selectedList = _$el.find('.included-list ul');
|
||||
|
||||
formatVerticalText();
|
||||
buildItemList(countries);
|
||||
bindItemEvents();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(function(){
|
||||
|
||||
Reference in New Issue
Block a user