” + “”);
that.currentCategory = item.category;
dirCssClass = (dirCssClass === ”) ? ‘ right’ : ”;
}
that._renderItem(ul, item);
cnt++;
});
if (cnt > 0) { ul.append(“
“); }
},
_renderItem: function (ul, item) {
var term = this.term;
var formattedLabel = item.description.replace(new RegExp(‘(‘ + term + ‘)’, ‘ig’), function ($1, match) { return ‘‘ + match + ‘‘; });
var t = (item.typeName) ? item.typeName : ” “;
t = (item.typeUrl) ? “” + t + “” : t;
return $(“
.data(“item.autocomplete”, item)
.append(“
” + ((item.tag1) ? item.tag1 : ” “) + “
” + ((item.tag2) ? item.tag2 : ” “) + “
” + “
” + t + “
“)
.appendTo(ul);
}
});
$(“#ctl00_ctlFooterMenu_ctlSearch_txtSearch”).catcomplete({
delay: 2000,
minLength: 2,
html: true,
position: { my: “right top”, at: “right bottom+1”, of: “#ctl00_ctlFooterMenu_ctlSearch_btnSearch”, collision: “none” },
appendTo: ‘div.page’,
source: function (request, response) {
var term = request.term.toLowerCase(),
element = this.element,
cache = this.element.data(‘autocompleteCache’) || {},
queue = this.element.data(‘autocompleteQueue’) || {};
if (term in cache || term in queue) {
response(cache[term]);
return;
}
console.log(“Ajax call.”);
$.ajax({
url: ‘/Ajax/Search/AutoComplete.aspx’,
dataType: “json”,
data: { q: request.term },
success: function (data) {
cache[term] = data;
element.data(‘autocompleteCache’, cache);
delete queue[term];
element.data(‘autocompleteQueue’, queue);
response(data);
}
});
},
select: function (event, ui) {
if (!ui.item) { return; }
if (ui.item.exact) {
window.location.href = ui.item.href;
return;
}
else {
if (ui.item.value === ‘close’) { $(“#ctl00_ctlFooterMenu_ctlSearch_txtSearch”).autocomplete(“close”); }
else { window.location.href = ‘/Search/’ + ‘?q=’ + ui.item.value; }
}
},
open: function (event, ui) { /* $(this).catcomplete(‘widget’).width(‘800px’); */ },
close: function (event, ui) { }
});
$(‘#ctl00_ctlFooterMenu_ctlSearch_btnSearch’).click(function(){
var _text = $(“#ctl00_ctlFooterMenu_ctlSearch_txtSearch”).val();
if (_text.length > 2) window.location.href = ‘/Search/’ + ‘?q=’ + _text;
return false;
});
});