帖子的编辑与删除
This commit is contained in:
parent
c8d07dedf6
commit
b9ff46f8d0
|
@ -143,7 +143,12 @@ class MemosController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count
|
||||
@my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count
|
||||
@replying = false
|
||||
respond_to do |format|
|
||||
format.html {render :layout=>'base_forums'}
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
n += 1;//英文,不多说了
|
||||
}
|
||||
}
|
||||
if(n >= 160)
|
||||
if(n >= 160 && event.keyCode != 8)
|
||||
event.returnValue = false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -35,13 +35,13 @@
|
|||
<div class="cl"></div>
|
||||
<% end %>
|
||||
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
<%# if attachment.is_text? %>
|
||||
<%#= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments',
|
||||
:action => 'show',
|
||||
:id => attachment,
|
||||
:filename => attachment.filename%>
|
||||
<% end %>
|
||||
<%# end %>
|
||||
<!--<span title="<%#= attachment.description%>">-->
|
||||
<!--<%#= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %>-->
|
||||
<!--</span>-->
|
||||
|
|
|
@ -1,55 +1,47 @@
|
|||
<!-- <h1>New memo</h1> -->
|
||||
<% @replying = !@memo.parent.nil? %>
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
<h3><%=l(:label_memo_edit)%></h3>
|
||||
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo)) do |f| %>
|
||||
<% if @memo.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= pluralize(@memo.errors.count, "error") %>
|
||||
prohibited this memo from being saved:
|
||||
</h2>
|
||||
<ul>
|
||||
<% @memo.errors.full_messages.each do |msg| %>
|
||||
<li>
|
||||
<%= msg %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="actions">
|
||||
<p>
|
||||
<% if @memo.parent.nil? && @memo.children.first.nil? %>
|
||||
<%#= f.text_field :subject, :required => true, :size => 96 ,:readonly => false, :maxlength => 50%>
|
||||
<% else %>
|
||||
<%#= f.text_field :subject, :required => true, :size => 96 ,:readonly => true, :style => "border: 1px solid gray", :maxlength => 50%>
|
||||
<% end %>
|
||||
</p>
|
||||
<% if User.current.admin?%>
|
||||
<p>
|
||||
<% unless @replying %>
|
||||
<% if @memo.safe_attribute? 'sticky' %>
|
||||
<%= f.check_box :sticky %>
|
||||
<%= label_tag 'memo_sticky', l(:label_board_sticky) %>
|
||||
<% end %>
|
||||
<% if @memo.safe_attribute? 'lock' %>
|
||||
<%= f.check_box :lock %> <%= label_tag 'memo_locked', l(:label_board_locked) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<%= f.kindeditor :content, :required => true, :size => 80,:owner_id => @memo.id,:owner_type => 1 %>
|
||||
</p>
|
||||
<!-- <script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
|
||||
<p style="float: left;margin-top: 5px;">
|
||||
<%= l(:label_attachment_plural) %>
|
||||
<br />
|
||||
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>
|
||||
</p>
|
||||
<br/>
|
||||
<div class="cl"></div>
|
||||
<%= f.submit :value => l(:button_change) %> <%= link_to l(:button_back), back_url ,:class => "button-canel",:style => "color: #ffffff;"%>
|
||||
<%= javascript_include_tag 'new_user'%>
|
||||
<script>
|
||||
$(function(){
|
||||
limitStrsize('memo_subject',50);
|
||||
limitStrsize('memo_content',5000);
|
||||
});
|
||||
function check_and_submit(){
|
||||
if($("textarea[name='memo[subject]']").val().trim() != "" && $("textarea[name='memo[content]']").val().trim() != "" ){
|
||||
$("#edit_memo").submit();
|
||||
}else if($("textarea[name='memo[subject]']").val().trim() == "" && $("textarea[name='memo[content]']").val().trim() != "" ){
|
||||
$("#error").html("主题不能为空").show();
|
||||
}else if($("textarea[name='memo[subject]']").val().trim() != "" && $("textarea[name='memo[content]']").val().trim() == ""){
|
||||
$("#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="display: none">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<textarea type="text" id="memo_subject" name="memo[subject]" class="postDetailInput" placeholder="对应帖子标题" ><%= @memo.subject%></textarea>
|
||||
<script>
|
||||
var ta = document.getElementById('memo_subject')
|
||||
autoTextarea(ta)
|
||||
</script>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="mt15">
|
||||
<textarea type="text" id="memo_content" name="memo[content]" class="postDetailInput" placeholder="对应帖子内容" ><%= @memo.content.html_safe%></textarea>
|
||||
<script>
|
||||
var ta1 = document.getElementById('memo_content')
|
||||
autoTextarea(ta1)
|
||||
</script>
|
||||
</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>
|
|
@ -24,8 +24,8 @@
|
|||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
|
||||
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
|
||||
<li><a href="<%= edit_forum_memo_path(@memo.forum,@memo)%>" class="postOptionLink">编辑</a></li>
|
||||
<li><a href="<%= forum_memo_path(@memo.forum,@memo) %>" data-method="delete" class="postOptionLink">删除</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -249,4 +249,23 @@ var autoTextarea = function (elem, extra, maxHeight) {
|
|||
addEvent('input', change);
|
||||
addEvent('focus', change);
|
||||
change();
|
||||
};
|
||||
};
|
||||
|
||||
function limitStrsize(id,length){
|
||||
document.getElementById(id).onkeydown = function()
|
||||
{
|
||||
var n = 0;
|
||||
var str = this.value;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
var leg = str.charCodeAt(i);//ASCII码
|
||||
if (leg > 255) {//大于255的都是中文
|
||||
n += 2;//如果是中文就是2个字节
|
||||
} else {
|
||||
n += 1;//英文,不多说了
|
||||
}
|
||||
}
|
||||
|
||||
if(n >= length && event.keyCode !== 8)
|
||||
event.returnValue = false;
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;}
|
|||
.homepageLeftLabelContainer {width:238px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px;}
|
||||
.homepageLabelText {color:#484848; font-size:16px; margin-left:10px; margin-bottom:12px; display:block;}
|
||||
.homepageRightBanner {width:720px; height:34px; margin:0px auto; border-bottom:1px solid #e9e9e9;}
|
||||
.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; background:url(../images/homepage_icon.png) -18px -230px no-repeat; width:150px; float:left; padding-left:15px; margin-top:4px;}
|
||||
.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; width:150px; float:left; margin-top:4px;}
|
||||
.newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2; z-index:9999;}
|
||||
.newsReadSetting {width:700px; background-color:#f6f6f6; border-bottom:1px solid #eeeeee; margin:10px auto; height:39px; line-height:39px; vertical-align:middle; font-size:14px; color:#7a7a7a; padding-left:10px;}
|
||||
.homepageNewsList {width:710px; height:49px; line-height:49px; vertical-align:middle; border-bottom:1px dashed #eaeaea; margin-left:10px;}
|
||||
|
|
|
@ -534,7 +534,7 @@ a.sendButtonBlue:hover {color:#ffffff;}
|
|||
outline:none;
|
||||
}
|
||||
.homepageRightBanner {width:720px; height:34px; margin:0px auto; border-bottom:1px solid #e9e9e9;}
|
||||
.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; background:url(images/homepage_icon.png) -18px -230px no-repeat; width:150px; float:left; padding-left:15px; margin-top:4px;}
|
||||
.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; width:150px; float:left; margin-top:4px;}
|
||||
a.resourcesTypeAll {background:url(images/homepage_icon.png) -180px -89px no-repeat; padding-left:23px;}
|
||||
a.resourcesTypeAtt {background:url(images/homepage_icon.png) -180px -49px no-repeat; padding-left:23px;}
|
||||
.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;}
|
||||
|
|
Loading…
Reference in New Issue