学生提交作品时描述框可以直接插入图片,作品列表也直接显示图片。

This commit is contained in:
cxt 2016-03-15 16:36:10 +08:00
parent 5476016b79
commit 90d664bbca
5 changed files with 270 additions and 41 deletions

View File

@ -59,8 +59,8 @@
<li >
<span class="tit_fb ">内容:</span>
<div class="showHworkP break_word">
<%= text_format(work.description) if work.description%>
<div class="showHworkP break_word upload_img" id="student_work_img_<%=work.id %>">
<%= work.description.html_safe if work.description%>
</div>
<div class="cl"></div>
</li>
@ -105,6 +105,9 @@
<div class="cl"></div>
</div>
<script type="text/javascript">
$(function(){
showNormalImage('student_work_img_<%=work.id %>');
});
function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>');
showModal('ajax-modal', '452px');

View File

@ -4,9 +4,11 @@
<p class="f14 mt5">
<span class="fb">作品名称:</span><%=@student_work.name%>
</p>
<p class="f14 mt5">
<span class="fb">作品描述:</span><%=@student_work.description%>
</p>
<div class="f14 mt5" style="max-width: 425px; color:#808181">
<div class="fb fl dis">作品描述:</div>
<div class="upload_img fl" style="max-width: 350px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>

View File

@ -4,9 +4,11 @@
<p class="f14 mt5">
<span class="fb">作品名称:</span><%=@student_work.name%>
</p>
<p class="f14 mt5">
<span class="fb">作品描述:</span><%=@student_work.description%>
</p>
<div class="f14 mt5" style="max-width: 425px; color:#808181">
<div class="fb fl dis">作品描述:</div>
<div class="upload_img fl" style="max-width: 350px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>

View File

@ -1,3 +1,7 @@
<% content_for :header_tags do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<div class="homepageRightBanner mb10">
<div class="NewsBannerName">编辑作品</div>
</div>
@ -25,7 +29,7 @@
</div><!----HomeWorkBox end-->
<div class="cl"></div>
<div class="HomeWorkCon mt15">
<div class="HomeWorkCon mt15" nhname='student_work_form'>
<%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
<div class=" c_red mb10">
提示:作品名称和描述中不要出现真实的姓名信息
@ -46,11 +50,12 @@
<p id="student_work_name_span" class="c_red mb10"></p>
</div>
<div class="mt10">
<textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea>
<script>
<textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"><%= @work.description%></textarea>
<!--<textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%#= @work.description%></textarea>-->
<!--<script>
var text = document.getElementById("student_work_description");
autoTextarea(text);// 调用
</script>
</script>-->
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red mb10"></p>
</div>
@ -66,7 +71,7 @@
<% end %>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();edit_student_work(<%= @work.id%>);">确定</a>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
</div>
@ -96,23 +101,129 @@
}
function popupRegex(){
if(regexStudentWorkName()&&regexStudentWorkDescription())
{
if($("#group_member_ids").length > 0) {
if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#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");
}
} else {
if($("#group_member_ids").length > 0) {
if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#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");
}
} else {
$('#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()){
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);
}
});
});
</script>

View File

@ -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 %>
<script type="text/javascript">
<%if @homework.homework_detail_manual.comment_status != 1%>
$(function(){
@ -57,26 +62,131 @@
}
// 作品校验
function popupRegex(){
if(regexStudentWorkName()&&regexStudentWorkDescription())
{
if($("#group_member_ids").length > 0) {
if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#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");
}
} else {
if($("#group_member_ids").length > 0) {
if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#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");
}
} else {
$('#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()){
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);
}
});
});
</script>
<div class="homepageRightBanner mb10">
@ -110,7 +220,7 @@
</div><!----HomeWorkBox end-->
<div class="cl"></div>
<div class="HomeWorkCon mt15">
<div class="HomeWorkCon mt15" nhname='student_work_form'>
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
@ -132,11 +242,12 @@
<p id="student_work_name_span" class="c_red mb10"></p>
</div>
<div class="mt10">
<%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%>
<script>
<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>
</script>-->
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red mb10"></p>
</div>
@ -167,9 +278,9 @@
</div>-->
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();new_student_work();">提交</a>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">提交</a>
<span class="fr mr10 mt3">或</span>
<%= 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"%>
</div>
<div class="cl"></div>
<% end%>