aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/filesummary.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/filesummary.js')
-rw-r--r--apps/files/js/filesummary.js37
1 files changed, 34 insertions, 3 deletions
diff --git a/apps/files/js/filesummary.js b/apps/files/js/filesummary.js
index f83eb54678b..d69c5f1b53a 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 && 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 && 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 && file.name.toLowerCase().indexOf(this.summary.filter) === -1) {
+ continue;
+ }
if (file.type === 'dir' || file.mime === 'httpd/unix-directory') {
summary.totalDirs++;
}
@@ -118,6 +133,9 @@
*/
setSummary: function(summary) {
this.summary = summary;
+ if (typeof this.summary.filter === 'undefined') {
+ this.summary.filter = '';
+ }
this.update();
},
@@ -137,6 +155,7 @@
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));
@@ -159,6 +178,13 @@
if (this.summary.totalDirs > 0 && this.summary.totalFiles > 0) {
$connector.removeClass('hidden');
}
+ if (this.summary.filter === '') {
+ $filterInfo.html('');
+ $filterInfo.addClass('hidden');
+ } else {
+ $filterInfo.html(n('files', ' matches \'{filter}\'', ' match \'{filter}\'', this.summary.totalDirs + this.summary.totalFiles, {filter: this.summary.filter}));
+ $filterInfo.removeClass('hidden');
+ }
},
render: function() {
if (!this.$el) {
@@ -168,6 +194,11 @@
var summary = this.summary;
var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs);
var fileInfo = n('files', '%n file', '%n files', summary.totalFiles);
+ if (this.summary.filter === '') {
+ var filterInfo = '';
+ } else {
+ 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,7 +213,7 @@
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');