diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-07-30 21:18:54 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-07-30 21:18:54 +0200 |
commit | aa08196c32894333b14570348446463385058c94 (patch) | |
tree | 32e32e166a2b623cff39085c926c8cf52b398a14 /core/js | |
parent | d2d77b2a481a63cb5b7346ab26565edefdc7f901 (diff) | |
download | nextcloud-server-aa08196c32894333b14570348446463385058c94.tar.gz nextcloud-server-aa08196c32894333b14570348446463385058c94.zip |
some interface work on instant search
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/js.js | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/core/js/js.js b/core/js/js.js index fbc014006b0..f85331db60a 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -54,6 +54,10 @@ OC={ }else{ $.getScript(path); } + }else{ + if(ready){ + ready(); + } } }, addStyle:function(app,style){ @@ -66,45 +70,16 @@ OC={ }, search:function(query){ if(query){ - OC.addStyle('search','results'); - $.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), OC.search.showResults); + OC.addScript('search','result',function(){ + OC.addStyle('search','results'); + $.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), OC.search.showResults); + }); } } } OC.addStyle.loaded=[]; OC.addScript.loaded=[]; -OC.search.catagorizeResults=function(results){ - var types={}; - for(var i=0;i<results.length;i++){ - var type=results[i].type; - if(!types[type]){ - types[type]=[]; - } - types[type].push(results[i]); - } - return types; -} -OC.search.showResults=function(results){ - var types=OC.search.catagorizeResults(results); - $('#searchresults').remove(); - var ul=$('<ul id="searchresults"><ul>'); - for(var name in types){ - var type=types[name]; - if(type.length>0){ - ul.append($('<li class="type">'+name+'</li>')); - for(var i=0;i<type.length;i++){ - var item=type[i]; - var li=($('<li class="'+name+'"></li>')); - li.append($('<a href="'+item.link+'">'+item.name+'</a>')); - li.append($('<span class="text">'+item.text+'</span>')); - ul.append(li); - } - } - } - $('body').append(ul); -} - if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp*/) { var len = this.length >>> 0; @@ -162,7 +137,9 @@ $(document).ready(function(){ if(query.length>2){ OC.search(query); }else{ - $('#searchresults').remove(); + if(OC.search.hide){ + OC.search.hide(); + } } }); $('#searchbox').click(function(){$('#searchbox').trigger('keyup')}); |