Commits (3)
......@@ -24,14 +24,14 @@ Search.prototype.init = function() {
this.initComponents();
this.bindEvents();
__translator.getTranslations(search.queryHandler.doSearchDelayed());
__translator.getTranslations(search.queryHandler.doSearchDelayed(true));
};
Search.prototype.bindEvents = function() {
$("#btn-exec-search").click(function() { search.queryHandler.doSearch(); });
$("#explain").change(function() { search.queryHandler.doSearch(); });
$('#expression').keyup(function (e) { if (e.which==13) { search.queryHandler.doSearch(); }});
$("#btn-exec-search").click(function() { search.search(true); });
$("#explain").change(function() { search.search(); });
$('#expression').keyup(function (e) { if (e.which==13) { search.search(true); }});
$("#size").bind("slider:changed", function (event, data) {
$("#size_shown").text(data.value);
......@@ -76,8 +76,12 @@ Search.prototype.getSelectedSourceIds = function() {
return this.sourceSelection.getSelectedSourceIds();
};
Search.prototype.search = function() {
//this.queryHandler.doSearch();
Search.prototype.search = function(immediately) {
if (immediately===true) {
this.queryHandler.doSearch();
} else {
this.queryHandler.doSearchDelayed();
}
};
Search.prototype.metasearch = function(sourceIds, isShowMore) {
......
......@@ -161,19 +161,26 @@ QueryHandler.prototype.removeSearchFacet = function(control) {
this.reorderFacets();
};
QueryHandler.prototype.doSearch = function(isShowMore) {
QueryHandler.prototype.doSearch = function(isShowMore, initSearch) {
if (isShowMore===null || isShowMore===undefined) {
isShowMore=false;
}
this.query = this.buildQuery(isShowMore);
this.imageQueue = [];
$(".wordcloud").text("");
this.clouds = [];
var _this = this;
if (this.query!==null) {
$(".wordcloud").text("");
this.clouds = [];
$("#search-loading-indicator").removeClass("fade");
// Leave notifications in place for first execution of search
if (initSearch!==true) {
$("#search-notifications-container").hide();
$("#search-notifications-container").text("");
}
$.ajax({
url: __util.getBaseUrl() + "query/",
type: "POST",
......@@ -196,16 +203,16 @@ QueryHandler.prototype.doSearch = function(isShowMore) {
};
QueryHandler.prototype.doSearchDelayed = function() {
QueryHandler.prototype.doSearchDelayed = function(initSearch) {
var ts = new Date();
search.queryHandler.lastDelayedQueryTs = ts;
setTimeout(function() { search.queryHandler.delaySearch(ts); }, 1000);
setTimeout(function() { search.queryHandler.delaySearch(ts, initSearch); }, 1000);
};
QueryHandler.prototype.delaySearch = function(timestamp) {
QueryHandler.prototype.delaySearch = function(timestamp, initSearch) {
if (timestamp===this.lastDelayedQueryTs) {
this.lastDelayedQueryTs = null;
this.doSearch();
this.doSearch(false, initSearch);
}
};
......
......@@ -42,6 +42,7 @@ SourceSelection.prototype.handleSelection = function() {
});
}
this.renderDatasourceList();
console.log(search);
if (search!==undefined && search.search!==undefined) {
search.search();
}
......