289 lines
13 KiB
Plaintext
289 lines
13 KiB
Plaintext
<!-- 此界面只用来新建匿评作业作品 -->
|
||
<% content_for :header_tags do %>
|
||
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
|
||
<%= javascript_include_tag 'homework','baiduTemplate' %>
|
||
<% end %>
|
||
|
||
<script type="text/javascript">
|
||
$(function(){
|
||
if(is_IE()){
|
||
$("#_notice_box").show();
|
||
$("#uploadReviseBox").addClass('disable_link');
|
||
$("#upload_file_local").attr("title","IE无法上传");
|
||
$("#upload_file_local").attr("onclick","return false;");
|
||
$("#resource_repo_upload").attr("title","IE无法上传");
|
||
$("#resource_repo_upload").attr("href","javascript:void(0)");
|
||
}
|
||
});
|
||
<% if @contestwork.work_detail_group %>
|
||
$(function(){
|
||
$('span.group_detail_info').text('分组人数:<%=@contestwork.work_detail_group.min_num %>-<%=@contestwork.work_detail_group.max_num %> 人');
|
||
});
|
||
<% end %>
|
||
|
||
// 添加组成员
|
||
function show_group_member() {
|
||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'choose_group_member',:locals => {:homework=>@contestwork}) %>');
|
||
showModal('ajax-modal', '528px');
|
||
$('#ajax-modal').siblings().remove();
|
||
$('#ajax-modal').parent().css("top","").css("left","");
|
||
$('#ajax-modal').parent().addClass("addMemberCP");
|
||
}
|
||
// 关联项目
|
||
function show_project() {
|
||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'relate_project',:locals => {:homework=>@contestwork}) %>');
|
||
showModal('ajax-modal', '320px');
|
||
$('#ajax-modal').siblings().remove();
|
||
$('#ajax-modal').parent().css("top","").css("left","");
|
||
$('#ajax-modal').parent().addClass("groupPopUp");
|
||
}
|
||
// 作品校验
|
||
function popupRegex(){
|
||
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
|
||
showModal('ajax-modal', '500px');
|
||
$('#ajax-modal').siblings().remove();
|
||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||
$('#ajax-modal').parent().addClass("anonymos");
|
||
}
|
||
|
||
function nh_check_field(params){
|
||
var result=true;
|
||
if(!regexStudentWorkName()) {
|
||
result=false;
|
||
return result;
|
||
}
|
||
if(params.content!=undefined){
|
||
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
|
||
result=false;
|
||
}
|
||
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
|
||
params.textarea.html(params.content.html());
|
||
params.content.sync();
|
||
|
||
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
|
||
params.contentmsg.html('作品描述不能为空');
|
||
}else{
|
||
params.contentmsg.html('');
|
||
}
|
||
}
|
||
if(!result) {
|
||
return result;
|
||
}
|
||
}
|
||
if($("#group_member_ids").length > 0) {
|
||
result=regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())));
|
||
}
|
||
return result;
|
||
}
|
||
function init_homework_form(params){
|
||
params.form.submit(function(){
|
||
params.textarea.html(params.editor.html());
|
||
params.editor.sync();
|
||
var flag = false;
|
||
if(params.form.attr('data-remote') != undefined ){
|
||
flag = true
|
||
}
|
||
var is_checked = nh_check_field({
|
||
issubmit:true,
|
||
content:params.editor,
|
||
contentmsg:params.contentmsg,
|
||
textarea:params.textarea
|
||
});
|
||
|
||
if(is_checked){
|
||
if(flag){
|
||
popupRegex();
|
||
return true;
|
||
}else{
|
||
$(this)[0].submit();
|
||
$("#ajax-indicator").hide();
|
||
return false;
|
||
}
|
||
}
|
||
return false;
|
||
});
|
||
}
|
||
function init_homework_editor(params){
|
||
params.textarea.removeAttr('placeholder');
|
||
var editor = params.kindutil.create(params.textarea, {
|
||
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
|
||
items : ['code','emoticons','fontname',
|
||
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
|
||
'formatblock', 'fontsize', '|','indent', 'outdent',
|
||
'|','imagedirectupload','table', 'media', 'preview',"more"
|
||
],
|
||
afterChange:function(){//按键事件
|
||
var edit = this.edit;
|
||
var body = edit.doc.body;
|
||
//paramsHeight = params.kindutil.removeUnit(this.height);
|
||
edit.iframe.height(150);
|
||
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
|
||
},
|
||
afterBlur:function(){
|
||
if(this.isEmpty()) {
|
||
this.edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
|
||
}
|
||
},
|
||
afterFocus: function(){
|
||
var edit = this.edit;
|
||
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
|
||
edit.html('');
|
||
}
|
||
},
|
||
afterCreate:function(){
|
||
//init
|
||
var edit = this.edit;
|
||
var body = edit.doc.body;
|
||
edit.iframe[0].scroll = 'no';
|
||
body.style.overflowY = 'hidden';
|
||
//reset height
|
||
var edit = this.edit;
|
||
var body = edit.doc.body;
|
||
edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
|
||
//paramsHeight = params.kindutil.removeUnit(this.height);
|
||
edit.iframe.height(150);
|
||
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
|
||
elocalStorage(editor2,'student_work_<%=@contestwork.id %>');
|
||
}
|
||
}).loadPlugin('paste');
|
||
return editor;
|
||
}
|
||
KindEditor.ready(function(K){
|
||
$("div[nhname='student_work_form']").each(function(){
|
||
var params = {};
|
||
params.kindutil = K;
|
||
params.div_form = $(this);
|
||
params.form = $("form",params.div_form);
|
||
if(params.form==undefined || params.form.length==0){
|
||
return;
|
||
}
|
||
params.textarea = $("textarea[nhname='student_work_textarea']",params.div_form);
|
||
params.contentmsg = $("#student_work_description_textarea");
|
||
params.submit_btn = $("#new_message_submit_btn");
|
||
if(params.textarea.data('init') == undefined) {
|
||
params.editor = init_homework_editor(params);
|
||
editor2 = params.editor;
|
||
init_homework_form(params);
|
||
params.submit_btn.click(function () {
|
||
params.form.submit();
|
||
$("#ajax-indicator").hide();
|
||
});
|
||
params.textarea.data('init', 1);
|
||
}
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<div class="homepageRight mt0 ml10">
|
||
<div class="homepageRightBanner mb10 ml10">
|
||
<div class="NewsBannerName">提交作品</div>
|
||
</div>
|
||
<div class="cl"></div>
|
||
|
||
<div class="_notice_box text_c none mb10" style="height: 20px; padding: 4px 4px; line-height: 20px;" id="_notice_box">注意:暂不支持IE浏览器的上传,请更换浏览器</div>
|
||
|
||
<div class="HomeWork" id="users_setting">
|
||
<div class="HomeWorkBox">
|
||
<div class="">
|
||
<div class="homepagePostTitle fl m_w530 hidden">
|
||
<%= @contestwork.name%>(竞赛名称)
|
||
</div>
|
||
<span class="fr c_grey">
|
||
截止时间:<%= @contestwork.end_time%>
|
||
</span>
|
||
<div class="cl"></div>
|
||
<a href="javascript:void(0);" class="c_blue">
|
||
<%= link_to @contestwork.user.show_name, user_activities_path(@contestwork.user_id), :class => "c_blue"%>
|
||
</a>
|
||
<div class="cl"></div>
|
||
<div class="HomeWorkP break_word">
|
||
<%= @contestwork.description.html_safe %>
|
||
</div>
|
||
<div>
|
||
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @contestwork.attachments} %>
|
||
<div class="cl"></div>
|
||
</div>
|
||
</div>
|
||
</div><!----HomeWorkBox end-->
|
||
<div class="cl"></div>
|
||
|
||
<div class="HomeWorkCon mt15" nhname='student_work_form'>
|
||
<%= form_for(@student_work,
|
||
:html => { :multipart => true },
|
||
:url => {:controller => 'contestant_works',
|
||
:action => 'create',
|
||
:work => @contestwork.id
|
||
},:remote=>true ) do |f| %>
|
||
|
||
<div class="cl"></div>
|
||
<% if @contestwork.work_type == 3 %>
|
||
<span id="min_num_member" style="display: none"><%=@contestwork.work_detail_group.min_num %></span>
|
||
<span id="max_num_member" style="display: none"><%=@contestwork.work_detail_group.max_num %></span>
|
||
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
|
||
<% end %>
|
||
<div>
|
||
<input type="text" name="student_work[name]" id="student_work_name" class="InputBox fl W700" maxlength="200" onkeyup="regexStudentWorkName();" placeholder="请输入作品名称" value="<%=@contestwork.name %>的作品提交(可修改)">
|
||
<div class="cl"></div>
|
||
<p id="student_work_name_span" class="c_red mb10"></p>
|
||
</div>
|
||
<div class="mt10">
|
||
<textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"></textarea>
|
||
<%#= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%>
|
||
<!--<script>
|
||
var text = document.getElementById("student_work_description");
|
||
autoTextarea(text);// 调用
|
||
</script>-->
|
||
<div class="cl"></div>
|
||
<p id="student_work_description_textarea" class="c_red mb10"></p>
|
||
<p id="e_tip" class="c_grey"></p>
|
||
<p id="e_tips" class="c_grey"></p>
|
||
</div>
|
||
|
||
<div class="mt10 mb10">
|
||
<span class="fl fontGrey2 group_detail_info"></span>
|
||
<div class="cl"></div>
|
||
<span class="fl fontGrey2" id="group_members"></span>
|
||
<div class="cl"></div>
|
||
<% if @contestwork && @contestwork.work_type == 3 %>
|
||
<sapn class="fl fontGrey2" id="group_members_show">
|
||
合作成员:<%= User.current.show_name %>(组长)
|
||
</sapn>
|
||
<span id="student_work_group_textarea" class="ml10 c_red fl"></span>
|
||
<% end %>
|
||
<div class="cl"></div>
|
||
<span class="fl fontGrey2" id="relate_project_show">
|
||
<% if @contestwork && @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
|
||
<% unless @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").empty? %>
|
||
<% project = Project.find @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").first.project_id %>
|
||
关联项目:<%= project.name %>
|
||
<% end %>
|
||
<% end %>
|
||
</span>
|
||
</div>
|
||
<div class="cl"></div>
|
||
|
||
<div id="homework_attachments">
|
||
<%= render :partial => 'contestant_work_attachment', :locals => {:container => @student_work} %>
|
||
</div>
|
||
<div id="group_member">
|
||
</div>
|
||
<div id="relate_project">
|
||
</div>
|
||
|
||
<% if @contestwork.work_type == 3 %>
|
||
<div class="fl mt5">
|
||
<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="请添加小组的其他成员" onclick="show_group_member();">合作成员</a>
|
||
</div>
|
||
<% end %>
|
||
|
||
<div class="mt5">
|
||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">提交</a>
|
||
<span class="fr mr10 mt3">或</span>
|
||
<%= link_to "取消", delete_work_contestant_works_path(:work =>@contestwork.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
|
||
</div>
|
||
<div class="cl"></div>
|
||
<% end%>
|
||
</div><!----HomeWorkCon end-->
|
||
</div>
|
||
</div>
|