use path param to create scrollto url

This commit is contained in:
Jörn Friedrich Dreyer 2013-09-19 16:15:17 +02:00
parent 9b63f945e3
commit 3510674d24
1 changed files with 16 additions and 11 deletions

View File

@ -57,22 +57,26 @@ OC.search.showResults=function(results){
var row=$('#searchresults tr.template').clone(); var row=$('#searchresults tr.template').clone();
row.removeClass('template'); row.removeClass('template');
row.addClass('result'); row.addClass('result');
row.data('type', typeid); row.data('type', typeid);
row.data('name', type[i].name); row.data('name', type[i].name);
row.data('text', type[i].text); row.data('text', type[i].text);
row.data('container', type[i].container); row.data('index',index);
if (i === 0){ if (i === 0){
row.children('td.type').text(typeid); row.children('td.type').text(typeid);
} }
row.find('td.result div.name').text(type[i].name); row.find('td.result div.name').text(type[i].name);
row.find('td.result div.text').text(type[i].text); row.find('td.result div.text').text(type[i].text);
if (type[i].container) {
var containerName = OC.basename(type[i].container); if (type[i].path) {
var parent = OC.dirname(type[i].path);
var containerName = OC.basename(parent);
if (containerName === '') { if (containerName === '') {
containerName = '/'; containerName = '/';
} }
var containerLink = OC.linkTo('files', 'index.php') var containerLink = OC.linkTo('files', 'index.php')
+'?dir='+encodeURIComponent(type[i].container) +'?dir='+encodeURIComponent(parent)
+'&scrollto='+encodeURIComponent(type[i].name); +'&scrollto='+encodeURIComponent(type[i].name);
row.find('td.result a') row.find('td.result a')
.attr('href', containerLink) .attr('href', containerLink)
@ -80,9 +84,10 @@ OC.search.showResults=function(results){
} else { } else {
row.find('td.result a').attr('href', type[i].link); row.find('td.result a').attr('href', type[i].link);
} }
row.data('index',index);
index++; index++;
if(OC.search.customResults[typeid]){//give plugins the ability to customize the entries in here //give plugins the ability to customize the entries in here
if(OC.search.customResults[typeid]){
OC.search.customResults[typeid](row, type[i]); OC.search.customResults[typeid](row, type[i]);
} }
$('#searchresults tbody').append(row); $('#searchresults tbody').append(row);
@ -114,19 +119,19 @@ OC.search.customResults.file = function (row, item) {
if(row.children('td.type').text() === 'file') { if(row.children('td.type').text() === 'file') {
row.children('td.type').text(t('lib','Files')); row.children('td.type').text(t('lib','Files'));
}; };
} };
OC.search.customResults.folder = function (row, item) { OC.search.customResults.folder = function (row, item) {
if(row.children('td.type').text() === 'folder') { if(row.children('td.type').text() === 'folder') {
row.children('td.type').text(t('lib','Folders')); row.children('td.type').text(t('lib','Folders'));
}; };
} };
OC.search.customResults.image = function (row, item) { OC.search.customResults.image = function (row, item) {
if(row.children('td.type').text() === 'image') { if(row.children('td.type').text() === 'image') {
row.children('td.type').text(t('lib','Images')); row.children('td.type').text(t('lib','Images'));
}; };
} };
OC.search.customResults.audio = function (row, item) { OC.search.customResults.audio = function (row, item) {
if(row.children('td.type').text() === 'audio') { if(row.children('td.type').text() === 'audio') {
row.children('td.type').text(t('lib','Audio')); row.children('td.type').text(t('lib','Audio'));
}; };
} };