From d31349b781040ba394d8b9f9bf0e0f06f33f5b9e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 Jul 2011 04:14:24 +0200 Subject: [PATCH] files can now be draged and dropped in the file browser --- files/index.php | 2 +- files/js/files.js | 30 +++++++++++++++++++++--------- files/templates/part.list.php | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/files/index.php b/files/index.php index e06ab552632..e88f0ef23e5 100644 --- a/files/index.php +++ b/files/index.php @@ -49,7 +49,7 @@ foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){ $i["date"] = OC_UTIL::formatDate($i["mtime"] ); if($i['type']=='file'){ $i['extention']=substr($i['name'],strrpos($i['name'],'.')); - $i['name']=substr($i['name'],0,strrpos($i['name'],'.')); + $i['basename']=substr($i['name'],0,strrpos($i['name'],'.')); } if($i['directory']=='/'){ $i['directory']=''; diff --git a/files/js/files.js b/files/js/files.js index 408bd6e48a0..85bc7a98f62 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -1,16 +1,28 @@ $(document).ready(function() { $('#file_action_panel').attr('activeAction', false); - - // Sets browser table behaviour : - $('.browser tr').hover( - function() { - $(this).addClass('mouseOver'); + + $('#fileList tr td.filename').draggable({ + distance: 20, revert: true, opacity: 0.7, + stop: function(event, ui) { + $('#fileList tr td.filename').addClass('ui-draggable'); }, - function() { - $(this).removeClass('mouseOver'); + }); + $('#fileList tr[data-type="dir"] td.filename').droppable({ + drop: function( event, ui ) { + var file=ui.draggable.text().trim(); + var target=$(this).text().trim(); + $.ajax({ + url: 'ajax/move.php', + data: "dir="+$('#dir').val()+"&file="+file+'&target='+target, + complete: function(data){boolOperationFinished(data, function(){ + var el=$('#fileList tr[data-file="'+file+'"] td.filename'); + el.draggable('destroy'); + FileList.remove(file); + });} + }); } - ); - + }); + // Sets the file-action buttons behaviour : $('td.fileaction a').live('click',function(event) { event.preventDefault(); diff --git a/files/templates/part.list.php b/files/templates/part.list.php index 119b1bbd83d..14a359fe668 100644 --- a/files/templates/part.list.php +++ b/files/templates/part.list.php @@ -8,7 +8,7 @@ - +