summaryrefslogtreecommitdiffstats
path: root/apps/files/js/fileactions.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-11-04 20:48:38 +0100
committerRobin Appelman <icewind@owncloud.com>2012-11-04 20:48:38 +0100
commitf187aa6c93ecc7538875e38629f4efb2c25c3155 (patch)
treea8618b7ecb7a9586439a33bf78ba42a80ce3c90d /apps/files/js/fileactions.js
parent555dd5c261e52cf64f5a8eb6f4d03635cedafbbe (diff)
downloadnextcloud-server-f187aa6c93ecc7538875e38629f4efb2c25c3155.tar.gz
nextcloud-server-f187aa6c93ecc7538875e38629f4efb2c25c3155.zip
some more code reuse for fileactions
also fixes an issue where some fileactions always worked on the last file in the list
Diffstat (limited to 'apps/files/js/fileactions.js')
-rw-r--r--apps/files/js/fileactions.js29
1 files changed, 13 insertions, 16 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 82d990bf780..0b547502bcf 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -70,6 +70,16 @@ var FileActions = {
}
parent.children('a.name').append('<span class="fileactions" />');
var defaultAction = FileActions.getDefault(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
+ var actionHandler = function (parent, action, event) {
+ event.stopPropagation();
+ event.preventDefault();
+ if(action)
+ FileActions.currentFile = parent;
+ file = FileActions.getCurrentFile();
+ console.log(file);
+ console.log(file);
+ action(file);
+ };
for (name in actions) {
// NOTE: Temporary fix to prevent rename action in root of Shared directory
if (name === 'Rename' && $('#dir').val() === '/Shared') {
@@ -87,14 +97,7 @@ var FileActions = {
html += t('files', name) + '</a>';
var element = $(html);
element.data('action', name);
- element.click(function (event) {
- FileActions.currentFile = $(this).parent().parent().parent();
- event.stopPropagation();
- event.preventDefault();
- var action = actions[$(this).data('action')];
- var currentFile = FileActions.getCurrentFile();
- action(currentFile);
- });
+ element.click(actionHandler.bind(null, parent, actions[name]));
parent.find('a.name>span.fileactions').append(element);
}
}
@@ -113,14 +116,8 @@ var FileActions = {
if (img) {
element.append($('<img class ="svg" src="' + img + '"/>'));
}
- element.data('action', 'Delete');
- element.click(function (event) {
- event.stopPropagation();
- event.preventDefault();
- var action = actions[$(this).data('action')];
- var currentFile = FileActions.getCurrentFile();
- action(currentFile);
- });
+ element.data('action', actions['Delete']);
+ element.click(actionHandler.bind(null, parent, actions['Delete']));
parent.parent().children().last().append(element);
}
},