Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-11-18 17:18:08 +0400
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-11-18 17:18:08 +0400
commitcb656c8321e71812809044c19525bf0b9a639b2c (patch)
tree68db8641d168fa0076a34d0c22778bd2c891df13 /search
parent477e3a8b87f9a3df3bfd6f4e457971f32a3e5fe8 (diff)
backport search scrollto & filter to stable5
Diffstat (limited to 'search')
-rw-r--r--search/js/result.js55
1 files changed, 44 insertions, 11 deletions
diff --git a/search/js/result.js b/search/js/result.js
index 78fa8efc8e9..2bad993f4a4 100644
--- a/search/js/result.js
+++ b/search/js/result.js
@@ -8,15 +8,23 @@ OC.search.catagorizeResults=function(results){
types[type].push(results[i]);
}
return types;
-}
+};
OC.search.hide=function(){
$('#searchresults').hide();
if($('#searchbox').val().length>2){
$('#searchbox').val('');
+ if (FileList && typeof FileList.unfilter === 'function') { //TODO add hook system
+ FileList.unfilter();
+ }
};
+ if ($('#searchbox').val().length === 0) {
+ if (FileList && typeof FileList.unfilter === 'function') { //TODO add hook system
+ FileList.unfilter();
}
+ }
+};
OC.search.showResults=function(results){
- if(results.length==0){
+ if(results.length === 0){
return;
}
if(!OC.search.showResults.loaded){
@@ -30,6 +38,9 @@ OC.search.showResults=function(results){
});
$(document).click(function(event){
OC.search.hide();
+ if (FileList && typeof FileList.unfilter === 'function') { //TODO add hook system
+ FileList.unfilter();
+ }
});
OC.search.lastResults=results;
OC.search.showResults(results);
@@ -39,30 +50,52 @@ OC.search.showResults=function(results){
$('#searchresults').show();
$('#searchresults tr.result').remove();
var index=0;
- for(var name in types){
- var type=types[name];
+ for(var typeid in types){
+ var type=types[typeid];
if(type.length>0){
for(var i=0;i<type.length;i++){
var row=$('#searchresults tr.template').clone();
row.removeClass('template');
row.addClass('result');
- if (i == 0){
- row.children('td.type').text(name);
+ row.data('type', typeid);
+ row.data('name', type[i].name);
+ row.data('text', type[i].text);
+ row.data('container', type[i].container);
+ if (i === 0){
+ row.children('td.type').text(typeid);
}
- row.find('td.result a').attr('href',type[i].link);
row.find('td.result div.name').text(type[i].name);
row.find('td.result div.text').text(type[i].text);
+ if (type[i].container) {
+ var containerName = OC.basename(type[i].container);
+ if (containerName === '') {
+ containerName = '/';
+ }
+ var containerLink = OC.linkTo('files', 'index.php')
+ +'?dir='+encodeURIComponent(type[i].container)
+ +'&scrollto='+encodeURIComponent(type[i].name);
+ row.find('td.result a')
+ .attr('href', containerLink)
+ .attr('title', t('core', 'Show in {folder}', {folder: containerName}));
+ } else {
+ row.find('td.result a').attr('href', type[i].link);
+ }
row.data('index',index);
index++;
- if(OC.search.customResults[name]){//give plugins the ability to customize the entries in here
- OC.search.customResults[name](row,type[i]);
+ if(OC.search.customResults[typeid]){//give plugins the ability to customize the entries in here
+ OC.search.customResults[typeid](row,type[i]);
}
$('#searchresults tbody').append(row);
}
}
}
+ $('#searchresults').on('click', 'result', function () {
+ if ($(this).data('type') === 'Files') {
+ //FIXME use ajax to navigate to folder & highlight file
+ }
+ });
}
-}
+};
OC.search.showResults.loaded=false;
OC.search.renderCurrent=function(){
@@ -71,4 +104,4 @@ OC.search.renderCurrent=function(){
$('#searchresults tr.result').removeClass('current');
$(result).addClass('current');
}
-}
+};