From 03747a0ffbb177de43db306f43e2896eb9cf740f Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 18 Apr 2011 10:02:01 +0200 Subject: [PATCH] implemented Delete action in file menu --- files/js/files.js | 39 +++++++++++++++++++++++++++++++-------- files/templates/index.php | 2 +- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/files/js/files.js b/files/js/files.js index 5c11bddeb5..019758dc49 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -39,6 +39,19 @@ $(document).ready(function() { $('.browser input:checkbox').attr('checked', false); }); + // Delete current file + $('#delete_single_file').click(function() { + filename = $('#file_menu').parents('tr:first').find('.filename:first').children('a:first').text(); + $.ajax({ + url: 'ajax/delete.php', + data: "dir="+$('#dir').val()+"&file="+filename, + complete: function(data){ + boolOperationFinished(data, true, $('#file_menu').parents('tr:first')); + } + }); + return false; + }); + $('#file_upload_start').click(function() { $('#file_upload_target').load(uploadFinished); }); @@ -47,7 +60,7 @@ $(document).ready(function() { $.ajax({ url: 'ajax/newfolder.php', data: "dir="+$('#dir').val()+"&foldername="+$('#file_new_dir_name').val(), - complete: boolOpFinished + complete: function(data){boolOperationFinished(data, false);} }); }); @@ -98,14 +111,20 @@ function resetFileActionPanel() { $('#file_action_panel').attr('activeAction', false); } -function boolOpFinished(data) { +function boolOperationFinished(data, single, el) { result = eval("("+data.responseText+");"); if(result.status == 'success'){ - $.ajax({ - url: 'ajax/list.php', - data: "dir="+$('#dir').val(), - complete: refreshContents - }); + if(single) { + $('#file_menu').slideToggle(0); + $('body').append($('#file_menu')); + $(el).remove(); + } else { + $.ajax({ + url: 'ajax/list.php', + data: "dir="+$('#dir').val(), + complete: refreshContents + }); + } } else { alert(result.data.message); } @@ -117,7 +136,11 @@ function refreshContents(data) { updateBreadcrumb(result.data.breadcrumb); } updateFileList(result.data.files); - $('#file_upload_button').click(); + $('td.fileaction a').click(function() { + $(this).parent().append($('#file_menu')); + $('#file_menu').slideToggle(250); + return false; + }); resetFileActionPanel(); } diff --git a/files/templates/index.php b/files/templates/index.php index 75eef0d16e..d38e771c2e 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -40,6 +40,6 @@ name="file_upload_target" src="">