2015-12-06 15:03:36 +08:00
|
|
|
<%= content_for(:header_tags) do %>
|
2016-03-17 15:03:34 +08:00
|
|
|
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
|
2015-12-06 15:03:36 +08:00
|
|
|
<% end %>
|
2016-03-17 15:03:34 +08:00
|
|
|
<script type="text/javascript">
|
2016-05-13 11:06:47 +08:00
|
|
|
var first_click = true;
|
2016-03-17 15:03:34 +08:00
|
|
|
function nh_check_field(params){
|
|
|
|
var result=true;
|
|
|
|
if(!regexTopicSubject()) {
|
|
|
|
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.text("描述不能为空");
|
|
|
|
params.contentmsg.css('color','#ff0000');
|
|
|
|
}
|
|
|
|
else if(params.content.html().length >=20000){
|
|
|
|
params.contentmsg.text("描述最多20000个汉字(或40000个英文字符)");
|
|
|
|
params.contentmsg.css('color','#ff0000');
|
|
|
|
result=false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
params.contentmsg.text("填写正确");
|
|
|
|
params.contentmsg.css('color','#008000');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 = false;
|
|
|
|
is_checked = nh_check_field({
|
|
|
|
issubmit:true,
|
|
|
|
content:params.editor,
|
|
|
|
contentmsg:params.contentmsg,
|
|
|
|
textarea:params.textarea
|
|
|
|
});
|
2016-05-13 11:06:47 +08:00
|
|
|
if(first_click && is_checked){
|
2016-03-17 15:03:34 +08:00
|
|
|
if(flag){
|
2016-05-13 11:06:47 +08:00
|
|
|
first_click = false;
|
2016-03-17 15:03:34 +08:00
|
|
|
return true;
|
|
|
|
}else{
|
2016-05-13 11:06:47 +08:00
|
|
|
first_click = false;
|
2016-03-17 15:03:34 +08:00
|
|
|
$(this)[0].submit();
|
|
|
|
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));
|
|
|
|
elocalStorage(message_content_editor,'topic_course_<%=course.id %>');
|
|
|
|
}
|
|
|
|
}).loadPlugin('paste');
|
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
KindEditor.ready(function(K){
|
|
|
|
$("div[nhname='topic_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='topic_textarea']",params.div_form);
|
|
|
|
params.contentmsg = $("#message_content_span");
|
|
|
|
params.submit_btn = $("#new_message_submit_btn");
|
|
|
|
if(params.textarea.data('init') == undefined) {
|
|
|
|
params.editor = init_homework_editor(params);
|
|
|
|
message_content_editor = params.editor;
|
|
|
|
init_homework_form(params);
|
|
|
|
params.submit_btn.click(function () {
|
|
|
|
params.form.submit();
|
|
|
|
});
|
|
|
|
params.textarea.data('init', 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2015-10-15 16:17:48 +08:00
|
|
|
<%= error_messages_for 'message' %>
|
|
|
|
<div class="resources mt10">
|
|
|
|
<div id="new_course_topic">
|
|
|
|
<div class="homepagePostBrief c_grey">
|
|
|
|
<div>
|
2016-08-26 14:03:09 +08:00
|
|
|
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
|
2015-10-15 16:17:48 +08:00
|
|
|
<p id="subjectmsg"></p>
|
|
|
|
</div>
|
|
|
|
<div id="topic_editor" style="display: none;">
|
2016-07-19 17:37:39 +08:00
|
|
|
<%if User.current.member_of_course?(course) %>
|
2015-10-16 17:32:17 +08:00
|
|
|
<div class="mt10">
|
2016-07-28 15:11:04 +08:00
|
|
|
<% if User.current.id == course.tea_id %>
|
2016-07-19 17:37:39 +08:00
|
|
|
<%= f.check_box :sticky, :value => topic.sticky %>
|
|
|
|
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
|
|
|
|
<%= f.check_box :locked, :value => topic.locked %>
|
2015-10-15 16:17:48 +08:00
|
|
|
<%= label_tag 'message_locked', l(:label_board_locked) %>
|
2016-07-28 15:11:04 +08:00
|
|
|
<% end %>
|
2015-10-15 16:17:48 +08:00
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
2015-10-16 17:32:17 +08:00
|
|
|
<% end %>
|
2015-10-15 16:17:48 +08:00
|
|
|
<div class="mt10">
|
|
|
|
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
|
|
|
|
<%= text_area :quote,:quote,:style => 'display:none' %>
|
|
|
|
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
2015-05-07 16:10:07 +08:00
|
|
|
|
2016-03-17 15:03:34 +08:00
|
|
|
<%#= f.kindeditor :content, :editor_id => 'message_content_editor',
|
2015-10-15 16:17:48 +08:00
|
|
|
:owner_id => topic.nil? ? 0: topic.id,
|
|
|
|
:owner_type => OwnerTypeHelper::MESSAGE,
|
|
|
|
:width => '100%',
|
|
|
|
:height => 300,
|
|
|
|
:minHeight=>300,
|
|
|
|
:class => 'talk_text fl',
|
|
|
|
:input_html => { :id => 'message_content',
|
|
|
|
:class => 'talk_text fl',
|
2015-12-14 17:13:57 +08:00
|
|
|
:maxlength => 5000 },
|
|
|
|
at_id: topic.id, at_type: topic.class.to_s
|
|
|
|
%>
|
2016-03-17 15:03:34 +08:00
|
|
|
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='topic_textarea' name="message[content]"><%=topic.content %></textarea>
|
2015-10-15 16:17:48 +08:00
|
|
|
<div class="cl"></div>
|
|
|
|
<p id="message_content_span"></p>
|
2016-03-17 15:03:34 +08:00
|
|
|
<p id="e_tip" class="c_grey"></p>
|
|
|
|
<p id="e_tips" class="c_grey"></p>
|
2015-10-15 16:17:48 +08:00
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
<div class="mt10">
|
|
|
|
<div class="fl" id="topic_attachments">
|
|
|
|
<%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-10-15 16:59:17 +08:00
|
|
|
<div class="cl"></div>
|
2015-10-15 16:17:48 +08:00
|
|
|
<div class="mt5">
|
|
|
|
<%if !edit_mode %>
|
2016-03-17 15:03:34 +08:00
|
|
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
|
2015-10-15 16:17:48 +08:00
|
|
|
<span class="fr mr10 mt3">或</span>
|
|
|
|
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
|
|
|
|
<% else %>
|
2016-03-17 15:03:34 +08:00
|
|
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn" onclick="submit_topic();">确定</a>
|
2015-10-15 16:17:48 +08:00
|
|
|
<span class="fr mr10 mt3">或</span>
|
|
|
|
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %>
|
|
|
|
<!--<li>
|
2015-05-27 14:42:36 +08:00
|
|
|
<div class="ml55 fl" nhname="toolbar_container"></div>
|
2015-10-15 16:17:48 +08:00
|
|
|
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%#= l(:button_cancel) %></a>
|
2015-05-27 14:42:36 +08:00
|
|
|
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
|
2015-10-15 16:17:48 +08:00
|
|
|
<%#= l(:button_submit)%>
|
2015-05-23 14:46:30 +08:00
|
|
|
</a>
|
2015-05-07 16:10:07 +08:00
|
|
|
<div class="cl"></div>
|
2015-10-15 16:17:48 +08:00
|
|
|
</li>-->
|
|
|
|
</div>
|
|
|
|
</div>
|