Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
ebe1afd489
|
@ -244,13 +244,18 @@ class TagsController < ApplicationController
|
|||
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank?
|
||||
@obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank?
|
||||
if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。
|
||||
#看重命名后的tag是否存在。如果存在的话,只需要更改taggings里边的id,
|
||||
if @rename_tag
|
||||
@taggings = ActsAsTaggableOn::Tagging.where(" `taggings`.`tag_id` = #{ @tag_id} AND `taggings`.`taggable_type` = 'Attachment' ")#find_by_tag_id_and_taggable_type(@tag_id,@taggable_type)
|
||||
@taggings.each { |t| t.update_attributes({:tag_id=> @rename_tag.id}) if t.tag_id != @rename_tag.id }
|
||||
ActsAsTaggableOn::Tag.find(@tag_id).update_attributes(:name=>@rename_tag_name)#并且将该tag改名
|
||||
else #如果不存在,那么就直接更新该tag名称为新的名称
|
||||
(ActsAsTaggableOn::Tag.find_by_name(@tag_name)).update_attributes(:name=>@rename_tag_name)
|
||||
if @course_id
|
||||
course = Course.find @course_id
|
||||
if course
|
||||
course.attachments.each do |attachment|
|
||||
taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class)
|
||||
if taggings
|
||||
taggings.delete
|
||||
attachment.tag_list.add(@rename_tag_name.split(","))
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if(@rename_tag.nil?) #这次命名的是新的tag
|
||||
|
|
|
@ -246,36 +246,63 @@
|
|||
tagId = id;
|
||||
taggableType = type;
|
||||
width = parseInt(domEle.css('width').replace('px','')) >=100 ? parseInt(domEle.css('width').replace('px','')) : 100
|
||||
domEle.html('<input name="" id="renameTagName" maxlength="<%=Setting.tags_max_length%>" minlength="<%= Setting.tags_min_length%>" style="width:'+width +'px;" value="'+name+'"/>');
|
||||
domEle.html('<input name="" id="renameTagName" maxlength="<%=Setting.tags_max_length%>" minlength="<%= Setting.tags_min_length%>" style="width:'+width +'px;" value="'+name+'"/>');
|
||||
domEle.parent().css("border","1px solid #ffffff");
|
||||
$("#renameTagName").focus();
|
||||
}
|
||||
//监听所有的单击事件
|
||||
$(document.body).click(function(e){
|
||||
isdb = false; //这是单击
|
||||
node = document.elementFromPoint(e.clientX, e.clientY);
|
||||
if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
|
||||
isdb = true; //为了防止在编辑的时候又去单击其他tag去过滤。导致tag过滤不可用
|
||||
return;
|
||||
}
|
||||
if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
|
||||
if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
|
||||
ele.parent().css("border","");
|
||||
ele.parent().html(tagNameHtml);
|
||||
$(function(){
|
||||
$("#renameTagName").live("blur",function(){
|
||||
updateTagName();
|
||||
}).live("keypress",function(e){
|
||||
if (e.keyCode == '13') {
|
||||
updateTagName();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}else{ //否则就要更新tag名称了
|
||||
// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问
|
||||
$.post(
|
||||
'<%= update_tag_name_path %>',
|
||||
{"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>}
|
||||
)
|
||||
// }else{
|
||||
// ele.parent().css("border","");
|
||||
// ele.parent().html(tagNameHtml);
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
//执行修改TAGName方法
|
||||
function updateTagName(){
|
||||
if(isdb){
|
||||
isdb = false;
|
||||
if($("#renameTagName").val() == tagName){ //如果值一样,则恢复原来的状态
|
||||
ele.parent().css("border","");
|
||||
ele.parent().html(tagNameHtml);
|
||||
|
||||
}
|
||||
else{
|
||||
$.post(
|
||||
'<%= update_tag_name_path %>',
|
||||
{"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// $(document.body).click(function(e){
|
||||
// isdb = false; //这是单击
|
||||
// node = document.elementFromPoint(e.clientX, e.clientY);
|
||||
// if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
|
||||
// isdb = true; //为了防止在编辑的时候又去单击其他tag去过滤。导致tag过滤不可用
|
||||
// return;
|
||||
// }
|
||||
// if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
|
||||
// if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
|
||||
// ele.parent().css("border","");
|
||||
// ele.parent().html(tagNameHtml);
|
||||
//
|
||||
// }else{ //否则就要更新tag名称了
|
||||
//// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问
|
||||
// $.post(
|
||||
// '<%= update_tag_name_path %>',
|
||||
// {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>}
|
||||
// )
|
||||
//// }else{
|
||||
//// ele.parent().css("border","");
|
||||
//// ele.parent().html(tagNameHtml);
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
<%end %>
|
||||
|
||||
</script>
|
||||
|
|
|
@ -44,12 +44,12 @@ pre li,ul,ol {
|
|||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums { margin-top: 0; margin-bottom: 0;line-height: 15px;margin-left: 0px !important; } /* IE indents via margin-left */
|
||||
.list_style ol li {
|
||||
list-style-type: decimal;
|
||||
margin-left: 10px !important;
|
||||
}
|
||||
/*.list_style ol li {*/
|
||||
/*list-style-type: decimal;*/
|
||||
/*margin-left: 10px !important;*/
|
||||
/*}*/
|
||||
.linenums li {
|
||||
margin-left: 0px !important;
|
||||
margin-left: 5px !important;
|
||||
}
|
||||
li.L0,
|
||||
li.L1,
|
||||
|
|
Loading…
Reference in New Issue