111 lines
5.0 KiB
Plaintext
111 lines
5.0 KiB
Plaintext
<%= content_for(:header_tags) do %>
|
|
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
|
|
<% end %>
|
|
|
|
<div class="wenba-tiwenbox fl mr10 mb10">
|
|
<div class="wenba-tiwen-con">
|
|
<ul >
|
|
<li class="mb10">
|
|
<%= f.text_field :subject, :no_label => true, :id => "memo_subject", :maxlength => "50", :style => "width:708px", :onblur => "check_memo_name();", :onfocus => "$('#memo_name_error_tips').hide();", :onmouseover => "this.style.borderColor='#d9d9d9'", :class => "wenba-tiwen-input", :placeholder => "请输入标题" %>
|
|
<p class="c_red" style="display: none" id="memo_name_error_tips"></p>
|
|
<script>
|
|
var textarea1 = document.getElementById('memo_subject');
|
|
autoTextarea(textarea1);
|
|
</script>
|
|
</li>
|
|
<li class="mb10">
|
|
<%= f.kindeditor :content, :editor_id => "memo_content", :height => 300, :no_label => true %>
|
|
</li>
|
|
<p class="c_red" style="display: none" id="memo_contents_error_tips"></p>
|
|
<li class="clear mb10">
|
|
<%= render :partial => 'forums/file_form', :locals => {:container => @memo} %>
|
|
</li>
|
|
</ul>
|
|
<ul class="wenba-tagbox clearfix">
|
|
<h3 class="mb5 c_red" id="memo_classify_tips">请选择分类</h3>
|
|
<% @forums.each do |forum| %>
|
|
<li class="hidden" style="max-width: 200px;"><a href="javascript:void(0)" class="wenba-tiwen-tag" name="<%= forum.name %>" id="forums_question_<%= forum.id %>" onclick="add_forum('forums_question_<%= forum.id %>')" ><%= forum.name %></a></li>
|
|
<% end %>
|
|
</ul>
|
|
<input type="text" style="display: none" id="forum_name" name="forum_name" value="">
|
|
<div class="clear ">
|
|
<%= link_to "取消", forum_path(@forum), :class => "btn fr" %>
|
|
<a href="javascript:void(0);" class="btn btn-blue fr mr5" onclick="memo_commit();">确定</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$(document).ready(function(){
|
|
$("#forums_question_"+<%= params[:forum_id] %>).addClass("wenba-tiwen-tag-active");
|
|
});
|
|
function add_forum(id){
|
|
$("#memo_classify_tips").attr('style','color: #333;');
|
|
$('a').removeClass("wenba-tiwen-tag-active");
|
|
$("#"+id).addClass("wenba-tiwen-tag-active");
|
|
}
|
|
function check_memo_name(){
|
|
if($("#memo_subject").val().trim().length > 50){
|
|
$("#memo_name_error_tips").html("主题 过长(最长为 50 个字符)").show();
|
|
return false;
|
|
}
|
|
if(memo_content.html().length > 20000){
|
|
$("#memo_contents_error_tips").html("内容 过长(最长为 20000 个字符)").show();
|
|
$("html,body").animate({scrollTop:$("#memo_contents_error_tips").offset().top},1000);
|
|
return false;
|
|
}
|
|
if($("#memo_subject").val().trim() == ""){
|
|
$("#memo_name_error_tips").html("标题不能为空").show();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
var first_click = true;
|
|
function check_and_submit(){
|
|
if(!check_memo_name()){
|
|
return;
|
|
}
|
|
if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() && first_click){
|
|
first_click = false;
|
|
memo_content.sync();
|
|
$.ajax({
|
|
url:'/forums/'+'<%= @forum.id.to_s%>'+'/memos',
|
|
type:'post',
|
|
data:$("#new_memo").serialize(),
|
|
success:function(data){
|
|
|
|
},
|
|
error:function(){
|
|
alert('请检查当前网络连接')
|
|
}
|
|
});
|
|
//$("#new_memo").submit();
|
|
}else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.isEmpty()){
|
|
$("#memo_error_tips").html("主题和内容不能为空").show();
|
|
}
|
|
else if($("textarea[name='memo[subject]']").val().trim() == "" && !memo_content.isEmpty() ){
|
|
$("#memo_error_tips").html("主题不能为空").show();
|
|
}else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.isEmpty()){
|
|
$("#memo_error_tips").html("内容不能为空").show();
|
|
}
|
|
}
|
|
var first_click = true;
|
|
function memo_commit(){
|
|
$("#memo_name_error_tips").hide();
|
|
$("#memo_contents_error_tips").hide();
|
|
var f_name = $('.wenba-tiwen-tag-active').attr('name');
|
|
$("#forum_name").attr('value',f_name);
|
|
if($("#memo_subject").val().trim() != "" && !memo_content.isEmpty() && first_click && $("#forum_name").attr('value') != ""){
|
|
// alert($("#forum_name").attr('name'));
|
|
memo_content.sync();
|
|
$("#new_memo").submit();
|
|
} else if($("#memo_subject").val().trim() == ""){
|
|
$("#memo_name_error_tips").html("标题不能为空").show();
|
|
}else if(memo_content.isEmpty()){
|
|
$("#memo_contents_error_tips").html("内容不能为空").show();
|
|
}else if ($("#forum_name").attr('value')== ""){
|
|
alert("请选择分类");
|
|
$("#memo_classify_tips").attr('style','color: #F00;');
|
|
}
|
|
}
|
|
</script> |