aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/css/files.css4
-rw-r--r--apps/files/index.php1
-rw-r--r--apps/files/js/filelist.js15
-rw-r--r--apps/files/js/search.js118
4 files changed, 124 insertions, 14 deletions
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 6f31715499b..a75ad57c833 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -540,7 +540,7 @@ a.action>img {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
opacity: .3;
- height: 70px;
+ height: 60px;
}
.summary:hover,
@@ -551,8 +551,6 @@ table tr.summary td {
}
.summary td {
- padding-top: 20px;
- padding-bottom: 150px;
border-bottom: none;
}
.summary .info {
diff --git a/apps/files/index.php b/apps/files/index.php
index 64b49c3bf1f..767cb156ca2 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -38,6 +38,7 @@ OCP\Util::addscript('files', 'jquery-visibility');
OCP\Util::addscript('files', 'filesummary');
OCP\Util::addscript('files', 'breadcrumb');
OCP\Util::addscript('files', 'filelist');
+OCP\Util::addscript('files', 'search');
\OCP\Util::addScript('files', 'favoritesfilelist');
\OCP\Util::addScript('files', 'tagsplugin');
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 09cb3d3287d..08017e3fef1 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1640,21 +1640,14 @@
},
filter:function(query) {
this.$fileList.find('tr').each(function(i,e) {
- if ($(e).data('file').toString().toLowerCase().indexOf(query.toLowerCase()) !== -1) {
- $(e).addClass("searchresult");
- } else {
- $(e).removeClass("searchresult");
+ if ($(e).data('file').toString().toLowerCase().indexOf(query.toLowerCase()) === -1) {
+ $(e).hide();
}
});
- //do not use scrollto to prevent removing searchresult css class
- var first = this.$fileList.find('tr.searchresult').first();
- if (first.exists()) {
- $(window).scrollTop(first.position().top);
- }
},
unfilter:function() {
- this.$fileList.find('tr.searchresult').each(function(i,e) {
- $(e).removeClass("searchresult");
+ this.$fileList.find('tr:hidden').each(function(i,e) {
+ $(e).show();
});
},
/**
diff --git a/apps/files/js/search.js b/apps/files/js/search.js
new file mode 100644
index 00000000000..a2d3a261259
--- /dev/null
+++ b/apps/files/js/search.js
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+(function() {
+ if (!OCA.Files) {
+ OCA.Files = {};
+ }
+ 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) {
+ OCA.Files.App.fileList.unfilter();
+ }
+ }
+ });
+
+ search.setRenderer('folder', OCA.Files.Search.renderFolderResult);
+ search.setRenderer('file', OCA.Files.Search.renderFileResult);
+ search.setRenderer('audio', OCA.Files.Search.renderAudioResult);
+ search.setRenderer('image', OCA.Files.Search.renderImageResult);
+
+ search.setHandler('folder', OCA.Files.Search.handleFolderClick);
+ search.setHandler(['file', 'audio', 'image'], OCA.Files.Search.handleFileClick);
+ },
+ renderFolderResult: function($row, result) {
+ /*render folder icon, show path beneath filename,
+ show size and last modified date on the right */
+ // backward compatibility:
+ if (typeof result.mime !== 'undefined') {
+ result.mime_type = result.mime;
+ } else if (typeof result.mime_type !== 'undefined') {
+ result.mime = result.mime_type;
+ }
+
+ 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') + ')');
+ },
+ renderFileResult: function($row, result) {
+ /*render preview icon, show path beneath filename,
+ show size and last modified date on the right */
+ // backward compatibility:
+ if (typeof result.mime !== 'undefined') {
+ result.mime_type = result.mime;
+ } else if (typeof result.mime_type !== 'undefined') {
+ result.mime = result.mime_type;
+ }
+
+ $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.Files) {
+ 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})
+ );
+ }
+ },
+ renderAudioResult: function($row, result) {
+ /*render preview icon, show path beneath filename,
+ show size and last modified date on the right
+ show Artist and Album */
+ },
+ renderImageResult: function($row, result) {
+ /*render preview icon, show path beneath filename,
+ show size and last modified date on the right
+ show width and height */
+ },
+ handleFolderClick: function($row, result, event) {
+ // open folder
+ if (OCA.Files) {
+ OCA.Files.App.fileList.changeDirectory(result.path);
+ return false;
+ } else {
+ return true;
+ }
+ },
+ handleFileClick: function($row, result, event) {
+ if (OCA.Files) {
+ OCA.Files.App.fileList.changeDirectory(OC.dirname(result.path));
+ OCA.Files.App.fileList.scrollTo(result.name);
+ return false;
+ } else {
+ return true;
+ }
+ }
+ };
+})();
+OC.Plugins.register('OCA.Search', OCA.Files.Search);