diff options
-rw-r--r-- | apps/files/js/filelist.js | 9 | ||||
-rw-r--r-- | apps/files/js/filesummary.js | 32 | ||||
-rw-r--r-- | apps/files/js/search.js | 7 | ||||
-rw-r--r-- | search/js/search.js | 2 |
4 files changed, 41 insertions, 9 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 88c81fb43af..910441bf267 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1668,6 +1668,8 @@ */ setFilter:function(filter) { this._filter = filter; + this.fileSummary.setFilter(filter, this.files); + this.hideHeaderWhenNoFilesMatch(); var that = this; this.$fileList.find('tr').each(function(i,e) { var $e = $(e); @@ -1679,6 +1681,13 @@ } }); }, + hideHeaderWhenNoFilesMatch:function() { + if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) { + this.$el.find('#filestable thead th').addClass('hidden'); + } else { + this.$el.find('#filestable thead th').removeClass('hidden'); + } + }, /** * get the current filter * @param filter diff --git a/apps/files/js/filesummary.js b/apps/files/js/filesummary.js index f83eb54678b..d73fd59cb81 100644 --- a/apps/files/js/filesummary.js +++ b/apps/files/js/filesummary.js @@ -39,7 +39,8 @@ summary: { totalFiles: 0, totalDirs: 0, - totalSize: 0 + totalSize: 0, + filter:'' }, /** @@ -48,6 +49,9 @@ * @param update whether to update the display */ add: function(file, update) { + if (file.name.toLowerCase().indexOf(this.summary.filter) === -1) { + return; + } if (file.type === 'dir' || file.mime === 'httpd/unix-directory') { this.summary.totalDirs++; } @@ -65,6 +69,9 @@ * @param update whether to update the display */ remove: function(file, update) { + if (file.name.toLowerCase().indexOf(this.summary.filter) === -1) { + return; + } if (file.type === 'dir' || file.mime === 'httpd/unix-directory') { this.summary.totalDirs--; } @@ -76,6 +83,10 @@ this.update(); } }, + setFilter: function(filter, files){ + this.summary.filter = filter.toLowerCase(); + this.calculate(files); + }, /** * Returns the total of files and directories */ @@ -91,11 +102,15 @@ var summary = { totalDirs: 0, totalFiles: 0, - totalSize: 0 + totalSize: 0, + filter: this.summary.filter }; for (var i = 0; i < files.length; i++) { file = files[i]; + if (file.name.toLowerCase().indexOf(this.summary.filter) === -1) { + continue; + } if (file.type === 'dir' || file.mime === 'httpd/unix-directory') { summary.totalDirs++; } @@ -137,10 +152,12 @@ var $dirInfo = this.$el.find('.dirinfo'); var $fileInfo = this.$el.find('.fileinfo'); var $connector = this.$el.find('.connector'); + var $filterInfo = this.$el.find('.filter'); // Substitute old content with new translations $dirInfo.html(n('files', '%n folder', '%n folders', this.summary.totalDirs)); $fileInfo.html(n('files', '%n file', '%n files', this.summary.totalFiles)); + $filterInfo.html(n('files', 'matches \'{filter}\'', 'match \'{filter}\'', this.summary.totalDirs + this.summary.totalFiles, {filter: this.summary.filter})); this.$el.find('.filesize').html(OC.Util.humanFileSize(this.summary.totalSize)); // Show only what's necessary (may be hidden) @@ -159,6 +176,11 @@ if (this.summary.totalDirs > 0 && this.summary.totalFiles > 0) { $connector.removeClass('hidden'); } + if (this.summary.filter === '') { + $filterInfo.addClass('hidden'); + } else { + $filterInfo.removeClass('hidden'); + } }, render: function() { if (!this.$el) { @@ -168,6 +190,7 @@ var summary = this.summary; var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs); var fileInfo = n('files', '%n file', '%n files', summary.totalFiles); + var filterInfo = n('files', 'matches \'{filter}\'', 'match \'{filter}\'', summary.totalFiles + summary.totalDirs, {filter: summary.filter}) var infoVars = { dirs: '<span class="dirinfo">'+directoryInfo+'</span><span class="connector">', @@ -182,11 +205,14 @@ var info = t('files', '{dirs} and {files}', infoVars); - var $summary = $('<td><span class="info">'+info+'</span></td>'+fileSize+'<td class="date"></td>'); + var $summary = $('<td><span class="info">'+info+' <span class="filter">'+filterInfo+'</span></span></td>'+fileSize+'<td class="date"></td>'); if (!this.summary.totalFiles && !this.summary.totalDirs) { this.$el.addClass('hidden'); } + if (!summary.filter) { + $summary.find('.filter').addClass('hidden'); + } this.$el.append($summary); } diff --git a/apps/files/js/search.js b/apps/files/js/search.js index e6d71cf0f60..1f155b0e9b7 100644 --- a/apps/files/js/search.js +++ b/apps/files/js/search.js @@ -15,11 +15,8 @@ attach: function(search) { search.setFilter('files', function (query) { if (OCA.Files.Search.fileAppLoaded()) { - if (query) { - OCA.Files.App.fileList.setFilter(query); - } else { - OCA.Files.App.fileList.unfilter(); - } + OCA.Files.App.fileList.setFilter(query); + } }); diff --git a/search/js/search.js b/search/js/search.js index 28e6fa999a0..afd3fca7b1b 100644 --- a/search/js/search.js +++ b/search/js/search.js @@ -227,7 +227,7 @@ // not showing result, decrease counter var count = $status.data('count') - 1; $status.data('count', count) - .text(t('search', '{count} search results in other folders', {count:count}, count)); + .text(t('search', '{count} search results in other places', {count:count}, count)); } }); } |