aboutsummaryrefslogtreecommitdiff
path: root/data/assets
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-17 10:52:47 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-17 10:52:47 -0400
commit2dd59c8a570a4bb28129b9ef3fd36b8e18ff5a9c (patch)
tree201fddcdb9920b38a87e3e0f6e2f99a098f46bb5 /data/assets
parent083dc329e5793cc441cfea5093326fe148ff6d22 (diff)
downloadguff-2dd59c8a570a4bb28129b9ef3fd36b8e18ff5a9c.tar.bz2
guff-2dd59c8a570a4bb28129b9ef3fd36b8e18ff5a9c.zip
refactor file actions
Diffstat (limited to 'data/assets')
-rw-r--r--data/assets/js/admin/tabs/files.js59
1 files changed, 29 insertions, 30 deletions
diff --git a/data/assets/js/admin/tabs/files.js b/data/assets/js/admin/tabs/files.js
index 6fcdde7..0e26b2f 100644
--- a/data/assets/js/admin/tabs/files.js
+++ b/data/assets/js/admin/tabs/files.js
@@ -165,40 +165,39 @@ jQuery(function($) {
});
$('#file-actions').on('click', 'a', function() {
- var action_id = $(this).data('id');
+ var action_id = $(this).data('id'),
+ data = $('#files .active').data();
// hide dropdown
$('body').trigger('click');
- if (action_id == 'download') {
- // alert('TODO: download file');
- var url = $('#files .active').data('url');
- if (url)
- location.href = url;
- } else if (action_id == 'move') {
- alert('TODO: move file');
- } else if (action_id == 'delete') {
- var data = $('#files .active').data();
-
- if (confirm(TEMPLATES.run('delete_confirm', data))) {
- send('file/delete', {
- path: data.path,
- }).always(function() {
- // TODO: need loading handler
- }).fail(function(r) {
- var error = r.responseText;
-
- try {
- var data = $.parseJSON(r.responseText);
- if (data.error)
- error = data.error;
- } catch (e) {}
-
- alert("Error: " + error);
- }).done(function() {
- // reload file list
- reload();
- });
+ if (data) {
+ if (action_id == 'download') {
+ if (data.url)
+ location.href = url;
+ } else if (action_id == 'move') {
+ alert('TODO: move file');
+ } else if (action_id == 'delete') {
+ if (confirm(TEMPLATES.run('delete_confirm', data))) {
+ send('file/delete', {
+ path: data.path,
+ }).always(function() {
+ // TODO: need loading handler
+ }).fail(function(r) {
+ var error = r.responseText;
+
+ try {
+ var data = $.parseJSON(r.responseText);
+ if (data.error)
+ error = data.error;
+ } catch (e) {}
+
+ alert("Error: " + error);
+ }).done(function() {
+ // reload file list
+ reload();
+ });
+ }
}
}