Implement inline renaming of files
Still needs some ui love
This commit is contained in:
parent
ba246d3b27
commit
9565ea251d
3 changed files with 35 additions and 3 deletions
|
@ -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" );
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue