|
|
|
@ -361,12 +361,11 @@
|
|
|
|
|
if(user_id === '<%= User.current.id%>') {
|
|
|
|
|
res_name = line.children().eq(1).children().attr('title');
|
|
|
|
|
res_link = line.children().eq(1).html();
|
|
|
|
|
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
|
|
|
|
|
line.children().eq(1).html(
|
|
|
|
|
'<input name="res_name" id="res_name" ' +
|
|
|
|
|
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
|
|
|
|
|
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" onkeypress="if(event.keyCode==13){event.preventDefault();this.blur();}" ' +
|
|
|
|
|
'value="'+res_name+
|
|
|
|
|
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+
|
|
|
|
|
'<% end %>');
|
|
|
|
|
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>');
|
|
|
|
|
$("#res_name").focus();
|
|
|
|
|
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
|
|
|
|
|
}else{
|
|
|
|
@ -382,6 +381,8 @@
|
|
|
|
|
return str.slice(0, i + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//恢复编辑状态到链接状态
|
|
|
|
|
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
|
|
|
|
|
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
|
|
|
|
@ -395,22 +396,22 @@
|
|
|
|
|
if( name && name != res_name.trim()){
|
|
|
|
|
|
|
|
|
|
if(confirm('确定修改为 '+name)){
|
|
|
|
|
$.post(
|
|
|
|
|
'<%=rename_resource_user_path(@user) %>',
|
|
|
|
|
"res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(),
|
|
|
|
|
function (data){
|
|
|
|
|
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '<%=rename_resource_user_path(@user) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(),
|
|
|
|
|
type:'get',
|
|
|
|
|
success:function (data)
|
|
|
|
|
{
|
|
|
|
|
if (data != 'fail') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
|
|
|
|
|
last_line.children().eq(1).html(res_link);
|
|
|
|
|
last_line.children().eq(1).children().attr('title',name);
|
|
|
|
|
last_line.children().eq(1).children().attr('href',data);
|
|
|
|
|
last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name);
|
|
|
|
|
}else{
|
|
|
|
|
last_line.children().eq(1).children().attr('title', name);
|
|
|
|
|
last_line.children().eq(1).children().attr('href', data);
|
|
|
|
|
last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name);
|
|
|
|
|
} else {
|
|
|
|
|
last_line.children().eq(1).html(res_link);
|
|
|
|
|
res_link = null; //如果修改失败,恢复之后将res_link置空
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'text'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
}else{
|
|
|
|
|
last_line.children().eq(1).html(res_link);
|
|
|
|
|
res_link = null; //如果没有做修改,恢复之后将res_link置空
|
|
|
|
|