diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-07-28 23:04:34 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-07-28 23:04:34 +0200 |
commit | 9565ea251daab076cdc89a5ce8fa409923e1eee8 (patch) | |
tree | dea2814b27990578f24a9432ea04e1cb0d53e049 /files | |
parent | ba246d3b27ca7a5de06e5674e9b562035d36eca0 (diff) | |
download | nextcloud-server-9565ea251daab076cdc89a5ce8fa409923e1eee8.tar.gz nextcloud-server-9565ea251daab076cdc89a5ce8fa409923e1eee8.zip |
Implement inline renaming of files
Still needs some ui love
Diffstat (limited to 'files')
-rw-r--r-- | files/ajax/rename.php | 2 | ||||
-rw-r--r-- | files/js/fileactions.js | 3 | ||||
-rw-r--r-- | files/js/filelist.js | 33 |
3 files changed, 35 insertions, 3 deletions
diff --git a/files/ajax/rename.php b/files/ajax/rename.php index 65763fceb94..7554aa0dd62 100644 --- a/files/ajax/rename.php +++ b/files/ajax/rename.php @@ -1,7 +1,7 @@ <?php // Init owncloud -require_once('../lib/base.php'); +require_once('../../lib/base.php'); // We send json data header( "Content-Type: application/jsonrequest" ); diff --git a/files/js/fileactions.js b/files/js/fileactions.js index 32029c94daa..1eb885f06de 100644 --- a/files/js/fileactions.js +++ b/files/js/fileactions.js @@ -126,8 +126,7 @@ FileActions.register('all','Delete',OC.imagePath('core','actions/delete'),functi }); FileActions.register('all','Rename',OC.imagePath('core','actions/rename'),function(filename){ - //todo - alert('Implement Me!!'); + FileList.rename(filename); }); FileActions.setDefault('all','Download'); diff --git a/files/js/filelist.js b/files/js/filelist.js index e84a9acb535..fb96437f0a7 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -73,5 +73,38 @@ FileList={ }, isLoading:function(name){ return $('tr[data-file="'+name+'"]').data('loading'); + }, + rename:function(name){ + var tr=$('tr[data-file="'+name+'"]'); + var td=tr.children('td.filename'); + var input=$('<input value='+name+' class="filename"></input>'); + var button=$('<input type="sumit" value="Ok"></input>'); + var form=$('<form action="#"></form>') + form.append(input); + form.append(button); + td.children('a.name').text(''); + td.children('a.name').append(form) + input.focus(); + td.children('a.name').append(button); + form.submit(function(event){ + var newname=input.val(); + event.stopPropagation(); + event.preventDefault(); + tr.attr('data-file',newname); + td.children('a.name').empty(); + td.children('a.name').text(newname); + $.ajax({ + url: 'ajax/rename.php', + data: "dir="+$('#dir').val()+"&newname="+encodeURIComponent(newname)+"&file="+encodeURIComponent(name) + }); + }); + form.click(function(event){ + event.stopPropagation(); + event.preventDefault(); + }); + input.blur(function(){ + td.children('a.name').empty(); + td.children('a.name').text(name); + }); } } |