2013-11-08 20:09:21 +08:00
|
|
|
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
|
2014-05-12 18:46:39 +08:00
|
|
|
<% attachmenttypes = @project.attachmenttypes %>
|
2014-05-13 15:49:14 +08:00
|
|
|
<% sufixtypes = @project.contenttypes %>
|
2014-05-12 18:46:39 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
<span class="borad-title"><%= (@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区</span>
|
2014-01-21 15:32:00 +08:00
|
|
|
|
2013-11-08 20:09:21 +08:00
|
|
|
<div class="content-title-top">
|
2014-03-07 08:53:05 +08:00
|
|
|
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
2014-03-06 16:47:28 +08:00
|
|
|
<div class="clearfix"></div>
|
2014-03-07 08:53:05 +08:00
|
|
|
<div id="file_buttons" class="nhidden">
|
2014-03-11 10:45:01 +08:00
|
|
|
<%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
2014-05-14 17:12:04 +08:00
|
|
|
<%= 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, @project) %>
|
2014-04-25 16:08:00 +08:00
|
|
|
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
2014-05-12 18:46:39 +08:00
|
|
|
|
|
|
|
<% if attachmenttypes.any? %>
|
2014-05-13 16:34:53 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
|
|
|
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
|
|
|
:onchange => "attachmenttypes_searchex(this.value)" %>
|
|
|
|
<% end %>
|
|
|
|
<% if sufixtypes.any? %>
|
2014-05-13 16:34:53 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
<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),
|
|
|
|
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
2014-05-13 15:49:14 +08:00
|
|
|
<% end %>
|
2014-05-12 18:46:39 +08:00
|
|
|
|
2014-05-30 09:31:04 +08:00
|
|
|
<div id="upload_file_div" class="relation_file_div hidden">
|
|
|
|
<%= render :partial => 'new', locals: {project: @project} %>
|
|
|
|
</div>
|
2014-05-20 11:33:17 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
<div id="relation_file_div" class="relation_file_div hidden">
|
2014-03-06 16:47:28 +08:00
|
|
|
<fieldset>
|
|
|
|
<legend>搜索</legend>
|
2014-05-12 18:46:39 +08:00
|
|
|
<%= form_tag(
|
|
|
|
attachments_autocomplete_path(:format => 'js'),
|
|
|
|
:remote => true,
|
|
|
|
:method => :post) do %>
|
2014-05-14 15:23:26 +08:00
|
|
|
<%= label_tag(:attach_search, "按关键字搜索:") %>
|
|
|
|
<%= text_field_tag(:attach_search) %>
|
2014-05-12 18:46:39 +08:00
|
|
|
<%#= submit_tag("Search") %>
|
|
|
|
<% end -%>
|
|
|
|
<%= form_tag attach_relation_path(:format => 'js'),
|
|
|
|
method: :post,
|
|
|
|
remote: true,
|
2014-05-14 17:12:04 +08:00
|
|
|
id: "relation_file_form",
|
2014-05-12 18:46:39 +08:00
|
|
|
:class => 'hidden' do %>
|
|
|
|
<%= hidden_field_tag(:class_name, 'Project') %>
|
|
|
|
<%= hidden_field_tag(:class_id, params[:project_id]) %>
|
2014-05-14 17:12:04 +08:00
|
|
|
<div id="relation_file">
|
2014-05-12 18:46:39 +08:00
|
|
|
</div>
|
2014-05-14 17:12:04 +08:00
|
|
|
<div class="kclearfix" style='margin-top: 10px;'>
|
2014-05-12 18:46:39 +08:00
|
|
|
<%= submit_tag(l(:button_add)) -%>
|
|
|
|
</div>
|
|
|
|
<% end -%>
|
2014-03-06 16:47:28 +08:00
|
|
|
</fieldset>
|
2014-03-12 08:47:43 +08:00
|
|
|
<div class="line_under" style="margin:20px 0px;"></div>
|
2014-05-12 18:46:39 +08:00
|
|
|
</div>
|
2014-03-06 16:47:28 +08:00
|
|
|
</div>
|
2014-03-01 10:14:01 +08:00
|
|
|
|
2014-05-12 18:46:39 +08:00
|
|
|
</div>
|
2014-03-06 16:47:28 +08:00
|
|
|
<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %>
|
|
|
|
|
2014-01-21 17:04:55 +08:00
|
|
|
|
2013-08-01 10:33:49 +08:00
|
|
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
2014-05-09 17:13:23 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
<div id="all_browse_div" class="all_browse_div">
|
|
|
|
<%= render :partial => 'show_all_attachment' %>
|
2014-05-12 18:46:39 +08:00
|
|
|
</div>
|
2013-08-01 10:33:49 +08:00
|
|
|
|
|
|
|
<% html_title(l(:label_attachment_plural)) -%>
|
2013-09-23 09:32:04 +08:00
|
|
|
|
2014-05-09 17:13:23 +08:00
|
|
|
<script type='text/javascript'>
|
2014-05-12 18:46:39 +08:00
|
|
|
var slideHeight = 29;
|
2014-05-14 17:12:04 +08:00
|
|
|
function readmore(aNode) {
|
2014-05-12 18:46:39 +08:00
|
|
|
// 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')
|
|
|
|
|
2014-05-15 15:52:25 +08:00
|
|
|
var slideHeight = 13; //px
|
2014-05-12 18:46:39 +08:00
|
|
|
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 {
|
2014-05-12 18:46:39 +08:00
|
|
|
$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
|
|
|
}
|
|
|
|
;
|
2014-03-01 10:14:01 +08:00
|
|
|
|
2014-05-12 18:46:39 +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');
|
|
|
|
}
|
|
|
|
;
|
2014-05-12 18:46:39 +08:00
|
|
|
});
|
2014-03-01 10:14:01 +08:00
|
|
|
|
2014-05-30 09:31:04 +08:00
|
|
|
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-05-13 11:54:21 +08:00
|
|
|
|
2014-05-13 15:49:14 +08:00
|
|
|
function attachmenttypes_searchex(value) {
|
|
|
|
$.ajax({
|
2014-05-14 17:12:04 +08:00
|
|
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
|
|
|
type: "POST",
|
|
|
|
data: {
|
|
|
|
type: encodeURIComponent(value),
|
2014-05-30 09:31:04 +08:00
|
|
|
contentType: $('#attach_sufix_browse').val()
|
2014-05-14 17:12:04 +08:00
|
|
|
}
|
2014-03-01 10:14:01 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
}).complete(eval_ajax);
|
2014-05-13 15:49:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function attachment_contenttypes_searchex(value) {
|
|
|
|
$.ajax({
|
2014-05-13 16:34:53 +08:00
|
|
|
|
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-13 15:49:14 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
}).complete(eval_ajax);
|
2014-05-13 15:49:14 +08:00
|
|
|
}
|
2014-05-14 15:03:04 +08:00
|
|
|
|
|
|
|
function attachtype_edit(value) {
|
|
|
|
$.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 15:03:04 +08:00
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
}).complete(eval_ajax);
|
2014-05-14 15:03:04 +08:00
|
|
|
}
|
|
|
|
|
2014-05-14 17:12:04 +08:00
|
|
|
function attachmenttypes_change(id, type) {
|
2014-05-14 15:03:04 +08:00
|
|
|
$.ajax({
|
2014-05-14 17:12:04 +08:00
|
|
|
url: '<%=updateType_attachments_path%>',
|
|
|
|
type: "POST",
|
|
|
|
data: {
|
|
|
|
attachmentid: encodeURIComponent(id),
|
|
|
|
newtype: encodeURIComponent(type)
|
|
|
|
}
|
2014-05-14 15:03:04 +08:00
|
|
|
|
|
|
|
}).complete(function (xhr, textStatus) {
|
|
|
|
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 () {
|
2014-05-30 09:31:04 +08:00
|
|
|
alert('error');
|
|
|
|
});
|
2014-05-14 15:03:04 +08:00
|
|
|
} else if (textStatus == 'error') {
|
2014-05-14 18:33:27 +08:00
|
|
|
alert('An error has occurred');
|
2014-05-14 15:03:04 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-05-20 11:33:17 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type='text/javascript'>
|
2014-05-30 09:31:04 +08:00
|
|
|
function tagAddClick(divid, objId, objTag) {
|
2014-05-20 11:33:17 +08:00
|
|
|
alert("OK");
|
|
|
|
$.ajax({
|
2014-05-30 09:31:04 +08:00
|
|
|
type: "POST",
|
|
|
|
url: '/users/tag_saveEx',
|
2014-05-20 11:33:17 +08:00
|
|
|
data: {
|
|
|
|
tagname: $('tag_name').value,
|
|
|
|
obj_id: encodeURIComponent(objId),
|
2014-05-30 09:31:04 +08:00
|
|
|
obj_flag: encodeURIComponent(objTag)
|
2014-05-20 11:33:17 +08:00
|
|
|
},
|
2014-05-30 09:31:04 +08:00
|
|
|
success: function (data, textStatus) {
|
2014-05-20 11:33:17 +08:00
|
|
|
alert("OK");
|
|
|
|
$(divid).empty();
|
|
|
|
$(divid).html('123');
|
2014-05-30 09:31:04 +08:00
|
|
|
$("#" + divid + " #name").val("");
|
2014-05-20 11:33:17 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|