aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/search.js
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-12-18 10:26:41 +0100
committerJörn Friedrich Dreyer <jfd@butonic.de>2015-01-02 10:28:41 +0100
commit7e6c660b008d158de92a664b56359ed0750b82a8 (patch)
treee47dba072d47b84fc087c6d1aaec8f1664fc4c77 /apps/files/js/search.js
parentd063c8e0429b680c9998f91075b18297f55ae62d (diff)
downloadnextcloud-server-7e6c660b008d158de92a664b56359ed0750b82a8.tar.gz
nextcloud-server-7e6c660b008d158de92a664b56359ed0750b82a8.zip
filter new rows
Diffstat (limited to 'apps/files/js/search.js')
-rw-r--r--apps/files/js/search.js44
1 files changed, 34 insertions, 10 deletions
diff --git a/apps/files/js/search.js b/apps/files/js/search.js
index a2d3a261259..e6d71cf0f60 100644
--- a/apps/files/js/search.js
+++ b/apps/files/js/search.js
@@ -14,12 +14,10 @@
OCA.Files.Search = {
attach: function(search) {
search.setFilter('files', function (query) {
- if (query) {
- if (OCA.Files) {
- OCA.Files.App.fileList.filter(query);
- }
- } else {
- if (OCA.Files) {
+ if (OCA.Files.Search.fileAppLoaded()) {
+ if (query) {
+ OCA.Files.App.fileList.setFilter(query);
+ } else {
OCA.Files.App.fileList.unfilter();
}
}
@@ -34,6 +32,9 @@
search.setHandler(['file', 'audio', 'image'], OCA.Files.Search.handleFileClick);
},
renderFolderResult: function($row, result) {
+ if (OCA.Files.Search.inFileList($row, result)) {
+ return null;
+ }
/*render folder icon, show path beneath filename,
show size and last modified date on the right */
// backward compatibility:
@@ -43,13 +44,17 @@
result.mime = result.mime_type;
}
- var $pathDiv = $('<div class="path"></div>').text(result.path)
+ var $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);
$row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/folder') + ')');
+ return $row;
},
renderFileResult: function($row, result) {
+ if (OCA.Files.Search.inFileList($row, result)) {
+ return null;
+ }
/*render preview icon, show path beneath filename,
show size and last modified date on the right */
// backward compatibility:
@@ -64,7 +69,7 @@
$row.find('td.result a').attr('href', result.link);
- if (OCA.Files) {
+ if (OCA.Files.Search.fileAppLoaded()) {
OCA.Files.App.fileList.lazyLoadPreview({
path: result.path,
mime: result.mime,
@@ -84,20 +89,36 @@
OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', {dir: dir, scrollto: result.name})
);
}
+ return $row;
},
renderAudioResult: function($row, result) {
+ if (OCA.Files.Search.inFileList($row, result)) {
+ return null;
+ }
/*render preview icon, show path beneath filename,
show size and last modified date on the right
show Artist and Album */
+ return $row;
},
renderImageResult: function($row, result) {
+ if (OCA.Files.Search.inFileList($row, result)) {
+ return null;
+ }
/*render preview icon, show path beneath filename,
show size and last modified date on the right
show width and height */
+ return $row;
+ },
+ inFileList: function($row, result){
+ if (OCA.Files.Search.fileAppLoaded() && OCA.Files.App.fileList.inList(result.name)) {
+ return true;
+ } else {
+ return false;
+ }
},
handleFolderClick: function($row, result, event) {
// open folder
- if (OCA.Files) {
+ if (OCA.Files.Search.fileAppLoaded()) {
OCA.Files.App.fileList.changeDirectory(result.path);
return false;
} else {
@@ -105,13 +126,16 @@
}
},
handleFileClick: function($row, result, event) {
- if (OCA.Files) {
+ if (OCA.Files.Search.fileAppLoaded()) {
OCA.Files.App.fileList.changeDirectory(OC.dirname(result.path));
OCA.Files.App.fileList.scrollTo(result.name);
return false;
} else {
return true;
}
+ },
+ fileAppLoaded: function() {
+ return OCA.Files && OCA.Files.App;
}
};
})();