mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
70130aace3
That'll be #8 wrapped up, plus some more of #7
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
var bfsAjax;
|
|
var bfsTimeout;
|
|
|
|
$(function () {
|
|
$("#page-navigation-search").click(function (event) {
|
|
event.preventDefault();
|
|
$("#search-modal").modal('show');
|
|
});
|
|
$("#search-input").keyup(function () {
|
|
var search = $(this);
|
|
$(this).parent().find(".list-group").remove();
|
|
|
|
if (typeof bfsTimeout != 'undefined')
|
|
{
|
|
clearTimeout(bfsTimeout);
|
|
}
|
|
|
|
if (typeof bfsAjax != 'undefined' && bfsAjax.readyState != 4)
|
|
{
|
|
bfsAjax.abort();
|
|
}
|
|
|
|
bfsTimeout = setTimeout(function (object) {
|
|
bfsAjax = $.ajax("/api/GetSearchResult/?query=" + $("#search-input").val()).done(function (data) {
|
|
var template = $.templates("#result-template");
|
|
var content = $("<div class='list-group'></div>");
|
|
|
|
var item = template.render(data);
|
|
content.append(item);
|
|
|
|
$("#search-results").html(content);
|
|
|
|
$(".panel-search a.list-group-item").click(function () {
|
|
ga('send', 'pageview', '/api/GetSearchResult/?query=' + $("#search-input").val());
|
|
});
|
|
});
|
|
}, 200);
|
|
});
|
|
}); |