Signed-off-by: alan <547533434@qq.com>

This commit is contained in:
alan 2014-10-28 22:34:51 +08:00
parent 78af80394a
commit dde40ed3b3
6 changed files with 283 additions and 268 deletions

View File

@ -84,7 +84,7 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder(sort).all @containers += @project.versions.includes(:attachments).reorder(sort).all
getattachtype
show_attachments @containers show_attachments @containers
render :layout => !request.xhr? render :layout => !request.xhr?
@ -122,6 +122,7 @@ class FilesController < ApplicationController
end end
end end
end end
getattachtype
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
show_attachments @containers show_attachments @containers
@ -275,8 +276,7 @@ class FilesController < ApplicationController
respond_to do |format| respond_to do |format|
format.js format.js
format.html
end end
end end
end end

View File

@ -2,11 +2,11 @@
<% attachmenttypes = @course.attachmenttypes %> <% attachmenttypes = @course.attachmenttypes %>
<% sufixtypes = @course.contenttypes %> <% sufixtypes = @course.contenttypes %>
<span class="borad-title"> <span class="borad-title"><%= t(:label_user_course) %>资源共享区</span>
<%= l(:label_coursefile_sharingarea) %>
</span>
<div class="content-title-top"> <div class="content-title-top">
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @course) %>
<div class="clearfix"></div> <div class="clearfix"></div>
<div id="file_buttons" class="nhidden"> <div id="file_buttons" class="nhidden">
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %> <%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %>
@ -55,7 +55,7 @@
<% if sufixtypes.any? %> <% if sufixtypes.any? %>
&nbsp; &nbsp;
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label> <label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') + options_for_select(sufixtypes), <%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
:onchange => "course_attachment_contenttypes_searchex(this.value)" %> :onchange => "course_attachment_contenttypes_searchex(this.value)" %>
<% end %> <% end %>
</div> </div>
@ -69,4 +69,5 @@
<div id="all_browse_div" class="all_browse_div"> <div id="all_browse_div" class="all_browse_div">
<%= render :partial => 'course_show_all_attachment' %> <%= render :partial => 'course_show_all_attachment' %>
</div> </div>
<% html_title(l(:label_course_file)) -%>
<% html_title(l(:label_attachment_plural)) -%>

View File

@ -72,4 +72,4 @@
<%= render :partial => 'show_all_attachment' %> <%= render :partial => 'show_all_attachment' %>
</div> </div>
<% html_title(l(:project_module_files)) -%> <% html_title(l(:label_attachment_plural)) -%>

View File

@ -0,0 +1,13 @@
<% if @attachtype==0 && @contenttype=='0' %>
<% if @project%>
<%= render partial: "show_all_attachment"%>
<% elsif @course%>
<%= render partial: "course_show_all_attachment"%>
<%end%>
<%else%>
<% if @project%>
<%= render partial: "sort_by_attachtypel"%>
<% elsif @course%>
<%= render partial: "course_sort_by_attachtypel"%>
<%end%>;
<%end%>

View File

@ -1,13 +1,13 @@
<% if @attachtype==0 && @contenttype=='0' %> <% if @attachtype==0 && @contenttype=='0' %>
<% if @project%> <% if @project%>
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); $("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
<% elsif @course%> <% elsif @course%>
$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); $("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>');
<%end%> <%end%>
<%else%> <%else%>
<% if @project%> <% if @project%>
$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>') $("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>')
<% elsif @course%> <% elsif @course%>
$("#all_browse_div").html('<%= j(render partial: "course_sort_by_attachtypel")%>') $("#all_browse_div").html('<%= j(render partial: "course_sort_by_attachtypel")%>')
<%end%>; <%end%>;
<%end%> <%end%>

View File

