summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-02-06 23:51:17 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-02-06 23:51:17 -0300
commitc59a6b2b869beae6595b8d0b35e582264712032c (patch)
tree90fee323020aa3de6cf07e55ed8aebe78d47522c
parent3b5b886c5b3b0cfaa25044e3fb8210e59d35b7dc (diff)
downloadaskbot-c59a6b2b869beae6595b8d0b35e582264712032c.tar.gz
askbot-c59a6b2b869beae6595b8d0b35e582264712032c.tar.bz2
askbot-c59a6b2b869beae6595b8d0b35e582264712032c.zip
improved behavior of the search bar
-rw-r--r--askbot/media/js/live_search.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/askbot/media/js/live_search.js b/askbot/media/js/live_search.js
index a0c7c2de..9c47ab31 100644
--- a/askbot/media/js/live_search.js
+++ b/askbot/media/js/live_search.js
@@ -744,6 +744,7 @@ FullTextSearch.prototype.updateToolTip = function() {
/**
* keydown handler operates on the tooltip and the X button
+ * also opens and closes drop menu according to the min search word threshold
* keyup is not good enough, because in that case
* tooltip will be displayed with the input box simultaneously
*/
@@ -765,14 +766,23 @@ FullTextSearch.prototype.makeKeyDownHandler = function() {
var query = me.getSearchQuery();
if (query.length === 0) {
if (keyCode !== 8 && keyCode !== 48) {//del and backspace
- toolTip.hide();
- dropMenu.show();
- dropMenu.showWaitIcon();
- //xButton.show();//causes a jump of search input...
+ toolTip.hide();//hide tooltip
}
} else {
me.updateToolTip();
me.refreshXButton();
+ var minQueryLength = askbot['settings']['minSearchWordLength'];
+ if (query.length === minQueryLength) {
+ if (keyCode !== 8 && keyCode !== 48) {//del and backspace
+ /* we get here if we were expanding the query
+ past the minimum length to trigger search */
+ dropMenu.show();
+ dropMenu.showWaitIcon();
+ } else {
+ //close drop menu if we were deleting the query
+ dropMenu.reset();
+ }
+ }
}
};
};