summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-07-01 21:32:04 +0200
committerVincent Petry <pvince81@owncloud.com>2014-07-01 21:32:04 +0200
commit025b71d068bf530581693af67a31a56dca24beb1 (patch)
tree1d3aeda7b7f569b02adf96399896b1a59c307913 /apps/files/js
parent509cdebab7bb99c34467b053a2e596f48a10399d (diff)
downloadnextcloud-server-025b71d068bf530581693af67a31a56dca24beb1.tar.gz
nextcloud-server-025b71d068bf530581693af67a31a56dca24beb1.zip
Use fileActionsReady to re-render sharing icons
Whenever file actions are modified, either by registering new actions or when appending a new page of entries, the sharing app is now notified so it can correctly refresh the sharing icon status. Additionally, the core's loadIcons() method is also used to load the existing shares and also refresh the sharing icons afterwards.
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/fileactions.js5
-rw-r--r--apps/files/js/filelist.js35
2 files changed, 25 insertions, 15 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index fc7c9ccacef..e06d2912274 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -181,11 +181,12 @@
return;
}
this.currentFile = parent;
+ var $tr = parent.closest('tr');
var self = this;
var actions = this.getActions(this.getCurrentMimeType(), this.getCurrentType(), this.getCurrentPermissions());
var file = this.getCurrentFile();
var nameLinks;
- if (parent.closest('tr').data('renaming')) {
+ if ($tr.data('renaming')) {
return;
}
@@ -278,7 +279,7 @@
}
if (triggerEvent){
- fileList.$fileList.trigger(jQuery.Event("fileActionsReady", {fileList: fileList}));
+ fileList.$fileList.trigger(jQuery.Event("fileActionsReady", {fileList: fileList, $files: $tr}));
}
},
getCurrentFile: function () {
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 07e4e523e03..c7fccc5dd66 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -473,6 +473,7 @@
/**
* Appends the next page of files into the table
* @param animate true to animate the new elements
+ * @return array of DOM elements of the newly added files
*/
_nextPage: function(animate) {
var index = this.$fileList.children().length,
@@ -483,7 +484,7 @@
isAllSelected = this.isAllSelected();
if (index >= this.files.length) {
- return;
+ return false;
}
while (count > 0 && index < this.files.length) {
@@ -496,12 +497,17 @@
}
if (animate) {
tr.addClass('appear transparent');
- newTrs.push(tr);
}
+ newTrs.push(tr);
index++;
count--;
}
+ // trigger event for newly added rows
+ if (newTrs.length > 0) {
+ this.$fileList.trigger($.Event('fileActionsReady', {fileList: this, $files: newTrs}));
+ }
+
if (animate) {
// defer, for animation
window.setTimeout(function() {
@@ -510,6 +516,7 @@
}
}, 0);
}
+ return newTrs;
},
/**
@@ -518,10 +525,16 @@
*/
_onFileActionsUpdated: function() {
var self = this;
- this.$fileList.find('tr td.filename').each(function() {
- self.fileActions.display($(this), false, self);
+ var $files = this.$fileList.find('tr');
+ if (!$files.length) {
+ return;
+ }
+
+ $files.each(function() {
+ self.fileActions.display($(this).find('td.filename'), false, self);
});
- this.$fileList.trigger($.Event('fileActionsReady', {fileList: this}));
+ this.$fileList.trigger($.Event('fileActionsReady', {fileList: this, $files: $files}));
+
},
/**
@@ -533,7 +546,6 @@
// detach to make adding multiple rows faster
this.files = filesArray;
- this.$fileList.detach();
this.$fileList.empty();
// clear "Select all" checkbox
@@ -542,10 +554,7 @@
this.isEmpty = this.files.length === 0;
this._nextPage();
- this.$el.find('thead').after(this.$fileList);
-
this.updateEmptyContent();
- this.$fileList.trigger($.Event('fileActionsReady', {fileList: this}));
this.fileSummary.calculate(filesArray);
@@ -1283,16 +1292,16 @@
// reinsert row
self.files.splice(tr.index(), 1);
tr.remove();
- self.add(fileInfo, {updateSummary: false, silent: true});
- self.$fileList.trigger($.Event('fileActionsReady', {fileList: self}));
+ tr = self.add(fileInfo, {updateSummary: false, silent: true});
+ self.$fileList.trigger($.Event('fileActionsReady', {fileList: self, $files: $(tr)}));
}
});
} else {
// add back the old file info when cancelled
self.files.splice(tr.index(), 1);
tr.remove();
- self.add(oldFileInfo, {updateSummary: false, silent: true});
- self.$fileList.trigger($.Event('fileActionsReady', {fileList: self}));
+ tr = self.add(oldFileInfo, {updateSummary: false, silent: true});
+ self.$fileList.trigger($.Event('fileActionsReady', {fileList: self, $files: $(tr)}));
}
} catch (error) {
input.attr('title', error);