summaryrefslogtreecommitdiffstats
path: root/apps/files/js/filelist.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/filelist.js
parentd063c8e0429b680c9998f91075b18297f55ae62d (diff)
downloadnextcloud-server-7e6c660b008d158de92a664b56359ed0750b82a8.tar.gz
nextcloud-server-7e6c660b008d158de92a664b56359ed0750b82a8.zip
filter new rows
Diffstat (limited to 'apps/files/js/filelist.js')
-rw-r--r--apps/files/js/filelist.js50
1 files changed, 43 insertions, 7 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 08017e3fef1..88c81fb43af 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -112,6 +112,12 @@
_selectionSummary: null,
/**
+ * If not empty, only files containing this string will be shown
+ * @type String
+ */
+ _filter: '',
+
+ /**
* Sort attribute
* @type String
*/
@@ -551,6 +557,7 @@
_nextPage: function(animate) {
var index = this.$fileList.children().length,
count = this.pageSize(),
+ hidden,
tr,
fileData,
newTrs = [],
@@ -562,7 +569,12 @@
while (count > 0 && index < this.files.length) {
fileData = this.files[index];
- tr = this._renderRow(fileData, {updateSummary: false, silent: true});
+ if (this._filter) {
+ hidden = fileData.name.toLowerCase().indexOf(this._filter.toLowerCase()) === -1;
+ } else {
+ hidden = false;
+ }
+ tr = this._renderRow(fileData, {updateSummary: false, silent: true, hidden: hidden});
this.$fileList.append(tr);
if (isAllSelected || this._selectedFiles[fileData.id]) {
tr.addClass('selected');
@@ -1638,17 +1650,41 @@
});
});
},
+ /**
+ * @deprecated use setFilter(filter)
+ */
filter:function(query) {
+ this.setFilter('');
+ },
+ /**
+ * @deprecated use setFilter('')
+ */
+ unfilter:function() {
+ this.setFilter('');
+ },
+ /**
+ * hide files matching the given filter
+ * @param filter
+ */
+ setFilter:function(filter) {
+ this._filter = filter;
+ var that = this;
this.$fileList.find('tr').each(function(i,e) {
- if ($(e).data('file').toString().toLowerCase().indexOf(query.toLowerCase()) === -1) {
- $(e).hide();
+ var $e = $(e);
+ if ($e.data('file').toString().toLowerCase().indexOf(filter.toLowerCase()) === -1) {
+ $e.addClass('hidden');
+ that.$container.trigger('scroll');
+ } else {
+ $e.removeClass('hidden');
}
});
},
- unfilter:function() {
- this.$fileList.find('tr:hidden').each(function(i,e) {
- $(e).show();
- });
+ /**
+ * get the current filter
+ * @param filter
+ */
+ getFilter:function(filter) {
+ return this._filter;
},
/**
* Update UI based on the current selection