summaryrefslogtreecommitdiffstats
path: root/apps/files/js/fileactions.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/fileactions.js')
-rw-r--r--apps/files/js/fileactions.js53
1 files changed, 41 insertions, 12 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 74bb711ef3d..9a69d7b3688 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -1,3 +1,15 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/* global OC, FileList */
+/* global trashBinApp */
var FileActions = {
actions: {},
defaults: {},
@@ -45,8 +57,9 @@ var FileActions = {
return filteredActions;
},
getDefault: function (mime, type, permissions) {
+ var mimePart;
if (mime) {
- var mimePart = mime.substr(0, mime.indexOf('/'));
+ mimePart = mime.substr(0, mime.indexOf('/'));
}
var name = false;
if (mime && FileActions.defaults[mime]) {
@@ -71,13 +84,15 @@ var FileActions = {
FileActions.currentFile = parent;
var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var file = FileActions.getCurrentFile();
+ var nameLinks;
if (FileList.findFileEl(file).data('renaming')) {
return;
}
// recreate fileactions
- parent.children('a.name').find('.fileactions').remove();
- parent.children('a.name').append('<span class="fileactions" />');
+ nameLinks = parent.children('a.name');
+ nameLinks.find('.fileactions, .nametext .action').remove();
+ nameLinks.append('<span class="fileactions" />');
var defaultAction = FileActions.getDefault(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var actionHandler = function (event) {
@@ -97,21 +112,30 @@ var FileActions = {
}
if ((name === 'Download' || action !== defaultAction) && name !== 'Delete') {
- var img = FileActions.icons[name];
+ var img = FileActions.icons[name],
+ actionText = t('files', name),
+ actionContainer = 'a.name>span.fileactions';
+
+ if (name === 'Rename') {
+ // rename has only an icon which appears behind
+ // the file name
+ actionText = '';
+ actionContainer = 'a.name span.nametext';
+ }
if (img.call) {
img = img(file);
}
var html = '<a href="#" class="action" data-action="' + name + '">';
if (img) {
- html += '<img class ="svg" src="' + img + '" /> ';
+ html += '<img class ="svg" src="' + img + '" />';
}
- html += t('files', name) + '</a>';
+ html += '<span> ' + actionText + '</span></a>';
var element = $(html);
element.data('action', name);
//alert(element);
element.on('click', {a: null, elem: parent, actionFunc: actions[name]}, actionHandler);
- parent.find('a.name>span.fileactions').append(element);
+ parent.find(actionContainer).append(element);
}
};
@@ -130,13 +154,14 @@ var FileActions = {
parent.parent().children().last().find('.action.delete').remove();
if (actions['Delete']) {
var img = FileActions.icons['Delete'];
+ var html;
if (img.call) {
img = img(file);
}
if (typeof trashBinApp !== 'undefined' && trashBinApp) {
- var html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
+ html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
} else {
- var html = '<a href="#" class="action delete delete-icon" />';
+ html = '<a href="#" class="action delete delete-icon" />';
}
var element = $(html);
element.data('action', actions['Delete']);
@@ -163,17 +188,21 @@ var FileActions = {
};
$(document).ready(function () {
+ var downloadScope;
if ($('#allowZipDownload').val() == 1) {
- var downloadScope = 'all';
+ downloadScope = 'all';
} else {
- var downloadScope = 'file';
+ downloadScope = 'file';
}
if (typeof disableDownloadActions == 'undefined' || !disableDownloadActions) {
FileActions.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/download');
}, function (filename) {
- window.location = OC.filePath('files', 'ajax', 'download.php') + '?files=' + encodeURIComponent(filename) + '&dir=' + encodeURIComponent($('#dir').val());
+ var url = FileList.getDownloadUrl(filename);
+ if (url) {
+ OC.redirect(url);
+ }
});
}
$('#fileList tr').each(function () {