178 lines
7.5 KiB
Plaintext
178 lines
7.5 KiB
Plaintext
|
|
||
|
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||
|
|
||
|
<% if @news.commentable? %>
|
||
|
<div class="msg_box fl">
|
||
|
<h4><%= l(:label_comment_add) %></h4>
|
||
|
<%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %>
|
||
|
<div class="box" id="news_comment">
|
||
|
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||
|
<%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%>
|
||
|
</div>
|
||
|
<p class="mt10">
|
||
|
<a href="javascript:void(0)" class="grey_btn fr ml10" onclick="KindEditor.instances[0].html('');">
|
||
|
<%= l(:label_cancel_with_space) %>
|
||
|
</a>
|
||
|
<a href="javascript:void(0)" class="blue_btn fr" onclick="submitComment();">
|
||
|
<%= l(:label_comment_with_space) %>
|
||
|
</a>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
|
||
|
<div class="homepagePostReplyInputContainer" id='leave-message' nhname="new_message">
|
||
|
|
||
|
<%= form_for('new_form', :method => :post,
|
||
|
:url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%>
|
||
|
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||
|
<textarea class="homepagePostReplyInput" nhname="new_message_textarea" name="new_form[course_message]" placeholder="请输入回复"></textarea>
|
||
|
<p nhname="contentmsg"></p>
|
||
|
<% end %>
|
||
|
<div class="cl"></div>
|
||
|
<div>
|
||
|
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
|
||
|
<a href="javascript:void(0)" class="grey_btn fr ml10 mt10" nhname="cancel_btn">取 消</a>
|
||
|
<a href="javascript:void(0)" onclick='$("#leave_message_form").submit();' class="blue_btn fr mt10">
|
||
|
发送
|
||
|
</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="cl"></div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
$(function(){
|
||
|
|
||
|
function init_editor(params){
|
||
|
var editor = params.kindutil.create(params.textarea, {
|
||
|
resizeType : 1,minWidth:"1px",width:"100%",height:"45px",
|
||
|
items:['emoticons'],
|
||
|
afterChange:function(){//按键事件
|
||
|
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
|
||
|
},
|
||
|
afterCreate:function(){
|
||
|
var toolbar = $("div[class='ke-toolbar']",params.div_form);
|
||
|
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
|
||
|
params.toolbar_container.append(toolbar);
|
||
|
}
|
||
|
}).loadPlugin('paste');
|
||
|
return editor;
|
||
|
}
|
||
|
|
||
|
function nh_check_field(params){
|
||
|
var result=true;
|
||
|
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('内容不能为空');
|
||
|
params.contentmsg.css({color:'#ff0000'});
|
||
|
}else{
|
||
|
params.contentmsg.html('填写正确');
|
||
|
params.contentmsg.css({color:'#008000'});
|
||
|
}
|
||
|
params.contentmsg.show();
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function init_form(params){
|
||
|
params.form.submit(function(){
|
||
|
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){
|
||
|
return true;
|
||
|
}else{
|
||
|
$(this)[0].submit();
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
});
|
||
|
}
|
||
|
function nh_reset_form(params){
|
||
|
params.form[0].reset();
|
||
|
params.textarea.empty();
|
||
|
if(params.editor != undefined){
|
||
|
params.editor.html(params.textarea.html());
|
||
|
}
|
||
|
params.contentmsg.hide();
|
||
|
}
|
||
|
|
||
|
KindEditor.ready(function(K){
|
||
|
$("a[nhname='reply_btn']").live('click',function(){
|
||
|
var params = {};
|
||
|
params.kindutil = K;
|
||
|
params.container = $(this).parent('div').parent('div');
|
||
|
params.div_form = $(">.respond-form",params.container);
|
||
|
params.form = $("form",params.div_form);
|
||
|
params.textarea = $("textarea[name='user_notes']",params.div_form);
|
||
|
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
|
||
|
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
|
||
|
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
|
||
|
if(params.textarea.data('init') == undefined){
|
||
|
params.editor = init_editor(params);
|
||
|
init_form(params);
|
||
|
params.cancel_btn.click(function(){
|
||
|
nh_reset_form(params);
|
||
|
});
|
||
|
}
|
||
|
params.cancel_btn.click();
|
||
|
toggleAndSettingWordsVal(params.div_form, params.textarea);
|
||
|
setTimeout(function(){
|
||
|
if(!params.div_form.is(':hidden')){
|
||
|
params.textarea.show();
|
||
|
params.textarea.focus();
|
||
|
params.textarea.hide();
|
||
|
}
|
||
|
},300);
|
||
|
params.textarea.data('init',1);
|
||
|
});
|
||
|
|
||
|
$("div[nhname='new_message']").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='new_message_textarea']",params.div_form);
|
||
|
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
|
||
|
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
|
||
|
if(params.textarea.data('init') == undefined){
|
||
|
params.editor = init_editor(params);
|
||
|
init_form(params);
|
||
|
$("a[nhname='cancel_btn']",params.div_form).click(function(){
|
||
|
nh_reset_form(params);
|
||
|
});
|
||
|
params.textarea.data('init',1);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
|
||
|
<!--
|
||
|
<textarea class="homepagePostReplyInput" placeholder="请输入回复"></textarea>
|
||
|
<div class="homepagePostReplyEmotion"><a href="javascript:void(0);" class="replyGrey">表情</a></div>
|
||
|
<div class="homepagePostReplyCancel"><a href="javascript:void(0);" class="postReplyCancel">取消</a>
|
||
|
</div>
|
||
|
<div class="homepagePostReplySubmit"><a href="javascript:void(0);" class="postReplySubmit">发送</a>
|
||
|
</div>-->
|