2015-04-29 17:50:35 +08:00
|
|
|
<script type="text/javascript">
|
2015-04-30 10:47:34 +08:00
|
|
|
|
2015-04-30 17:24:30 +08:00
|
|
|
jQuery(window).load(function () {
|
|
|
|
jQuery(".issue_attachment_picture").each(function () {
|
|
|
|
DrawImage(this, 100, 73);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
function DrawImage(ImgD, FitWidth, FitHeight) {
|
|
|
|
var image = new Image();
|
|
|
|
image.src = ImgD.src;
|
|
|
|
if (image.width > 100 || image.height > 73)
|
|
|
|
{
|
|
|
|
rateWidth = image.width / 100;
|
|
|
|
rateHeight = image.height / 73;
|
|
|
|
if (rateWidth > rateHeight) {
|
|
|
|
ImgD.width = 100;
|
|
|
|
ImgD.height = Math.round(image.height/rateWidth);
|
2015-04-29 17:50:35 +08:00
|
|
|
}
|
2015-04-30 10:47:34 +08:00
|
|
|
else
|
|
|
|
{
|
2015-04-30 17:24:30 +08:00
|
|
|
ImgD.width = Math.round(image.width/rateHeight);
|
|
|
|
ImgD.height = 73;
|
2015-04-29 17:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
2015-04-30 17:24:30 +08:00
|
|
|
}
|
2015-04-29 17:50:35 +08:00
|
|
|
</script>
|
2015-04-30 10:47:34 +08:00
|
|
|
|
2015-04-07 12:48:47 +08:00
|
|
|
<div class="attachments" style="font-weight:normal;">
|
|
|
|
<% is_float ||= false %>
|
|
|
|
<% for attachment in attachments %>
|
2015-05-19 12:22:53 +08:00
|
|
|
<div style="float:left;">
|
2015-07-28 17:17:52 +08:00
|
|
|
<p style="height:14px;line-height:12px;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
|
|
|
<%if is_float%>
|
|
|
|
<div style="max-width:55%;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;float: left;">
|
|
|
|
<% end%>
|
|
|
|
<span title="<%= attachment.filename %>" id = "attachment_">
|
2015-04-07 12:48:47 +08:00
|
|
|
<% if options[:length] %>
|
2016-09-19 10:01:22 +08:00
|
|
|
<% if User.current.logged? %>
|
|
|
|
<%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%>
|
|
|
|
<% else %>
|
|
|
|
<%= link_to(attachment.filename, signin_url_without_domain, :class => "link_file_board", :length => options[:length]) %>
|
|
|
|
<% end %>
|
2015-04-07 12:48:47 +08:00
|
|
|
<% else %>
|
2016-09-19 10:01:22 +08:00
|
|
|
<% if User.current.logged? %>
|
|
|
|
<%= link_to_short_attachment attachment, :length=> 58,:class => 'hidden link_file_a fl newsBlue mw400', :download => true -%>
|
|
|
|
<% else %>
|
|
|
|
<%= link_to(attachment.filename, signin_url_without_domain,:length=> 58, :class => "hidden link_file_a fl newsBlue mw400") %>
|
|
|
|
<% end %>
|
2015-04-07 12:48:47 +08:00
|
|
|
<% end %>
|
|
|
|
</span>
|
2015-07-28 17:17:52 +08:00
|
|
|
<%if is_float%>
|
|
|
|
</div>
|
|
|
|
<% end%>
|
2015-04-07 12:48:47 +08:00
|
|
|
|
2015-07-28 17:17:52 +08:00
|
|
|
<% if attachment.is_text? %>
|
|
|
|
<%= link_to image_tag('magnifier.png'),
|
|
|
|
:controller => 'attachments',
|
|
|
|
:action => 'show',
|
|
|
|
:id => attachment,
|
|
|
|
:filename => attachment.filename%>
|
|
|
|
<% end %>
|
2015-05-19 12:22:53 +08:00
|
|
|
</div>
|
|
|
|
<div style="float:left;max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="<%= attachment.description%>">
|
2015-07-28 17:17:52 +08:00
|
|
|
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
|
|
|
</div>
|
2015-04-07 12:48:47 +08:00
|
|
|
<span class="size">(
|
|
|
|
<%= number_to_human_size attachment.filesize %>)
|
|
|
|
</span>
|
|
|
|
<% if options[:deletable] %>
|
|
|
|
<% if attachment.container_type == 'HomeworkAttach' %>
|
|
|
|
<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
|
|
|
|
:data => {:confirm => l(:text_are_you_sure)},
|
|
|
|
:method => :delete,
|
|
|
|
:class => 'delete delete-homework-icon',
|
|
|
|
:remote => true,
|
|
|
|
:title => l(:button_delete) %>
|
2015-07-28 17:17:52 +08:00
|
|
|
<% elsif attachment.container_type == 'Issue' %>
|
|
|
|
<% if User.current == attachment.author %>
|
|
|
|
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
|
|
|
:data => {:confirm => l(:text_are_you_sure)},
|
|
|
|
:method => :delete,
|
|
|
|
:class => 'delete',
|
|
|
|
#:remote => true,
|
|
|
|
#:id => "attachments_" + attachment.id.to_s,
|
|
|
|
:title => l(:button_delete) %>
|
|
|
|
<% end %>
|
2015-04-07 12:48:47 +08:00
|
|
|
<% else %>
|
|
|
|
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
|
|
|
:data => {:confirm => l(:text_are_you_sure)},
|
|
|
|
:method => :delete,
|
|
|
|
:class => 'delete',
|
|
|
|
#:remote => true,
|
|
|
|
#:id => "attachments_" + attachment.id.to_s,
|
|
|
|
:title => l(:button_delete) %>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if options[:wrap] %>
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<% end %>
|
|
|
|
<% if options[:author] %>
|
2016-09-14 17:27:21 +08:00
|
|
|
<span class="author" title="<%= attachment.author.show_name%>">
|
2016-09-19 10:01:22 +08:00
|
|
|
<%= link_to h(truncate(attachment.author.show_name, length: 10, omission: '...')), User.current.logged? ? user_path(attachment.author) : signin_url_without_domain, :class => "link-blue" %>,
|
2015-04-07 12:48:47 +08:00
|
|
|
<%= format_time(attachment.created_on) %>
|
|
|
|
</span>
|
|
|
|
<% end %>
|
|
|
|
</p>
|
|
|
|
<% end %>
|
2015-04-17 14:14:13 +08:00
|
|
|
<div class="thumbnails">
|
2015-07-28 17:17:52 +08:00
|
|
|
<% if defined?(thumbnails) && thumbnails %>
|
|
|
|
<% images = attachments.select(&:thumbnailable?) %>
|
|
|
|
<% if images.any? %>
|
2015-04-07 12:48:47 +08:00
|
|
|
<% images.each do |attachment| %>
|
2015-04-22 16:49:07 +08:00
|
|
|
<div class="pro_pic fl " width="100" height="73"><%= thumbnail_issue_tag(attachment) %></div>
|
2015-04-07 12:48:47 +08:00
|
|
|
<% end %>
|
2015-07-28 17:17:52 +08:00
|
|
|
<% end %>
|
|
|
|
<% end %>
|
2015-04-17 14:14:13 +08:00
|
|
|
</div>
|
2015-04-07 12:48:47 +08:00
|
|
|
</div>
|