Update site search js and add .ruby-version to .gitignore
This commit is contained in:
parent
3c95f053ab
commit
d23a956085
|
@ -25,3 +25,4 @@ uploads/**/*
|
|||
config/mongoid.yml
|
||||
*.
|
||||
sftp-config.json
|
||||
.ruby-version
|
|
@ -7,34 +7,36 @@
|
|||
<div id='search_footer'></div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
var Search = function(){
|
||||
var s = this;
|
||||
var interval = 0;
|
||||
var keyword;
|
||||
var processLock=false;
|
||||
this.init = function(){
|
||||
$("#q").keyup(function(){s.queueSearch();});
|
||||
$("#search_form").submit(function(){s.queueSearch(); return false; });
|
||||
$("#search_close").click(function(){$("#search_container").fadeOut(300);});
|
||||
}
|
||||
|
||||
$("#q").keyup(function(){queueSearch();});
|
||||
$("#search_form").submit(function(){queueSearch(); return false; });
|
||||
|
||||
function queueSearch(){
|
||||
this.queueSearch = function(){
|
||||
if($("#q").val() != keyword && $("#q").val()!=""){
|
||||
keyword = $("#q").val();
|
||||
interval=500;
|
||||
if(!processLock) processSearch();
|
||||
if(!processLock) s.processSearch();
|
||||
}else if($("#q").val()==""){
|
||||
keyword = ""
|
||||
$("#search_container").fadeOut(300);
|
||||
}
|
||||
}
|
||||
|
||||
$("#search_close").click(function(){$("#search_container").fadeOut(300);});
|
||||
|
||||
function processSearch(){
|
||||
this.processSearch = function(){
|
||||
keyword_tmp = keyword;
|
||||
processLock = true;
|
||||
if(interval==0 && keyword!=""){
|
||||
$.getJSON("/site_search?keywords="+keyword, function(data){
|
||||
$.getJSON("/site_search", {"keywords" : keyword}, function(data){
|
||||
if(keyword_tmp != keyword) {
|
||||
processLock = false;
|
||||
processSearch();
|
||||
s.processSearch();
|
||||
return;
|
||||
}
|
||||
$("#search_results").scrollTop(0);
|
||||
|
@ -55,7 +57,10 @@
|
|||
});
|
||||
}else if(interval>0){
|
||||
interval -= 100;
|
||||
setTimeout(processSearch,100);
|
||||
setTimeout(s.processSearch,100);
|
||||
}
|
||||
}
|
||||
s.init();
|
||||
}();
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue