From 90d664bbca37390dc47b11483aaeb1ef1c8f74e3 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Mar 2016 16:36:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4=E4=BD=9C?= =?UTF-8?q?=E5=93=81=E6=97=B6=E6=8F=8F=E8=BF=B0=E6=A1=86=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8F=92=E5=85=A5=E5=9B=BE=E7=89=87=EF=BC=8C?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8=E4=B9=9F=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=9B=BE=E7=89=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_show.html.erb | 7 +- .../_work_edit_information.html.erb | 8 +- .../student_work/_work_information.html.erb | 8 +- app/views/student_work/edit.html.erb | 143 +++++++++++++++-- app/views/student_work/new.html.erb | 145 ++++++++++++++++-- 5 files changed, 270 insertions(+), 41 deletions(-) diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index d66a30718..67c04d71f 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -59,8 +59,8 @@
  • 内容: -
    - <%= text_format(work.description) if work.description%> +
    + <%= work.description.html_safe if work.description%>
  • @@ -105,6 +105,9 @@
    -->

    @@ -66,7 +71,7 @@ <% end %>
    - 确定 + 确定 <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
    @@ -96,23 +101,129 @@ } function popupRegex(){ - if(regexStudentWorkName()&®exStudentWorkDescription()) - { - if($("#group_member_ids").length > 0) { - if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { - $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); - 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"); - } - } else { + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); 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"); } + } else { + $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); + 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()){ + 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()){ + params.contentmsg.html('作品描述不能为空'); + }else{ + params.contentmsg.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)); + }, + 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(params.textarea.innerHTML); + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); + + } + }).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); + init_homework_form(params); + params.submit_btn.click(function () { + params.form.submit(); + $("#ajax-indicator").hide(); + }); + params.textarea.data('init', 1); + } + }); + }); \ No newline at end of file diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 9391aab37..15958d870 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -1,4 +1,9 @@ +<% content_for :header_tags do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> +
    @@ -110,7 +220,7 @@
    -
    +
    <%= form_for(@student_work, :html => { :multipart => true }, :url => {:controller => 'student_work', @@ -132,11 +242,12 @@

    - <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%> - -->

    @@ -167,9 +278,9 @@
    -->
    - 提交 + 提交 - <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%> + <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
    <% end%>