diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-11-24 16:26:50 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-11-24 16:26:50 +0100 |
commit | e689bc745fc94d9760976e40522ddf96eb5c645c (patch) | |
tree | 8e4f24c0b42a08d4aa39e57f11380714f953164c /apps/files_trashbin/js | |
parent | 13b06aa6dfeb7c63750461529b27494ed035707d (diff) | |
download | nextcloud-server-e689bc745fc94d9760976e40522ddf96eb5c645c.tar.gz nextcloud-server-e689bc745fc94d9760976e40522ddf96eb5c645c.zip |
Improve FileActions JS to allow for custom rendering
This improves the OCA.Files.FileActions class to support passing a
"render" function in the action object.
The default function "_defaultRenderFunction" is used by default and
renders actions in the usual actions container.
Moved "Rename" and "Delete" to custom render functions.
Diffstat (limited to 'apps/files_trashbin/js')
-rw-r--r-- | apps/files_trashbin/js/app.js | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js index a9727542bad..72d9f4a6771 100644 --- a/apps/files_trashbin/js/app.js +++ b/apps/files_trashbin/js/app.js @@ -57,21 +57,34 @@ OCA.Trashbin.App = { ); }, t('files_trashbin', 'Restore')); - fileActions.register('all', 'Delete', OC.PERMISSION_READ, function() { - return OC.imagePath('core', 'actions/delete'); - }, function(filename, context) { - var fileList = context.fileList; - $('.tipsy').remove(); - var tr = fileList.findFileEl(filename); - var deleteAction = tr.children("td.date").children(".action.delete"); - deleteAction.removeClass('icon-delete').addClass('icon-loading-small'); - fileList.disableActions(); - $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'), { - files: JSON.stringify([filename]), - dir: fileList.getCurrentDirectory() - }, - _.bind(fileList._removeCallback, fileList) - ); + fileActions.registerAction({ + name: 'Delete', + displayName: '', + mime: 'all', + permissions: OC.PERMISSION_READ, + icon: function() { + return OC.imagePath('core', 'actions/delete'); + }, + render: function(actionSpec, isDefault, context) { + var $actionLink = fileActions._makeActionLink(actionSpec, context); + $actionLink.attr('original-title', t('files', 'Delete permanently')); + context.$file.find('td:last').append($actionLink); + return $actionLink; + }, + actionHandler: function(filename, context) { + var fileList = context.fileList; + $('.tipsy').remove(); + var tr = fileList.findFileEl(filename); + var deleteAction = tr.children("td.date").children(".action.delete"); + deleteAction.removeClass('icon-delete').addClass('icon-loading-small'); + fileList.disableActions(); + $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'), { + files: JSON.stringify([filename]), + dir: fileList.getCurrentDirectory() + }, + _.bind(fileList._removeCallback, fileList) + ); + } }); return fileActions; } |