summaryrefslogtreecommitdiffstats
path: root/files/js/filelist.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-28 23:04:34 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-28 23:04:34 +0200
commit9565ea251daab076cdc89a5ce8fa409923e1eee8 (patch)
treedea2814b27990578f24a9432ea04e1cb0d53e049 /files/js/filelist.js
parentba246d3b27ca7a5de06e5674e9b562035d36eca0 (diff)
downloadnextcloud-server-9565ea251daab076cdc89a5ce8fa409923e1eee8.tar.gz
nextcloud-server-9565ea251daab076cdc89a5ce8fa409923e1eee8.zip
Implement inline renaming of files
Still needs some ui love
Diffstat (limited to 'files/js/filelist.js')
-rw-r--r--files/js/filelist.js33
1 files changed, 33 insertions, 0 deletions
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);
+ });
}
}