From 23900a5a39c45cff90e0056d3d58736ea11553c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 5 Jan 2015 13:11:50 +0100 Subject: [PATCH] filter trashbin and share views --- apps/files/js/filelist.js | 12 ++++++++++++ apps/files/js/search.js | 19 ++++++++++++------- apps/files/templates/simplelist.php | 6 ++++++ apps/files_sharing/templates/list.php | 6 ++++++ apps/files_trashbin/templates/index.php | 6 ++++++ search/js/search.js | 2 +- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 84b537fbdf..768fc77df2 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -214,6 +214,8 @@ this.$el.on('show', this._onResize); + this.updateSearch(); + this.$fileList.on('click','td.filename>a.name', _.bind(this._onClickFile, this)); this.$fileList.on('change', 'td.filename>.selectCheckBox', _.bind(this._onClickFileCheckbox, this)); this.$el.on('urlChanged', _.bind(this._onUrlChanged, this)); @@ -274,6 +276,8 @@ containerWidth -= $('#app-navigation-toggle').width(); this.breadcrumb.setMaxWidth(containerWidth - actionsWidth - 10); + + this.updateSearch(); }, /** @@ -1702,6 +1706,14 @@ getFilter:function(filter) { return this._filter; }, + /** + * update the search object to use this filelist when filtering + */ + updateSearch:function() { + if (OCA.Search.files) { + OCA.Search.files.setFileList(this); + } + }, /** * Update UI based on the current selection */ diff --git a/apps/files/js/search.js b/apps/files/js/search.js index 2c3c42cf49..5fb10ef34c 100644 --- a/apps/files/js/search.js +++ b/apps/files/js/search.js @@ -21,6 +21,8 @@ */ Files.prototype = { + fileList: null, + /** * Initialize the file search */ @@ -32,7 +34,7 @@ return !!OCA.Files && !!OCA.Files.App; }; function inFileList($row, result) { - return self.fileAppLoaded() && OCA.Files.App.fileList.inList(result.name); + return self.fileAppLoaded() && self.fileList.inList(result.name); } function updateLegacyMimetype(result) { // backward compatibility: @@ -79,7 +81,7 @@ $row.find('td.result a').attr('href', result.link); if (self.fileAppLoaded()) { - OCA.Files.App.fileList.lazyLoadPreview({ + self.fileList.lazyLoadPreview({ path: result.path, mime: result.mime, callback: function (url) { @@ -127,7 +129,7 @@ this.handleFolderClick = function($row, result, event) { // open folder if (self.fileAppLoaded()) { - OCA.Files.App.fileList.changeDirectory(result.path); + self.fileList.changeDirectory(result.path); return false; } else { return true; @@ -136,8 +138,8 @@ this.handleFileClick = function($row, result, event) { if (self.fileAppLoaded()) { - OCA.Files.App.fileList.changeDirectory(OC.dirname(result.path)); - OCA.Files.App.fileList.scrollTo(result.name); + self.fileList.changeDirectory(OC.dirname(result.path)); + self.fileList.scrollTo(result.name); return false; } else { return true; @@ -150,6 +152,9 @@ result.mime = result.mime_type; } }; + this.setFileList = function (fileList) { + this.fileList = fileList; + }; OC.Plugins.register('OCA.Search', this); }, @@ -157,7 +162,7 @@ var self = this; search.setFilter('files', function (query) { if (self.fileAppLoaded()) { - OCA.Files.App.fileList.setFilter(query); + self.fileList.setFilter(query); if (query.length > 2) { //search is not started until 500msec have passed window.setTimeout(function() { @@ -176,6 +181,6 @@ search.setHandler(['file', 'audio', 'image'], this.handleFileClick.bind(this)); } }; - new Files(); OCA.Search.Files = Files; + OCA.Search.files = new Files(); })(); diff --git a/apps/files/templates/simplelist.php b/apps/files/templates/simplelist.php index d806a220ac..15bbfbb292 100644 --- a/apps/files/templates/simplelist.php +++ b/apps/files/templates/simplelist.php @@ -11,6 +11,12 @@ + + diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php index a1d95ebc1f..f9a6257dff 100644 --- a/apps/files_sharing/templates/list.php +++ b/apps/files_sharing/templates/list.php @@ -8,6 +8,12 @@ + +
diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index fe1311340c..b89ec66b15 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -12,6 +12,12 @@ + +
diff --git a/search/js/search.js b/search/js/search.js index 078fe4f82b..d8922cf167 100644 --- a/search/js/search.js +++ b/search/js/search.js @@ -165,7 +165,7 @@ function showResults(results) { lastResults = results; $searchResults.find('tr.result').remove(); - $searchResults.show(); + $searchResults.removeClass('hidden'); addResults(results); } function addResults(results) {