You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/views/libraries/show.html.erb

139 lines
6.1 KiB

6 years ago
<%
admin_or_self = admin_or_business? || @library.user_id == User.current.id
6 years ago
%>
6 years ago
<div class="educontent mb50">
<p class="mt10 mb20 clearfix lineh-20">
<%= link_to '教学案例', libraries_path, class: 'color-grey-9' %> &gt;
6 years ago
<span class="color-grey-3">详情</span>
6 years ago
</p>
<p class="lineh-25 mb20 clearfix">
<span class="font-22 fl mr10 task-hide" style="max-width: 800px">
<%= @library.title %>
</span>
6 years ago
<%= show_library_tags(@library) %>
6 years ago
<% if admin_or_self %>
<% if @library.pending? %>
6 years ago
<span class="fl edu-filter-btn edu-activity-green mt3 ml10">草稿</span>
6 years ago
<% elsif @library.processing? %>
6 years ago
<span class="fl edu-filter-btn edu-activity-green mt3 ml10">审核中</span>
6 years ago
<% elsif @library.refused? %>
6 years ago
<span class="fl edu-filter-btn edu-activity-orange mt3 ml10">未通过</span>
6 years ago
<% end %>
<% end %>
<%= link_to('返回', libraries_path, class: 'fr color-grey-9 mt5') %>
6 years ago
</p>
<div class="edu-back-white">
6 years ago
<% if admin_or_self && !@library.published? && @library_applies.size > 0 %>
6 years ago
<div class="padding30 bor-bottom-greyE">
6 years ago
<p class="mb10 clearfix">
<span class="color-grey-6 font-16 mr10">私有化原因</span>
<span class="color-grey-c font-12">(请按照提示修改,并在完成编辑后重新提交)</span>
6 years ago
<a href="javascript:void(0)" class="color-blue fr" id="actionPanel" at="0" onclick="getMore(this)"></a>
6 years ago
6 years ago
<div class="private_reason">
6 years ago
<ul id="private_reason_ul">
6 years ago
<% @library_applies.each do |apply| %>
<li>
<p class="color-grey-9"><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></p>
<p class="lineh-25 font-16 break-word"><%= apply.reason %></p>
</li>
<% end %>
6 years ago
</ul>
6 years ago
</div>
6 years ago
</div>
6 years ago
<% end %>
6 years ago
<div class="padding30">
6 years ago
<div class="df">
<%= link_to image_tag(url_to_avatar(@library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(@library.user) %>
6 years ago
<div class="flex1">
<li class="clearfix">
<span class="font-16 fl"><%= @library.user.show_real_name %></span>
<% if admin_or_business? || @library.user_id == User.current.id && @library.pending? %>
<%= link_to '删除', 'javascript:void(0);', data: { id: @library.id },
class: 'white-btn edu-blueline-btn fr ml20 delete-btn' %>
<% end %>
<% if admin_or_self %>
<%= link_to '编辑', edit_library_path(id: @library.id), class: 'white-btn edu-blueline-btn fr' %>
<% end %>
</li>
6 years ago
<li class="clearfix">
6 years ago
<span class="fl color-grey-9 mr20"><%= @library.user.school_name %></span>
<span class="fl color-grey-9"><%= @library.user.identity %></span>
6 years ago
<span class="fr">
<span class="fl color-grey-9 mr30">编码:<span class="color-grey-6"><%= @library.uuid %></span></span>
<% if @library.published? %>
<span class="fl color-grey-9">发布时间:<span class="color-grey-6"><%= @library.published_at.strftime('%Y-%m-%d %H:%M') %></span></span>
<% else %>
6 years ago
<span class="fl color-grey-9">上传时间:<span class="color-grey-6"><%= @library.created_at.strftime('%Y-%m-%d %H:%M') %></span></span>
<% end %>
6 years ago
</span>
</li>
</div>
</div>
<div>
6 years ago
<div class="break_full_word new_li" id="labraries_editorMd_content" style="box-sizing: border-box">
6 years ago
<textarea style="display:none;"><%= @library.content %></textarea>
6 years ago
</div>
6 years ago
<div class="mt10 pl20">
6 years ago
<%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %>
6 years ago
</div>
</div>
</div>
</div>
</div>
<script>
function getMore(item) {
var at=$(item).attr("at");
var one=parseInt($("#private_reason_ul").find("li").eq(0).height())+10;
var two=parseInt($("#private_reason_ul").find("li").eq(1).height());
var plus=one+two;
6 years ago
if(at=="0"){
$(item).html('点击收起<i class="iconfont icon-shangjiantou color-blue font-14 ml5"></i>');
$(item).attr("at","1");
6 years ago
$(".private_reason").css({maxHeight:"unset"});
6 years ago
}else{
$(item).html('点击展开<i class="iconfont icon-xiajiantou color-blue font-14 ml5"></i>');
$(item).attr("at","0");
$(".private_reason").css({maxHeight:plus+"px"});
6 years ago
}
}
var homeworkDescr = editormd.markdownToHTML("labraries_editorMd_content", {
htmlDecode: "style,script,iframe", // you can filter tags decode
taskList: true,
tex: true, // 默认不解析
flowChart: true, // 默认不解析
sequenceDiagram: true // 默认不解析
});
6 years ago
$(function(){
// 删除
$('.delete-btn').on('click', function(){
var id = $(this).data('id');
op_confirm_tip_1("是否确认删除?", "destroyLibrary(" + id + ");")
});
if ($('#private_reason_ul').length != 0) {
6 years ago
var height=document.getElementById("private_reason_ul").offsetHeight;
var one=parseInt($("#private_reason_ul").find("li").eq(0).height())+10;
var two=parseInt($("#private_reason_ul").find("li").eq(1).height());
var plus=one+two;
6 years ago
if(parseInt(height)>166){
$("#actionPanel").html('点击展开<i class="iconfont icon-xiajiantou color-blue font-14 ml5"></i>');
$(".private_reason").css({maxHeight:plus+"px"});
6 years ago
}
}
6 years ago
})
function destroyLibrary (id) {
$.ajax({
type: "DELETE",
url: "<%= libraries_path %>/" + id,
success: function (data) {
if(data && data.status == 0){
notice_box_redirect("<%= libraries_path %>", "删除成功");
} else {
notice_box(data.message);
}
}
});
}
6 years ago
</script>