@ -1,248 +1,249 @@
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 --> <!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
<% if @isproject %> <% if @isproject %>
<%= render :partial => 'project_file', locals: {project: @project} %> <%= render :partial => 'project_file', locals: {project: @project} %>
<% else %> <% else %>
<%= render :partial => 'course_file', locals: {course: @course} %> <%= render :partial => 'course_file', locals: {course: @course} %>
<% end %> <% end %>
<script type='text/javascript'> <script type='text/javascript'>
var slideHeight = 29; var slideHeight = 29;
function readmore(aNode) { function readmore(aNode) {
// console.log(aNode) // console.log(aNode)
// var $td_tags_area = $(aNode).parent().parent(); // var $td_tags_area = $(aNode).parent().parent();
var $td_tags_area = $(aNode).parent().parent().parent().parent(); var $td_tags_area = $(aNode).parent().parent().parent().parent();
var $tags_area = $td_tags_area.find('.tags_area') var $tags_area = $td_tags_area.find('.tags_area')
var $tags_gradint = $td_tags_area.find('.tags_gradint') var $tags_gradint = $td_tags_area.find('.tags_gradint')
var $read_more = $td_tags_area.find('.read-more') var $read_more = $td_tags_area.find('.read-more')
var $read_more_a = $td_tags_area.find('.read-more a') var $read_more_a = $td_tags_area.find('.read-more a')
var $tags = $td_tags_area.find('#tags') var $tags = $td_tags_area.find('#tags')
var $icona = $td_tags_area.find('.tags_icona') var $icona = $td_tags_area.find('.tags_icona')
var slideHeight = 13; //px var slideHeight = 13; //px
var defHeight = $tags.height(); var defHeight = $tags.height();
var curHeight = $tags_area.height(); var curHeight = $tags_area.height();
if (curHeight == slideHeight) { if (curHeight == slideHeight) {
$tags_area.animate({ $tags_area.animate({
height: defHeight height: defHeight
}, 'normal'); }, 'normal');
$read_more_a.html('隐藏'); $read_more_a.html('隐藏');
$icona.html('<%=image_tag "/images/sidebar/minus.png"%>') $icona.html('<%=image_tag "/images/sidebar/minus.png"%>')
$tags_gradint.fadeOut(); $tags_gradint.fadeOut();
} else { } else {
$tags_area.animate({ $tags_area.animate({
height: slideHeight height: slideHeight
}, 'normal'); }, 'normal');
$read_more_a.html('更多'); $read_more_a.html('更多');
$icona.html('<%=image_tag "/images/sidebar/add.png"%>') $icona.html('<%=image_tag "/images/sidebar/add.png"%>')
$tags_gradint.fadeIn(); $tags_gradint.fadeIn();
} }
; ;
} }
$(function () { $(function () {
var slideHeight = 20; //px var slideHeight = 20; //px
var defHeight = $('.tags_area').height(); var defHeight = $('.tags_area').height();
if (defHeight >= slideHeight) { if (defHeight >= slideHeight) {
$('.tags_area').css('height', slideHeight + 'px'); $('.tags_area').css('height', slideHeight + 'px');
} }
; ;
}); });
function eval_ajax(xhr, textStatus) { function eval_ajax(xhr, textStatus) {
if (textStatus == 'success') { if (textStatus == 'success') {
eval(xhr.responseText); eval(xhr.responseText);
} else if (textStatus == 'error') { } else if (textStatus == 'error') {
// alert('error'); alert('error');
} }
} }
function attachment_contenttypes_searchex(value) { function attachment_contenttypes_searchex(value) {
<% if @project%> <% if @project%>
$.ajax({ $.ajax({
url: '<%=getattachtype_project_files_path(project_id: @project)%>', url: '<%=getattachtype_project_files_path(project_id: @project)%>',
type: "POST", type: "POST",
data: { data: {
type: $('#attachment_browse').val(), type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value) contentType: encodeURIComponent(value)
} }
}).complete(eval_ajax); }).complete(eval_ajax);
<%end%> <%end%>
} }
function attachtype_edit(value) { function attachtype_edit(value) {
<% if @project%> <% if @project%>
$.ajax({ $.ajax({
url: '<%=getattachtype_project_files_path(project_id: @project)%>', url: '<%=getattachtype_project_files_path(project_id: @project)%>',
type: "POST", type: "POST",
data: { data: {
type: $('#attachment_browse').val(), type: $('#attachment_browse').val(),
contentType: encodeURIComponent(value) contentType: encodeURIComponent(value)
} }
}).complete(eval_ajax); }).complete(eval_ajax);
<%end%> <%end%>
} }
function attachmenttypes_searchex(value) { function attachmenttypes_searchex(value) {
<% if @project%> <% if @project%>
$.ajax({ $.ajax({
url: '<%=getattachtype_project_files_path(project_id: @project)%>', url: '<%=getattachtype_project_files_path(project_id: @project)%>',
type: "POST", type: "POST",
data: { data: {
type: encodeURIComponent(value), type: encodeURIComponent(value),
contentType: $('#attach_sufix_browse').val() contentType: $('#attach_sufix_browse').val()
} }
}).complete(eval_ajax); }).complete(eval_ajax);
<%end%> <%end%>
} }
function course_attachmenttypes_searchex(value) { function course_attachmenttypes_searchex(value) {
<% if @course %> <% if @course%>
$.ajax({ $.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>', url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST", type: "POST",
data: { data: {
type: encodeURIComponent(value), type: encodeURIComponent(value),
contentType: $('#attach_sufix_browse').val() contentType: $('#attach_sufix_browse').val()
} }
}).complete(eval_ajax); }).complete(eval_ajax);
<%end%> <%end%>
} }
function course_attachment_contenttypes_searchex(value) { function course_attachment_contenttypes_searchex(value) {
<% if @course%> <% if @course%>
$.ajax({ $.ajax({
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
type: "POST", url: '<%=getattachtype_course_files_path(course_id: @course)%>',
data: { type: "POST",
type: $('#attachment_browse').val(), data: {
contentType: encodeURIComponent(value) type: $('#attachment_browse').val(),
} contentType: encodeURIComponent(value)
}
}).complete(eval_ajax);
<%end%> }).complete(eval_ajax);
} <%end%>
function course_attachtype_edit(value) { }
<% if @course%> function course_attachtype_edit(value) {
$.ajax({ <% if @course%>
url: '<%=getattachtype_course_files_path(course_id: @course)%>', $.ajax({
type: "POST", url: '<%=getattachtype_course_files_path(course_id: @course)%>',
data: { type: "POST",
type: $('#attachment_browse').val(), data: {
contentType: encodeURIComponent(value) type: $('#attachment_browse').val(),
} contentType: encodeURIComponent(value)
}
}).complete(eval_ajax);
<%end%> }).complete(eval_ajax);
} <%end%>
}
function attachmenttypes_change(id, type) {
<% if @project%> function attachmenttypes_change(id, type) {
$.ajax({ <% if @project%>
url: '<%=updateType_attachments_path%>', $.ajax({
type: "POST", url: '<%=updateType_attachments_path%>',
data: { type: "POST",
attachmentid: encodeURIComponent(id), data: {
newtype: encodeURIComponent(type) attachmentid: encodeURIComponent(id),
} newtype: encodeURIComponent(type)
}
}).complete(function (xhr, textStatus) {
}).complete(function (xhr, textStatus) {
if (textStatus == 'success') {
$.ajax({ if (textStatus == 'success') {
url: '<%=getattachtype_project_files_path(project_id: @project)%>', $.ajax({
type: "POST", url: '<%=getattachtype_project_files_path(project_id: @project)%>',
data: { type: "POST",
type: $('#attachment_browse').val(), data: {
contentType: $('#attach_sufix_browse').val() type: $('#attachment_browse').val(),
} contentType: $('#attach_sufix_browse').val()
}).error(function () { }
alert('error'); }).error(function () {
}); alert('error');
} else if (textStatus == 'error') { });
alert('An error has occurred'); } else if (textStatus == 'error') {
} alert('An error has occurred');
}); }
<%end%> });
<%end%>
}
}
function course_attachmenttypes_change(id, type) {
<% if @course%> function course_attachmenttypes_change(id, type) {
$.ajax({ <% if @course%>
url: '<%=updateType_attachments_path%>', $.ajax({
type: "POST", url: '<%=updateType_attachments_path%>',
data: { type: "POST",
attachmentid: encodeURIComponent(id), data: {
newtype: encodeURIComponent(type) attachmentid: encodeURIComponent(id),
} newtype: encodeURIComponent(type)
}
}).complete(function (xhr, textStatus) {
}).complete(function (xhr, textStatus) {
if (textStatus == 'success') {
$.ajax({ if (textStatus == 'success') {
url: '<%=getattachtype_course_files_path(course_id: @course)%>', $.ajax({
type: "POST", url: '<%=getattachtype_course_files_path(course_id: @course)%>',
data: { type: "POST",
type: $('#attachment_browse').val(), data: {
contentType: $('#attach_sufix_browse').val() type: $('#attachment_browse').val(),
} contentType: $('#attach_sufix_browse').val()
}).error(function () { }
alert('error'); }).error(function () {
}); alert('error');
} else if (textStatus == 'error') { });
alert('An error has occurred'); } else if (textStatus == 'error') {
} alert('An error has occurred');
}); }
<%end%> });
<%end%>
}
}
// 编辑文件密级
function file_dense_edit(id, type) { // 编辑文件密级
$.ajax({ function file_dense_edit(id, type) {
url: '<%=updateFileDense_attachments_path%>', $.ajax({
type: "POST", url: '<%=updateFileDense_attachments_path%>',
remote:"true", type: "POST",
data: { remote:"true",
attachmentid: encodeURIComponent(id), data: {
newtype: encodeURIComponent(type) attachmentid: encodeURIComponent(id),
} newtype: encodeURIComponent(type)
}
}).complete(function (xhr, textStatus) {
}); }).complete(function (xhr, textStatus) {
});
}
}
</script>
</script>
<script type='text/javascript'>
function tagAddClick(divid, objId, objTag) { <script type='text/javascript'>
alert("OK"); function tagAddClick(divid, objId, objTag) {
$.ajax({ alert("OK");
type: "POST", $.ajax({
url: '/users/tag_saveEx', type: "POST",
data: { url: '/users/tag_saveEx',
tagname: $('tag_name').value, data: {
obj_id: encodeURIComponent(objId), tagname: $('tag_name').value,
obj_flag: encodeURIComponent(objTag) obj_id: encodeURIComponent(objId),
}, obj_flag: encodeURIComponent(objTag)
success: function (data, textStatus) { },
alert("OK"); success: function (data, textStatus) {
$(divid).empty(); alert("OK");
$(divid).html('123'); $(divid).empty();
$("#" + divid + " #name").val(""); $(divid).html('123');
} $("#" + divid + " #name").val("");
}) }
} })
</script> }
</script>