feat: new inquiry form 2019 js
parent
9309634c50
commit
03ad0ee5ac
@ -0,0 +1,92 @@
|
||||
$(function() {
|
||||
String.prototype.capitalize = function() {
|
||||
return this.replace(/^\S/, function(s) {
|
||||
return s.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
$("a[minus]").each(function(index, element) {
|
||||
$(element).click(function() {
|
||||
var targetId = $(this).data("target");
|
||||
var $targetInput = $("#" + targetId);
|
||||
var minVal = $targetInput.data("min");
|
||||
var inputVal = parseInt($targetInput.val());
|
||||
if (inputVal > minVal) {
|
||||
inputVal -= 1;
|
||||
$targetInput.val(inputVal);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("a[plus]").each(function(index, element) {
|
||||
$(element).click(function() {
|
||||
var targetId = $(this).data("target");
|
||||
var $targetInput = $("#" + targetId);
|
||||
var maxVal = $targetInput.data("max");
|
||||
var inputVal = parseInt($targetInput.val());
|
||||
if (inputVal < maxVal) {
|
||||
inputVal += 1;
|
||||
$targetInput.val(inputVal);
|
||||
}
|
||||
});
|
||||
});
|
||||
var $realname = $('#realname');
|
||||
$("#realname").blur(function() {
|
||||
$realname.val($realname.val().capitalize());
|
||||
});
|
||||
$('.whoTravel :input').focus(function(){
|
||||
$('.whoTravel').children('.requiredArea').remove();
|
||||
});
|
||||
$('#starting_date').focus(function() {
|
||||
$('.travelDays').children('.requiredArea').remove();
|
||||
});
|
||||
$('#starting_date').focus(function() {
|
||||
$('.datesArrival').children('.requiredArea').remove();
|
||||
});
|
||||
$('input[name="hotel"]').click(function() {
|
||||
$('.hotelBlock').children('.requiredArea').remove();
|
||||
});
|
||||
$('input[name="HotelName"]').focus(function() {
|
||||
$('.hotelBlock').children('.requiredArea').remove();
|
||||
});
|
||||
$('input[name="travelstyle"]').click(function() {
|
||||
$('.travelBlock').children('.requiredArea').remove();
|
||||
});
|
||||
$('input[name="realname"],input[name="nationality"],input[name="email"]').focus(function() {
|
||||
$(this).parents('.personalInfo').children('.requiredArea').remove();
|
||||
});
|
||||
|
||||
var substringMatcher = function(strs) {
|
||||
return function findMatches(q, cb) {
|
||||
if (q == '') {
|
||||
return cb(
|
||||
["United States", "Canada", "Australia", "United Kingdom", "Germany",
|
||||
"France", "Italy", "Spain", "China", "Singapore", "Malaysia"]);
|
||||
}
|
||||
var matches, substringRegex;
|
||||
matches = [];
|
||||
substrRegex = new RegExp(q, 'i');
|
||||
$.each(strs, function(i, str) {
|
||||
if (substrRegex.test(str)) {
|
||||
matches.push(str);
|
||||
}
|
||||
});
|
||||
cb(matches);
|
||||
};
|
||||
};
|
||||
|
||||
var nationality_map = ["afghanistan", "albania", "algeria", "american samoa", "andorra", "angola", "anguilla", "antarctica", "antigua and barbuda", "argentina", "armenia", "aruba", "australia", "austria", "azerbaijan", "bahamas", "bahrain", "bangladesh", "barbadian", "barbados", "belarus", "belgium", "belize", "benin", "bermuda", "bhutan", "bolivia", "botswana", "bouvet island", "brazil", "british indian ocean territory", "brunei darussalam", "bulgaria", "burkina faso", "burundi", "cambodia", "cameroon", "canada", "cape verde", "cayman islands", "central african republic", "chad", "chile", "china", "china HK", "christmas island", "colombia", "comoros", "congo", "cook islands", "costa rica", "croatia", "cuba", "cyprus", "czech republic", "czechoslovakia", "denmark", "djibouti", "dominica", "dominican republic", "east timor", "ecuador", "egypt", "el salvador", "equatorial guinea", "eritrea", "estonia", "ethiopia", "falkland islands", "faroe islands", "fiji", "finland", "france", "french guiana", "french polynesia", "gabon", "gambia", "georgia", "germany", "ghana", "gibraltar", "greece", "greenland", "grenada", "guadeloupe", "guam", "guatemala", "guernsey", "guinea", "guinea-bissau", "guyana", "haiti", "honduras", "hong kong", "hungary", "iceland", "india", "indonesia", "iran", "iraq", "ireland", "isle of man", "israel", "italy", "jamaica", "japan", "jersey", "jordan", "kazakhstan", "kazakhstan2", "kenya", "kiribati", "korea", "kuwait", "kyrgyzstan", "laos", "latvia", "lebanon", "lesotho", "liberia", "libyan arab jamahiriya", "liechtenstein", "lithuania", "luxembourg", "macau", "macedonia", "madagascar", "malawi", "malaysia", "maldives", "mali", "malta", "marshall islands", "martinique", "mauritania", "mauritius", "mayotte", "mexican", "micronesia", "moldova", "monaco", "mongolia", "montserrat", "morocco", "mozambique", "myanmar", "namibia", "nauru", "nepal", "netherlands", "netherlands antilles", "neutral zone", "new caledonia", "new zealand", "nicaragua", "niger", "nigeria", "niue", "norfolk island", "north korea", "northern mariana islands", "norway", "oman", "pakistan", "palau", "panama", "papua new guinea", "paraguay", "peru", "philippines", "pitcairn", "poland", "portugal", "puerto rico", "qatar", "reunion", "romania", "russian federation", "rwanda", "saint helena", "samoa", "san marino", "sao tome and principe", "saudi arabia", "scotland", "senegal", "seychelles", "sierra leone", "singapore", "slovakia", "slovenia", "solomon islands", "somalia", "south africa", "south georgia and the sandwich", "spain", "sri lanka", "sudan", "suriname", "swaziland", "sweden", "switzerland", "syrian arab republic", "taiwan", "tanzania", "thailand", "the republic of cote d'ivoire", "togo", "tokelau", "tonga", "trinidad and tobago", "tunisia", "turkey", "turkmenistan", "turks and caicos islands", "tuvalu", "uganda", "ukraine", "united arab emirates", "united kingdom", "united states", "unknown", "uruguay", "ussr", "uzbekistan", "vanuatu", "vatican city state", "venezuela", "vietnam", "virgin islands (british)", "virgin islands (u.s.)", "western sahara", "yemen", "yugoslavia", "zaire", "zambia", "zimbabwe"];
|
||||
$('.nationality').typeahead({
|
||||
hint: false,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
suggestion: 'tt-suggestion tt-selectable tt-suggestion-nationality'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'nationality_states',
|
||||
source: substringMatcher(nationality_map),
|
||||
limit: 10
|
||||
});
|
||||
})
|
Loading…
Reference in New Issue