aboutsummaryrefslogtreecommitdiffstats
path: root/files/js/filelist.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-08-04 00:22:44 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-08-04 00:22:44 +0200
commite209511f86ec33222f92c80db1c59c3305bef9d5 (patch)
tree3907d4138ea3450c767e00e530f6446f02c28471 /files/js/filelist.js
parent4851a55c1d6824a0c46636f7a8749ad2418e1b4a (diff)
downloadnextcloud-server-e209511f86ec33222f92c80db1c59c3305bef9d5.tar.gz
nextcloud-server-e209511f86ec33222f92c80db1c59c3305bef9d5.zip
provide undo button when deleting files from the web interface
Diffstat (limited to 'files/js/filelist.js')
-rw-r--r--files/js/filelist.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/files/js/filelist.js b/files/js/filelist.js
index 243c1113a47..b4d0adf982c 100644
--- a/files/js/filelist.js
+++ b/files/js/filelist.js
@@ -149,5 +149,66 @@ FileList={
input.blur(function(){
form.trigger('submit');
});
+ },
+ delete:function(files){
+ if(FileList.deleteFiles){//finish any ongoing deletes first
+ FileList.finishDelete(function(){
+ FileList.delete(files);
+ });
+ return;
+ }
+ if(files.substr){
+ files=[files];
+ }
+ $.each(files,function(index,file){
+ $('tr[data-file="'+file+'"]').hide();
+ $('tr[data-file="'+file+'"]').find('input[type="checkbox"]').removeAttr('checked');
+ $('tr[data-file="'+file+'"]').removeClass('selected');
+ });
+ procesSelection();
+ FileList.deleteCanceled=false;
+ FileList.deleteFiles=files;
+ $('#notification').text(files.length+' file'+((files.length>1)?'s':'')+' deleted, click here to undo');
+
+ $('#notification').show();
+ },
+ finishDelete:function(ready,sync){
+ if(!FileList.deleteCanceled && FileList.deleteFiles){
+ var fileNames=FileList.deleteFiles.join(';');
+ $.ajax({
+ url: 'ajax/delete.php',
+ async:!sync,
+ data: "dir="+$('#dir').val()+"&files="+encodeURIComponent(fileNames),
+ complete: function(data){
+ boolOperationFinished(data, function(){
+ $('#notification').hide();
+ $.each(FileList.deleteFiles,function(index,file){
+// alert(file);
+ FileList.remove(file);
+ });
+ FileList.deleteCanceled=true;
+ FileList.deleteFiles=null;
+ if(ready){
+ ready();
+ }
+ });
+ }
+ });
+ }
}
}
+
+$(document).ready(function(){
+ $('#notification').click(function(){
+ FileList.deleteCanceled=true;
+ $('#notification').hide();
+ $.each(FileList.deleteFiles,function(index,file){
+ $('tr[data-file="'+file+'"]').show();
+// alert(file);
+ });
+ FileList.deleteFiles=null;
+ });
+ $(window).bind('beforeunload', function (){
+ FileList.finishDelete(null,true);
+ });
+});