$(document).ready(function() {
/* Search Autocomplete.....[Start]
*/
// debugger;
$.widget("custom.catcomplete", $.ui.autocomplete, {
_renderMenu: function(ul, items) {
var that = this,
currentCategory = "";
$.each(items, function(index, item) {
if (item.category != currentCategory) {
if (item.category === "city") {
ul.append("
");
}
else if (item.category === "category") {
ul.append("");
}
else if (item.category === "state") {
ul.append("");
}
else if (item.category === "region") {
ul.append("");
}
else if (item.category === "country") {
ul.append("");
}
else if (item.category === "tours") {
ul.append("");
}
else {
ul.append("");
}
currentCategory = item.category;
}
that._renderItemData(ul, item);
});
}
});
$("#txtSearch1").catcomplete({
source:function(request, response) {
xmlHttp = new Ajax().GetXmlHttpObject();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
var responseTxt = JSON.parse(xmlHttp.responseText);
var data = eval(responseTxt)
if (!data || data.length != 0) {
response($.map(data, function(item) {
return { label: item.Name, category: item.SearchType, code: item.Code, displayname: item.DisplayName };
}))
}
else {
//var result = [{ label: Resources.AutoCompleteNoMatch + request.term, category: 'noresult'}];
var result= [{ label: 'No Result Found', category: 'noresult'}];
response(result);
}
}
};
var domainurl = "https://www.veenaworld.com";
var AutocompleteUrl= domainurl + "/Home/autoCompleteResults?"
var Params="term=" + request.term + "&&countryCode=IN&locationType="+ $("input[name=domTypeMain]:checked").val()
var url = AutocompleteUrl + Params;
// Set up and make the request.
xmlHttp.open('POST', url, true);
xmlHttp.send();
},
minLength: 3,
select: function(event, ui) {
if (ui.item.category != "noresult") {
if (ui.item.category === "city") { $('#txtWhere').val(ui.item.label); $("#optCategory option:selected").text(''); }
else if (ui.item.category === "category") { $("#optCategory option:selected").text(ui.item.code); $('#txtWhere').val('') }
else if (ui.item.category === "tours") { window.location.href = "/Package/Detail?pCode=" + ui.item.code + "&cCode=" + ui.item.displayname; return false; }
$("input[name=domType]:checked").val($("input[name=domTypeMain]:checked").val());
$("#optMonth option:selected").text(''); $("#optYear option:selected").text('');
$("#hdnSearchType").val(ui.item.category);
$("#hdnDestinationName").val(ui.item.displayname);
$("#hdnDestination").val(ui.item.label);
$("#hdnSearchParam").val(ui.item.code);
$("#frmSearch").submit();
}
return false;
},
appendTo: "#divSearchResults"
});
$(function() {
$("#txtSearch").catcomplete({
delay: 0,
source: function(request, response) {
$.ajax({
url: '/Home/autoCompleteResults',
type: "POST",
crossDomain: true,
dataType: 'json',
cache: false,
data: { term: request.term, countryCode: 'IN', locationType: $("input[name=domTypeMain]:checked").val() },
success: function(data) {
//debugger;
if (!data || data.length != 0) {
response($.map(data, function(item) {
return { label: item.Name, category: item.SearchType, code: item.Code, displayname: item.DisplayName };
}))
}
else {
var result = [{ label: Resources.AutoCompleteNoMatch + request.term, category: 'noresult'}];
response(result);
}
}
})
},
minLength: 2,
select: function(event, ui) {
if (ui.item.category != "noresult") {
if (ui.item.category === "city") { $('#txtWhere').val(ui.item.label); $("#optCategory option:selected").text(''); }
else if (ui.item.category === "category") { $("#optCategory option:selected").text(ui.item.code); $('#txtWhere').val('') }
else if (ui.item.category === "tours") { window.location.href = "/Package/Detail?pCode=" + ui.item.code + "&cCode=" + ui.item.displayname; return false; }
$("input[name=domType]:checked").val($("input[name=domTypeMain]:checked").val());
$("#optMonth option:selected").text(''); $("#optYear option:selected").text('');
$("#hdnSearchType").val(ui.item.category);
$("#hdnDestinationName").val(ui.item.displayname);
$("#hdnDestination").val(ui.item.label);
$("#hdnSearchParam").val(ui.item.code);
$("#frmSearch").submit();
}
return false;
},
appendTo: "#divSearchResults"
});
});
/* Search Autocomplete.....[End]
*/
/* Search Autocomplete.....[Start]
*/
$.widget("custom.catcomplete", $.ui.autocomplete, {
_renderMenu: function(ul, items) {
var that = this,
currentCategory = "";
$.each(items, function(index, item) {
//debugger;
if (item.category != currentCategory) {
if (item.category === "city") {
ul.append("");
}
else if (item.category === "category") {
ul.append("");
}
else if (item.category === "state") {
ul.append("");
}
else if (item.category === "region") {
ul.append("");
}
else if (item.category === "country") {
ul.append("");
}
else if (item.category === "tours") {
ul.append("");
}
else {
ul.append("");
}
currentCategory = item.category;
}
that._renderItemData(ul, item);
});
}
});
$(function() {
$("#txtWhere").catcomplete({
delay: 0,
source: function(request, response) {
$.ajax({
url: '/Home/autoCompleteResults',
type: "POST",
crossDomain: true,
dataType: 'json',
cache: false,
data: { term: request.term, countryCode: 'IN', locationType: $("input[name=domType]:checked").val(), searchType: $("#txtWhere").attr("searchtype") },
success: function(data) {
//debugger;
if (!data || data.length != 0) {
response($.map(data, function(item) {
return { label: item.Name, category: item.SearchType, code: item.Code, displayname: item.DisplayName };
}))
}
else {
var result = [{ label: Resources.AutoCompleteNoMatch + request.term, category: 'noresult'}];
response(result);
}
}
})
},
minLength: 3,
select: function(event, ui) {
// debugger;
if (ui.item.category != "noresult") {
if (ui.item.category === "city") {
$('#txtWhere').val(ui.item.label);
$("input[name=domType]:checked").val($("input[name=domType]:checked").val());
}
else if (ui.item.category === "category") { $("#optCategory option:selected").text(ui.item.label); $('#txtWhere').val(ui.item.label) }
$('#txtWhere').val(ui.item.label);
$("#hdnSearchType").val(ui.item.category);
$("#hdnDestinationName").val(ui.item.displayname);
$("#hdnDestination").val(ui.item.label);
$("#hdnSearchParam").val(ui.item.code);
}
return false;
},
appendTo: "#divSearchWhere"
});
});
/* Search Autocomplete.....[End]
*/
// debugger
$.ajax({
url: '/Home/LoadCategory',
type: "POST",
dataType: "json",
crossDomain: true,
cache: false,
data: {},
success: function(data) {
//debugger;
if (!data || data.length != 0) {
$.each(data, function(key, value) {
$("#optCategory").append($("").val(value.Code).html(value.Name));
});
}
else {
var result = [{ label: Resources.AutoCompleteNoMatch + request.term, category: 'noresult'}];
response(result);
}
}
})
$(".sui_sbutton").click(function() {
$("#frmSearch").submit();
});
});
function SetText(ctrl) {
$('#hdnAdvanceSearchType').val('category');
$('#hdnCategoryName').val(ctrl.options[ctrl.selectedIndex].innerHTML);
$("#hdnAdvanceSearchParam").val($("#optCategory option:selected").val());
}