summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2012-11-05 05:52:52 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2012-11-05 05:52:52 -0800
commit5c72d28ffdcb3290e722bd91bef3f5a5f8130f3f (patch)
treebb5215f0c6de4d42273cca6e6f2fd6a2322f2fc0 /apps
parent59381b90a0b9fb57413f7facb773cc450280039b (diff)
parent34fee8afaa9161fbc9c608ae87bb19b770110a5c (diff)
downloadnextcloud-server-5c72d28ffdcb3290e722bd91bef3f5a5f8130f3f.tar.gz
nextcloud-server-5c72d28ffdcb3290e722bd91bef3f5a5f8130f3f.zip
Merge pull request #245 from owncloud/fileactions
some more reuse for fileactions
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/fileactions.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 82d990bf780..40dd9f14a69 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -70,6 +70,13 @@ 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();
+ FileActions.currentFile = parent;
+ file = FileActions.getCurrentFile();
+ 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 +94,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 +113,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);
}
},