socialforge/app/views/memos/edit.html.erb

74 lines
3.1 KiB
Plaintext

<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<%= javascript_include_tag 'new_user' %>
<% end %>
<script>
function check_and_submit(){
if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() ){
if($("textarea[name='memo[subject]']").val().trim().length > 50 ){
$("#error").html('主题不能超过50个字符').show();
return;
}
if(memo_content.html().length > 20000){
$("#error").html("内容 过长(最长为 20000 个字符)").show();
$("html,body").animate({scrollTop:$("#error").offset().top},1000)
return false;
}
memo_content.sync();
$.ajax({
url:' /forums/'+'<%= @memo.forum_id.to_s %>'+'/memos/<%= @memo.id.to_s%>',
type:'put',
data:$("#edit_memo").serialize(),
success:function(data){
},
error:function(){
alert('请检查当前网络连接')
}
});
//$("#edit_memo").submit();
}else if($("textarea[name='memo[subject]']").val().trim() == "" && !memo_content.isEmpty() ){
$("#error").html("主题不能为空").show();
}else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.isEmpty()){
$("#error").html("内容不能为空").show();
}else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.isEmpty()){
$("#error").html("主题和内容不能为空").show();
}
}
</script>
<div class="homepageRightBanner mt15">
<div class="NewsBannerName">编辑帖子</div>
</div>
<div class="postRightContainer" style="margin-top: 15px">
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %>
<div id="error" style="color:red ;display: none">
</div>
<div>
<textarea type="text" id="memo_subject" name="memo[subject]" maxlength="50" class="postDetailInput" placeholder="对应帖子标题" ><%= @memo.subject%></textarea>
<script>
var ta = document.getElementById('memo_subject')
autoTextarea(ta)
</script>
</div>
<div class="mt15">
<%= kindeditor_tag 'memo[content]',@memo.content,:height=>300,:editor_id=>'memo_content'%>
</div>
<div class="mt10">
<!--<a href="javascript:void(0);" class="AnnexBtn fl mt3">对应附件名称</a>-->
<%= render :partial => 'forums/file_form', :locals => {:container => @memo} %>
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit();">确定</a></div>
<div class="fr"><a href="<%= forum_memo_path(@memo.forum,@memo)%>" class="linkGrey2 mr10">取消</a><span class="mr10 fontGrey">或</span></div>
<div class="cl"></div>
</div>
<% end %>
</div>
<script>
$(function(){
limitStrsize('memo_subject',50);
limitStrsize('memo_content',5000);
});
</script>