summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-03-17 20:15:10 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-03-17 20:15:10 +0100
commitea8705bac8ae10b0c3c11258e83d8fb80ee616e9 (patch)
treed17c6c710d1f5b24422886da6bb3158716e6b243
parentac48563efd74675f75b2b300b7d8b0c4f74be70b (diff)
downloadnextcloud-server-ea8705bac8ae10b0c3c11258e83d8fb80ee616e9.tar.gz
nextcloud-server-ea8705bac8ae10b0c3c11258e83d8fb80ee616e9.zip
additional class is added to the file actions called e.g. 'action-share', 'action-rename'
in order to allow proper translations of the action's display name an additional parameter has been added to the register function
-rw-r--r--apps/files/js/fileactions.js37
-rw-r--r--apps/files_versions/js/versions.js3
2 files changed, 28 insertions, 12 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 9a69d7b3688..a7d1fa9d8a2 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -15,21 +15,33 @@ var FileActions = {
defaults: {},
icons: {},
currentFile: null,
- register: function (mime, name, permissions, icon, action) {
+ register: function (mime, name, permissions, icon, action, displayName) {
if (!FileActions.actions[mime]) {
FileActions.actions[mime] = {};
}
if (!FileActions.actions[mime][name]) {
FileActions.actions[mime][name] = {};
}
+ if (!displayName) {
+ displayName = t('files', name);
+ }
FileActions.actions[mime][name]['action'] = action;
FileActions.actions[mime][name]['permissions'] = permissions;
+ FileActions.actions[mime][name]['displayName'] = displayName;
FileActions.icons[name] = icon;
},
setDefault: function (mime, name) {
FileActions.defaults[mime] = name;
},
get: function (mime, type, permissions) {
+ var actions = this.getActions(mime, type, permissions);
+ var filteredActions = {};
+ $.each(actions, function (name, action) {
+ filteredActions[name] = action.action;
+ });
+ return filteredActions;
+ },
+ getActions: function (mime, type, permissions) {
var actions = {};
if (FileActions.actions.all) {
actions = $.extend(actions, FileActions.actions.all);
@@ -51,7 +63,7 @@ var FileActions = {
var filteredActions = {};
$.each(actions, function (name, action) {
if (action.permissions & permissions) {
- filteredActions[name] = action.action;
+ filteredActions[name] = action;
}
});
return filteredActions;
@@ -82,7 +94,7 @@ var FileActions = {
*/
display: function (parent, triggerEvent) {
FileActions.currentFile = parent;
- var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
+ var actions = FileActions.getActions(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var file = FileActions.getCurrentFile();
var nameLinks;
if (FileList.findFileEl(file).data('renaming')) {
@@ -105,15 +117,16 @@ var FileActions = {
event.data.actionFunc(file);
};
- var addAction = function (name, action) {
+ var addAction = function (name, action, displayName) {
// NOTE: Temporary fix to prevent rename action in root of Shared directory
if (name === 'Rename' && $('#dir').val() === '/Shared') {
return true;
}
if ((name === 'Download' || action !== defaultAction) && name !== 'Delete') {
+
var img = FileActions.icons[name],
- actionText = t('files', name),
+ actionText = displayName,
actionContainer = 'a.name>span.fileactions';
if (name === 'Rename') {
@@ -125,7 +138,7 @@ var FileActions = {
if (img.call) {
img = img(file);
}
- var html = '<a href="#" class="action" data-action="' + name + '">';
+ var html = '<a href="#" class="action action-' + name.toLowerCase() + '" data-action="' + name + '">';
if (img) {
html += '<img class ="svg" src="' + img + '" />';
}
@@ -133,8 +146,7 @@ var FileActions = {
var element = $(html);
element.data('action', name);
- //alert(element);
- element.on('click', {a: null, elem: parent, actionFunc: actions[name]}, actionHandler);
+ element.on('click', {a: null, elem: parent, actionFunc: actions[name].action}, actionHandler);
parent.find(actionContainer).append(element);
}
@@ -142,12 +154,15 @@ var FileActions = {
$.each(actions, function (name, action) {
if (name !== 'Share') {
- addAction(name, action);
+ displayName = action.displayName;
+ ah = action.action;
+
+ addAction(name, ah, displayName);
}
});
if(actions.Share && !($('#dir').val() === '/' && file === 'Shared')){
- // t('files', 'Share')
- addAction('Share', actions.Share);
+ displayName = t('files', 'Share');
+ addAction('Share', actions.Share, displayName);
}
// remove the existing delete action
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index 4adf14745de..b452bc25b13 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -11,7 +11,7 @@ $(document).ready(function(){
// Add versions button to 'files/index.php'
FileActions.register(
'file'
- , t('files_versions', 'Versions')
+ , 'Versions'
, OC.PERMISSION_UPDATE
, function() {
// Specify icon for hitory button
@@ -36,6 +36,7 @@ $(document).ready(function(){
createVersionsDropdown(filename, file);
}
}
+ , t('files_versions', 'Versions')
);
}