socialforge/app/views/files/index.html.erb

233 lines
7.0 KiB
Plaintext
Raw Normal View History

<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
<% if @isproject %>
<%= render :partial => 'project_file', locals: {project: @project} %>
<% else %>
<%= render :partial => 'course_file', locals: {course: @course} %>
<% end %>
2013-09-23 09:32:04 +08:00
2014-05-09 17:13:23 +08:00
<script type='text/javascript'>
var slideHeight = 29;
2014-05-14 17:12:04 +08:00
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();
2014-05-14 17:12:04 +08:00
} else {
$tags_area.animate({
height: slideHeight
}, 'normal');
$read_more_a.html('更多');
$icona.html('<%=image_tag "/images/sidebar/add.png"%>')
$tags_gradint.fadeIn();
2014-05-14 17:12:04 +08:00
}
;
}
$(function () {
var slideHeight = 20; //px
var defHeight = $('.tags_area').height();
if (defHeight >= slideHeight) {
2014-05-14 17:12:04 +08:00
$('.tags_area').css('height', slideHeight + 'px');
}
;
});
function eval_ajax(xhr, textStatus) {
2014-05-14 17:12:04 +08:00
if (textStatus == 'success') {
eval(xhr.responseText);
} else if (textStatus == 'error') {
alert('error');
}
}
2014-06-10 15:44:37 +08:00
function attachment_contenttypes_searchex(value) {
<% if @project%>
$.ajax({
2014-06-10 15:44:37 +08:00
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
type: "POST",
data: {
2014-06-10 15:44:37 +08:00
type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value)
}
}).complete(eval_ajax);
2014-06-10 15:44:37 +08:00
<%end%>
}
2014-06-10 15:44:37 +08:00
function attachtype_edit(value) {
<% if @project%>
$.ajax({
2014-05-14 17:12:04 +08:00
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
type: "POST",
data: {
type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value)
}
2014-05-14 17:12:04 +08:00
}).complete(eval_ajax);
2014-06-10 15:44:37 +08:00
<%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%>
}
2014-06-10 15:44:37 +08:00
function course_attachmenttypes_searchex(value) {
<% if @course%>
$.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST",
data: {
2014-06-10 15:44:37 +08:00
type: encodeURIComponent(value),
contentType: $('#attach_sufix_browse').val()
}
}).complete(eval_ajax);
2014-06-10 15:44:37 +08:00
<%end%>
}
2014-06-10 15:44:37 +08:00
function course_attachment_contenttypes_searchex(value) {
<% if @course%>
$.ajax({
2014-06-10 15:44:37 +08:00
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
2014-05-14 17:12:04 +08:00
type: "POST",
data: {
type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value)
}
2014-05-14 17:12:04 +08:00
}).complete(eval_ajax);
2014-06-10 15:44:37 +08:00
<%end%>
}
function course_attachtype_edit(value) {
2014-06-10 15:44:37 +08:00
<% if @course%>
$.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST",
data: {
type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value)
}
}).complete(eval_ajax);
2014-06-10 15:44:37 +08:00
<%end%>
}
2014-05-14 17:12:04 +08:00
function attachmenttypes_change(id, type) {
2014-06-10 15:44:37 +08:00
<% if @project%>
$.ajax({
2014-05-14 17:12:04 +08:00
url: '<%=updateType_attachments_path%>',
type: "POST",
data: {
attachmentid: encodeURIComponent(id),
newtype: encodeURIComponent(type)
}
}).complete(function (xhr, textStatus) {
2014-06-10 15:44:37 +08:00
if (textStatus == 'success') {
$.ajax({
2014-05-14 17:12:04 +08:00
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()
2014-05-14 17:12:04 +08:00
}
}).error(function () {
alert('error');
});
} else if (textStatus == 'error') {
2014-05-14 18:33:27 +08:00
alert('An error has occurred');
}
});
2014-06-10 15:44:37 +08:00
<%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>