333 lines
12 KiB
Plaintext
333 lines
12 KiB
Plaintext
<div id="resource_list">
|
||
<% if @isproject %>
|
||
<%= render :partial => 'project_file_new', locals: {project: @project} %>
|
||
<% else %>
|
||
<%= render :partial => 'course_file', locals: {course: @course} %>
|
||
<% end %>
|
||
</div>
|
||
|
||
<script type='text/javascript'>
|
||
var slideHeight = 29;
|
||
function readmore(aNode) {
|
||
// console.log(aNode)
|
||
// var $td_tags_area = $(aNode).parent().parent();
|
||
var $td_tags_area = $(aNode).parent().parent().parent().parent();
|
||
var $tags_area = $td_tags_area.find('.tags_area')
|
||
var $tags_gradint = $td_tags_area.find('.tags_gradint')
|
||
var $read_more = $td_tags_area.find('.read-more')
|
||
var $read_more_a = $td_tags_area.find('.read-more a')
|
||
var $tags = $td_tags_area.find('#tags')
|
||
var $icona = $td_tags_area.find('.tags_icona')
|
||
|
||
var slideHeight = 13; //px
|
||
var defHeight = $tags.height();
|
||
|
||
var curHeight = $tags_area.height();
|
||
if (curHeight == slideHeight) {
|
||
$tags_area.animate({
|
||
height: defHeight
|
||
}, 'normal');
|
||
$read_more_a.html('隐藏');
|
||
$icona.html('<%=image_tag "/images/sidebar/minus.png"%>')
|
||
$tags_gradint.fadeOut();
|
||
} else {
|
||
$tags_area.animate({
|
||
height: slideHeight
|
||
}, 'normal');
|
||
$read_more_a.html('更多');
|
||
$icona.html('<%=image_tag "/images/sidebar/add.png"%>')
|
||
$tags_gradint.fadeIn();
|
||
}
|
||
;
|
||
|
||
}
|
||
$(function () {
|
||
var slideHeight = 20; //px
|
||
var defHeight = $('.tags_area').height();
|
||
if (defHeight >= slideHeight) {
|
||
$('.tags_area').css('height', slideHeight + 'px');
|
||
}
|
||
;
|
||
});
|
||
|
||
function eval_ajax(xhr, textStatus) {
|
||
if (textStatus == 'success') {
|
||
eval(xhr.responseText);
|
||
} else if (textStatus == 'error') {
|
||
alert('error');
|
||
}
|
||
}
|
||
|
||
|
||
function attachment_contenttypes_searchex(value) {
|
||
<% if @project%>
|
||
$.ajax({
|
||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: $('#attachment_browse').val(),
|
||
contentType: encodeURIComponent(value)
|
||
}
|
||
|
||
}).complete(eval_ajax);
|
||
<%end%>
|
||
}
|
||
|
||
|
||
|
||
function attachtype_edit(value) {
|
||
<% if @project%>
|
||
$.ajax({
|
||
|
||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: $('#attachment_browse').val(),
|
||
contentType: encodeURIComponent(value)
|
||
}
|
||
|
||
}).complete(eval_ajax);
|
||
<%end%>
|
||
}
|
||
|
||
function attachmenttypes_searchex(value) {
|
||
<% if @project%>
|
||
$.ajax({
|
||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: encodeURIComponent(value),
|
||
contentType: $('#attach_sufix_browse').val()
|
||
}
|
||
|
||
}).complete(eval_ajax);
|
||
<%end%>
|
||
}
|
||
|
||
function course_attachmenttypes_searchex(value) {
|
||
<% if @course%>
|
||
$.ajax({
|
||
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: encodeURIComponent(value),
|
||
contentType: $('#attach_sufix_browse').val()
|
||
}
|
||
|
||
}).complete(eval_ajax);
|
||
<%end%>
|
||
}
|
||
|
||
function course_attachment_contenttypes_searchex(value) {
|
||
<% if @course%>
|
||
$.ajax({
|
||
|
||
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: $('#attachment_browse').val(),
|
||
contentType: encodeURIComponent(value)
|
||
}
|
||
|
||
}).complete(eval_ajax);
|
||
<%end%>
|
||
}
|
||
function course_attachtype_edit(value) {
|
||
<% if @course%>
|
||
$.ajax({
|
||
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: $('#attachment_browse').val(),
|
||
contentType: encodeURIComponent(value)
|
||
}
|
||
|
||
}).complete(eval_ajax);
|
||
<%end%>
|
||
}
|
||
|
||
function attachmenttypes_change(id, type) {
|
||
<% if @project%>
|
||
$.ajax({
|
||
url: '<%=updateType_attachments_path%>',
|
||
type: "POST",
|
||
data: {
|
||
attachmentid: encodeURIComponent(id),
|
||
newtype: encodeURIComponent(type)
|
||
}
|
||
|
||
}).complete(function (xhr, textStatus) {
|
||
|
||
if (textStatus == 'success') {
|
||
$.ajax({
|
||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: $('#attachment_browse').val(),
|
||
contentType: $('#attach_sufix_browse').val()
|
||
}
|
||
}).error(function () {
|
||
alert('error');
|
||
});
|
||
} else if (textStatus == 'error') {
|
||
alert('An error has occurred');
|
||
}
|
||
});
|
||
<%end%>
|
||
|
||
}
|
||
|
||
function course_attachmenttypes_change(id, type) {
|
||
<% if @course%>
|
||
$.ajax({
|
||
url: '<%=updateType_attachments_path%>',
|
||
type: "POST",
|
||
data: {
|
||
attachmentid: encodeURIComponent(id),
|
||
newtype: encodeURIComponent(type)
|
||
}
|
||
|
||
}).complete(function (xhr, textStatus) {
|
||
|
||
if (textStatus == 'success') {
|
||
$.ajax({
|
||
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||
type: "POST",
|
||
data: {
|
||
type: $('#attachment_browse').val(),
|
||
contentType: $('#attach_sufix_browse').val()
|
||
}
|
||
}).error(function () {
|
||
alert('error');
|
||
});
|
||
} else if (textStatus == 'error') {
|
||
alert('An error has occurred');
|
||
}
|
||
});
|
||
<%end%>
|
||
|
||
}
|
||
|
||
// 编辑文件密级
|
||
function file_dense_edit(id, type) {
|
||
$.ajax({
|
||
url: '<%=updateFileDense_attachments_path%>',
|
||
type: "POST",
|
||
remote:"true",
|
||
data: {
|
||
attachmentid: encodeURIComponent(id),
|
||
newtype: encodeURIComponent(type)
|
||
}
|
||
|
||
}).complete(function (xhr, textStatus) {
|
||
});
|
||
|
||
}
|
||
<% if @course %>
|
||
var tagNameHtml; //当前双击的链接的父节点的html
|
||
var tagName; //标签的值
|
||
var parentCssBorder; //当前双击的链接的父节点
|
||
var ele; //当前双击的链接
|
||
var tagId; //标签的id
|
||
var taggableType; //被标签的类型
|
||
//这里renameTag有两种情况,一种是改变某个资源的tag名称。如果其他资源也有这个tag。则新增一个改变后的tag名
|
||
//第二种是改变某个tag名称。其他所有的资源如果拥有这个tag。那么对应的tag名也要改掉。
|
||
//目前这两种依据 的来源就是 是否 传了参数 id。如果有id。就指定了资源id,就是第一种情况。如果没有id。就是第二种情况
|
||
function rename_tag(domEle,name,id,type){
|
||
if(String(id) != '' || '<%=User.current.allowed_to?(:as_teacher,@course)%>' == 'true' ) { //如果有id ,或者是老师就都能编辑,否则,没有id,不是老师就不能编辑
|
||
isdb = true; //这是双击
|
||
//clearTimeout(clickFunction);
|
||
if (domEle.children().get(0) != undefined) { //已经是编辑框的情况下不要动
|
||
return;
|
||
}
|
||
tagNameHtml = domEle.parent().html()
|
||
tagName = name;
|
||
parentCssBorder = domEle.parent().css("border");
|
||
ele = domEle;
|
||
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.parent().css("border", "1px solid #ffffff");
|
||
$("#renameTagName").focus();
|
||
}
|
||
}
|
||
//监听所有的单击事件
|
||
$(function(){
|
||
$("#renameTagName").live("blur",function(){
|
||
updateTagName();
|
||
}).live("keypress",function(e){
|
||
if (e.keyCode == '13') {
|
||
updateTagName();
|
||
}
|
||
});
|
||
});
|
||
|
||
//执行修改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>
|
||
|
||
|
||
<script type='text/javascript'>
|
||
function tagAddClick(divid, objId, objTag) {
|
||
alert("OK");
|
||
$.ajax({
|
||
type: "POST",
|
||
url: '/users/tag_saveEx',
|
||
data: {
|
||
tagname: $('tag_name').value,
|
||
obj_id: encodeURIComponent(objId),
|
||
obj_flag: encodeURIComponent(objTag)
|
||
},
|
||
success: function (data, textStatus) {
|
||
alert("OK");
|
||
$(divid).empty();
|
||
$(divid).html('123');
|
||
$("#" + divid + " #name").val("");
|
||
}
|
||
})
|
||
}
|
||
</script>
|