|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
<p class="lineh-25 font-22 mb20">上传教学案例</p>
|
|
|
|
|
<div class="library-form-container">
|
|
|
|
|
<%= form_for(@library) do |f| %>
|
|
|
|
|
<%= form_for(@library, html: { multipart: true }) do |f| %>
|
|
|
|
|
<% tag_ids = @library.library_tags.map(&:id) %>
|
|
|
|
|
<%= hidden_field_tag :apply_publish, false %>
|
|
|
|
|
<%= hidden_field_tag :tag_ids, tag_ids.join(',') %>
|
|
|
|
@ -20,12 +20,12 @@
|
|
|
|
|
<div class="clearfix mt20">
|
|
|
|
|
<span class="upload_Title">作者</span>
|
|
|
|
|
<li class="fl">
|
|
|
|
|
<input class="greyInput winput-300-35 mr20 fl winput150" id="library_title" name="library[author_name]" placeholder="请输入姓名" size="30" type="text" width="163">
|
|
|
|
|
<p style="height:20px;line-height:20px;"><span class="color-red none" id="title_notice">请输入姓名</span></p>
|
|
|
|
|
<%= f.text_field :author_name, placeholder: '请输入姓名', class: 'greyInput winput-300-35 mr20 fl winput150', width: '163', size: 30 %>
|
|
|
|
|
<p style="height:20px;line-height:20px;"><span class="color-red none" id="author_name_notice">请输入姓名</span></p>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="fl">
|
|
|
|
|
<input class="greyInput winput-300-35 mr20 fl" id="library_title" name="library[author_school_name]" placeholder="请输入作者单位名称" size="30" type="text">
|
|
|
|
|
<p style="height:20px;line-height:20px;"><span class="color-red none" id="title_notice">请输入作者单位名称</span></p>
|
|
|
|
|
<%= f.text_field :author_school_name, placeholder: '请输入作者单位名称', class: 'greyInput winput-300-35 mr20 fl', width: '163', size: 30 %>
|
|
|
|
|
<p style="height:20px;line-height:20px;"><span class="color-red none" id="author_school_name_notice">请输入作者单位名称</span></p>
|
|
|
|
|
</li>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -61,38 +61,22 @@
|
|
|
|
|
<p style="height:22px;line-height:22px;"><span class="color-red none" id="file_notice">请上传附件</span></p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="clearfix lineheight35">
|
|
|
|
|
<% cover_exists = @library.cover_id.present? %>
|
|
|
|
|
<% cover_exists = @library.cover_id.present? && !@library.cover_id_changed? %>
|
|
|
|
|
<div><span class="upload_Titles">封面图</span> <span class="color-grey-c">(上传尺寸:120*90 px)</span></div>
|
|
|
|
|
<div class="surfacePlot ml25">
|
|
|
|
|
<img src="/images/educoder/unite.png" class="marginuploading"/>
|
|
|
|
|
|
|
|
|
|
<%= hidden_field_tag 'library[cover_id]', @library.cover_id %>
|
|
|
|
|
<%= hidden_field_tag 'cover_file_name', '', class: 'cover-file-name' %>
|
|
|
|
|
<input type="file" name="cover_file" accept="image/*" id="library-cover-file" style="display: none"/>
|
|
|
|
|
|
|
|
|
|
<div class="surfacePlot ml25 library-cover-select" data-tip-down="上传图片" onclick="$('#library-cover-file').click();">
|
|
|
|
|
<img src="/images/educoder/unite.png" class="marginuploading <%= cover_exists ? 'hidden' : '' %>" style="<%= cover_exists ? 'display:none' : '' %>"/>
|
|
|
|
|
<div class="library-cover-perview" style="<%= cover_exists ? '' : 'display:none' %>">
|
|
|
|
|
<% cover_url = cover_exists ? named_attachment_path(@library.cover.id, @library.cover.filename) : '' %>
|
|
|
|
|
<img src="<%= cover_url %>" width="120px" height="90px"/>
|
|
|
|
|
</div>
|
|
|
|
|
<% if cover_exists %>
|
|
|
|
|
<%= image_tag(named_attachment_path(@library.cover.id, @library.cover.filename), :class => "w120 h90 ml5 shixun_image_show") %>
|
|
|
|
|
<% else %>
|
|
|
|
|
<img src="" class="ml5 shixun_image_show ml50 none" width="150px" height="150px" id="shixun_image_show_<%= @library.id %>"/>
|
|
|
|
|
<% end %>
|
|
|
|
|
<%= file_field_tag 'library[cover_id]',
|
|
|
|
|
:id => "upload_img_#{@library.id}",
|
|
|
|
|
:style => 'display:none;',
|
|
|
|
|
:size => "1",
|
|
|
|
|
:multiple => false,
|
|
|
|
|
:onchange => 'addInputAvatar(this);',
|
|
|
|
|
:data => {
|
|
|
|
|
:max_file_size => Setting.authentication_img_max_size.to_i.kilobytes,
|
|
|
|
|
:max_file_size_message => l(:error_user_auth_too_big, :max_size => number_to_human_size(Setting.authentication_img_max_size.to_i.kilobytes)),
|
|
|
|
|
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
|
|
|
|
:file_type => Redmine::Configuration['pic_types'].to_s,
|
|
|
|
|
:type_support_message => l(:error_pic_type),
|
|
|
|
|
:upload_path => uploads_path(:format => 'js',:project =>nil),
|
|
|
|
|
:description_placeholder => nil ,# l(:label_optional_description)
|
|
|
|
|
} %>
|
|
|
|
|
<div>
|
|
|
|
|
<a href="javascript:void(0);" id="object_upload_img_<%= @library.id %>" class="<%= cover_exists ? "mr10 ml60" : "mr10 ml60 decoration4CACFF" %>" onclick="$('#upload_img_<%= @library.id %>').click();">
|
|
|
|
|
<%= cover_exists ? "重新上传" : "上传图片" %>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<p style="height:20px;line-height:20px;"><span class="color-red ml20 none" id="cover_file_notice">请上传封面</span></p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="padding30 bor-top-greyE">
|
|
|
|
@ -155,6 +139,9 @@
|
|
|
|
|
var submitForm = function(){
|
|
|
|
|
var title = $("input[name='library[title]']").val();
|
|
|
|
|
var content = $("textarea[name='library[content]']").val();
|
|
|
|
|
var author_name = $("input[name='library[author_name]']").val();
|
|
|
|
|
var author_school_name = $("input[name='library[author_school_name]']").val();
|
|
|
|
|
var cover_file = $("input[name='cover_file").val();
|
|
|
|
|
|
|
|
|
|
if (!title || title.length == 0) {
|
|
|
|
|
$("#title_notice").removeClass("none");
|
|
|
|
@ -168,6 +155,25 @@
|
|
|
|
|
}else{
|
|
|
|
|
$("#des_notice").addClass("none");
|
|
|
|
|
}
|
|
|
|
|
if (!author_name || author_name.length == 0) {
|
|
|
|
|
$("#author_name_notice").removeClass("none");
|
|
|
|
|
return
|
|
|
|
|
}else{
|
|
|
|
|
$("#author_name_notice").addClass("none");
|
|
|
|
|
}
|
|
|
|
|
if (!author_school_name || author_school_name.length == 0) {
|
|
|
|
|
$("#author_school_name_notice").removeClass("none");
|
|
|
|
|
return
|
|
|
|
|
}else{
|
|
|
|
|
$("#author_school_name_notice").addClass("none");
|
|
|
|
|
}
|
|
|
|
|
var coverId = $("input[name='library[cover_id]']").val();
|
|
|
|
|
if ((!coverId || coverId.length == 0) && (!cover_file || cover_file.length == 0)) {
|
|
|
|
|
$("#cover_file_notice").removeClass("none");
|
|
|
|
|
return
|
|
|
|
|
}else{
|
|
|
|
|
$("#cover_file_notice").addClass("none");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($('.attachments_fields .attachment').length == 0){
|
|
|
|
|
$("#file_notice").removeClass("none");
|
|
|
|
@ -199,5 +205,26 @@
|
|
|
|
|
console.log('ids', ids)
|
|
|
|
|
$('#tag_ids').val(ids);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$("#library-cover-file").change(function (e) {
|
|
|
|
|
var file = e.target.files[0] || e.dataTransfer.files[0];
|
|
|
|
|
$('input.cover-file-name').val(document.getElementById("library-cover-file").files[0].name);
|
|
|
|
|
if (file) {
|
|
|
|
|
var reader = new FileReader();
|
|
|
|
|
reader.onload = function () {
|
|
|
|
|
$(".library-cover-perview img").attr("src", this.result);
|
|
|
|
|
$('.marginuploading').addClass('hidden').hide();
|
|
|
|
|
$('.library-cover-perview').show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.library-cover-select').hover(function(){
|
|
|
|
|
$('.library-cover-select .marginuploading.hidden').show();
|
|
|
|
|
},function(){
|
|
|
|
|
$('.library-cover-select .marginuploading.hidden').hide();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
</script>
|