summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-26 22:06:33 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-26 22:06:33 -0300
commite94fc0a5d07653fb0c03e3d6f820ee8b5ee2e5f7 (patch)
tree46ef51f87f701e81d0ada022fd2ca5a8fa0b372c
parent46526ef93e87cd4ac1e75f760543688751981300 (diff)
downloadaskbot-e94fc0a5d07653fb0c03e3d6f820ee8b5ee2e5f7.tar.gz
askbot-e94fc0a5d07653fb0c03e3d6f820ee8b5ee2e5f7.tar.bz2
askbot-e94fc0a5d07653fb0c03e3d6f820ee8b5ee2e5f7.zip
recovered the full text search function
-rw-r--r--askbot/media/js/live_search.js34
-rw-r--r--askbot/media/js/utils.js12
-rw-r--r--askbot/templates/meta/bottom_scripts.html1
3 files changed, 28 insertions, 19 deletions
diff --git a/askbot/media/js/live_search.js b/askbot/media/js/live_search.js
index 5dffb677..5f536844 100644
--- a/askbot/media/js/live_search.js
+++ b/askbot/media/js/live_search.js
@@ -745,6 +745,19 @@ FullTextSearch.prototype.makeKeyDownHandler = function() {
};
};
+FullTextSearch.prototype.makeFormSubmitHandler = function() {
+ var me = this;
+ var baseUrl = me._baseUrl;
+ return function(evt) {
+ // if user clicks the button the s(h)e probably wants page reload,
+ // so provide that experience but first update the query string
+ me.updateQueryString();
+ var searchUrl = me.getSearchUrl();
+ evt.preventDefault();
+ window.location.href = baseUrl + searchUrl;
+ };
+};
+
FullTextSearch.prototype.decorate = function(element) {
this._element = element;/* this is a bit artificial we don't use _element */
this._query = element;
@@ -757,6 +770,10 @@ FullTextSearch.prototype.decorate = function(element) {
element.focus();
});
this._element.after(toolTip.getElement());
+ //below is called after getElement, b/c element must be defined
+ if (this._prevText !== '') {
+ toolTip.hide();//hide if search query is not empty
+ }
this._toolTip = toolTip;
var dropMenu = new SearchDropMenu();
@@ -765,11 +782,8 @@ FullTextSearch.prototype.decorate = function(element) {
this._dropMenu = dropMenu;
element.parent().after(this._dropMenu.getElement());
- var menuCloser = function(){
- dropMenu.reset();
- };
- $(element).click(function(e){ return false });
- $(document).click(menuCloser);
+ $(element).click(function(e) { return false });
+ $(document).click(function() { dropMenu.reset(); });
//the tag search input is optional in askbot
$('#ab-tag-search').parent().before(
@@ -815,13 +829,5 @@ FullTextSearch.prototype.decorate = function(element) {
this.activateTagSearchInput();
- var baseUrl = this._baseUrl;
- var searchUrl = this.getSearchUrl();
- $("form#searchForm").submit(function(event) {
- // if user clicks the button the s(h)e probably wants page reload,
- // so provide that experience but first update the query string
- event.preventDefault();
- me.updateQueryString();
- window.location.href = baseUrl + searchUrl;
- });
+ $("form#searchForm").submit(me.makeFormSubmitHandler());
};
diff --git a/askbot/media/js/utils.js b/askbot/media/js/utils.js
index 6ea23566..4340c78b 100644
--- a/askbot/media/js/utils.js
+++ b/askbot/media/js/utils.js
@@ -128,15 +128,16 @@ var setupButtonEventHandlers = function(button, callback){
var putCursorAtEnd = function(element){
- var el = element.get()[0];
+ var el = $(element).get()[0];
+ var jEl = $(el);
if (el.setSelectionRange){
- var len = element.val().length * 2;
+ var len = jEl.val().length * 2;
el.setSelectionRange(len, len);
}
else{
- element.val(element.val());
+ jEl.val(jEl.val());
}
- element.scrollTop = 999999;
+ jEl.scrollTop(999999);
};
var setCheckBoxesIn = function(selector, value){
@@ -213,7 +214,8 @@ QSutils.patch_query_string = function (query_string, patch, remove) {
var mapping = {};
if(!remove) {
- mapping[patch_split[0]] = patch_split[1]; // prepopulate the patched selector if it's not meant to be removed
+ // prepopulate the patched selector if it's not meant to be removed
+ mapping[patch_split[0]] = patch_split[1];
}
for (var i = 0; i < params.length; i++) {
diff --git a/askbot/templates/meta/bottom_scripts.html b/askbot/templates/meta/bottom_scripts.html
index 24c2ba10..9d535a2b 100644
--- a/askbot/templates/meta/bottom_scripts.html
+++ b/askbot/templates/meta/bottom_scripts.html
@@ -67,6 +67,7 @@
if (searchInput) {
searchInput.focus();
+ putCursorAtEnd(searchInput);
}
{% if active_tab in ('questions', 'badges', 'ask') %}