From 47993fe29a6a7837e39b1e24e03c3b4ac9d7f794 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 Jul 2011 21:43:35 +0200 Subject: [PATCH] You can now move files to a parent folder by draging them to an element in the breadcrumb bar also fixed dragging newly uploaded files and droppin in new folders --- core/css/styles.css | 6 +-- files/css/files.css | 4 ++ files/js/filelist.js | 4 ++ files/js/files.js | 58 ++++++++++++++++++++++------- files/templates/index.php | 4 +- files/templates/part.breadcrumb.php | 8 +++- 6 files changed, 64 insertions(+), 20 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index a0dd69516c..f0dfd1e9b1 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -249,9 +249,9 @@ table td.delete { background-image:url('../img/delete.png'); } #fileList tr:hover input[type=checkbox] { display:inline; } /* NAVIGATION BAR */ -p.nav { margin:1em 0 0 2em; padding:0.8em; line-height:16px; font-weight:bold; } -p.nav a { padding:0.5em 1.5em 0.5em 0.5em; background-position:right center; background-repeat:no-repeat; background-image:url('../img/arrow.png'); text-decoration:none; } -p.nav a img { height:16px; vertical-align:text-top; } +span.nav { margin:1em 0 0 2em; padding:0.8em; line-height:16px; font-weight:bold; display:block} +span.nav a { padding:0.5em 1.5em 0.5em 0.5em; background-position:right center; background-repeat:no-repeat; background-image:url('../img/arrow.png'); text-decoration:none; } +span.nav a img { height:16px; vertical-align:text-top; } /* ACTIONS BAR */ p.actions, div.actions { padding:0; } diff --git a/files/css/files.css b/files/css/files.css index 3b01bfe097..ed67755ab4 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -114,3 +114,7 @@ table td.filename a span.extention{ color:#999; } + +div.crumb{ + float:left; +} \ No newline at end of file diff --git a/files/js/filelist.js b/files/js/filelist.js index 2d00c64233..290f062dae 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -11,6 +11,7 @@ FileList={ html+=''; html+=''; FileList.insertElement(name,'file',$(html)); + $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); }, addDir:function(name,size,lastModified){ var html=''; @@ -22,6 +23,8 @@ FileList={ html+=''; FileList.insertElement(name,'dir',$(html)); + $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + $('tr[data-file="'+name+'"] td.filename').droppable(folderDropOptions); }, refresh:function(data) { result = jQuery.parseJSON(data.responseText); @@ -32,6 +35,7 @@ FileList={ resetFileActionPanel(); }, remove:function(name){ + $('tr[data-file="'+name+'"] td.filename').draggable('destroy'); $('tr[data-file="'+name+'"]').remove(); }, insertElement:function(name,type,element){ diff --git a/files/js/files.js b/files/js/files.js index 85bc7a98f6..431b49131c 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -1,26 +1,33 @@ $(document).ready(function() { $('#file_action_panel').attr('activeAction', false); - - $('#fileList tr td.filename').draggable({ - distance: 20, revert: true, opacity: 0.7, - stop: function(event, ui) { - $('#fileList tr td.filename').addClass('ui-draggable'); - }, - }); - $('#fileList tr[data-type="dir"] td.filename').droppable({ + + //drag/drop of files + $('#fileList tr td.filename').draggable(dragOptions); + $('#fileList tr[data-type="dir"] td.filename').droppable(folderDropOptions); + $('div.crumb').droppable({ drop: function( event, ui ) { var file=ui.draggable.text().trim(); - var target=$(this).text().trim(); + var target=$(this).attr('data-dir'); + var dir=$('#dir').val(); + while(dir.substr(0,1)=='/'){//remove extra leading /'s + dir=dir.substr(1); + } + dir='/'+dir; + if(dir.substr(-1,1)!='/'){ + dir=dir+'/'; + } + if(target==dir){ + return; + } $.ajax({ url: 'ajax/move.php', - data: "dir="+$('#dir').val()+"&file="+file+'&target='+target, + data: "dir="+dir+"&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); });} }); - } + }, + tolerance: 'pointer' }); // Sets the file-action buttons behaviour : @@ -234,3 +241,28 @@ function formatDate(date){ "July", "August", "September", "October", "November", "December" ]; return monthNames[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear()+', '+((date.getHours()<10)?'0':'')+date.getHours()+':'+date.getMinutes(); } + + +//options for file drag/dropp +var dragOptions={ + distance: 20, revert: true, opacity: 0.7, + stop: function(event, ui) { + $('#fileList tr td.filename').addClass('ui-draggable'); + } +}; +var folderDropOptions={ + drop: function( event, ui ) { + var file=ui.draggable.text().trim(); + var target=$(this).text().trim(); + var dir=$('#dir').val(); + $.ajax({ + url: 'ajax/move.php', + data: "dir="+dir+"&file="+file+'&target='+dir+'/'+target, + complete: function(data){boolOperationFinished(data, function(){ + var el=$('#fileList tr[data-file="'+file+'"] td.filename'); + el.draggable('destroy'); + FileList.remove(file); + });} + }); + } +} \ No newline at end of file diff --git a/files/templates/index.php b/files/templates/index.php index b9f8c02c93..a1254eeb42 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -23,9 +23,9 @@ - + diff --git a/files/templates/part.breadcrumb.php b/files/templates/part.breadcrumb.php index da9544008b..34f955fe67 100644 --- a/files/templates/part.breadcrumb.php +++ b/files/templates/part.breadcrumb.php @@ -1,4 +1,8 @@ - ">" alt="Root" /> +
+ ">" alt="Root"/> +
- "> +
+ "> +
\ No newline at end of file