Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
add missing search.js
Browse files Browse the repository at this point in the history
  • Loading branch information
butonic authored and VicDeo committed May 26, 2015
1 parent 6eed05b commit fd670b8
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions js/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(function() {
OCA.Search.Lucene = {
attach: function(search) {

search.setRenderer('lucene', OCA.Search.Lucene.renderFileResult);
search.setHandler('lucene', OCA.Search.Lucene.handleFileClick);
},
renderFileResult: function($row, result) {
var $fileResultRow = OCA.Search.files.renderFileResult($row, result);
if (!$fileResultRow && result.name.toLowerCase().indexOf(OC.Search.getLastQuery()) === -1) {
/*render preview icon, show path beneath filename,
show size and last modified date on the right */

$pathDiv = $('<div class="path"></div>').text(result.path);
$row.find('td.info div.name').after($pathDiv).text(result.name);

$row.find('td.result a').attr('href', result.link);

if (OCA.Search.files.fileAppLoaded()) {
OCA.Files.App.fileList.lazyLoadPreview({
path: result.path,
mime: result.mime,
callback: function (url) {
$row.find('td.icon').css('background-image', 'url(' + url + ')');
}
});
} else {
// FIXME how to get mime icon if not in files app
var mimeicon = result.mime.replace('/', '-');
$row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/' + mimeicon) + ')');
var dir = OC.dirname(result.path);
if (dir === '') {
dir = '/';
}
$row.find('td.info a').attr('href',
OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', {dir: dir, scrollto: result.name})
);
}
$fileResultRow = $row;
}
if ($fileResultRow && typeof result.highlights === 'object') {
var highlights = result.highlights.join(' … ');
var $highlightsDiv = $('<div class="highlights"></div>').html(highlights);
$row.find('td.info div.path').after($highlightsDiv);
}
return $fileResultRow;
},
handleFileClick: function($row, result, event) {
OCA.Search.files.handleFileClick($row, result, event);
}
};
})();

OC.Plugins.register('OCA.Search', OCA.Search.Lucene);

0 comments on commit fd670b8

Please sign in to comment.