模式二添加回复功能,模式一回复超过三行则隐藏

This commit is contained in:
huang 2016-05-04 09:45:02 +08:00
parent 39dd62580a
commit 557e731343
3 changed files with 40 additions and 33 deletions

View File

@ -113,7 +113,7 @@ class SubDocumentCommentsController < ApplicationController
@org_subfield = @subdomain.org_subfield @org_subfield = @subdomain.org_subfield
@organization = @org_subfield.organization @organization = @org_subfield.organization
@comment = SubDocumentComment.new(:sub_domain_id => @document.sub_domain_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment = SubDocumentComment.new(:sub_domain_id => @document.sub_domain_id, :creator_id => User.current.id, :reply_id => params[:id])
@comment.content = params[:org_comment][:sub_content] @comment.content = params[:flag] ? params[:sub_content] : params[:org_comment][:sub_content]
@document.children << @comment @document.children << @comment
@document.save @document.save
respond_to do |format| respond_to do |format|

View File

@ -13,37 +13,37 @@
</div> </div>
</div> </div>
<!--回复--> <!--回复-->
<% comments_for_doc = @document.children.reorder("created_at desc") %> <% if User.current.logged? %>
<% count = @document.children.count() %> <% comments_for_doc = @document.children.reorder("created_at desc") %>
<div class="sn-replybox"> <% count = @document.children.count() %>
<h2 class="sn-reply-h2">留言板<span class="sn-fr sn-f14 sn-font-grey3 sn-mt10">80条留言</span></h2> <div class="sn-replybox">
<form class="sn-reply-form"> <h2 class="sn-reply-h2">留言板<span class="sn-fr sn-f14 sn-font-grey3 sn-mt10"><%= count %>条留言</span></h2>
<textarea class="sn-reply-text" name="" ></textarea> <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'sub_document_comments', :id => @document.id, :flag => true}, :html => {:multipart => true, :id => 'message_form', :class => "sn-reply-form", } do |f| %>
<div class="sn-reply-btnbox"> <textarea class="sn-reply-text" name="sub_content" ></textarea>
<a href="javascript:void(0)" class="submit-btn">发表</a> <%#= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor', :class => "sn-reply-text" %>
</div> <div class="sn-reply-btnbox">
</form> <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "$('#message_form').submit();", :class => "submit-btn" %>
<div class="sn-reply-comment"> </div>
<h2 class="sn-comment-h2">全部评论</h2> <%#= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %>
<div class=""> <% end %>
<div class="sn-comment-listbox">
<a href="javascript:void(0)" class="sn-reply-userpic fl"><img src="images/img-news-con.jpg" width="824" height="522" alt="" /></a> <div class="sn-reply-comment">
<a href="javascript:void(0)" class="sn-reply-username fl">与再有</a><span class="fl">10分钟</span> <h2 class="sn-comment-h2">全部评论</h2>
<p class="fl sn-reply-usertxt ">北斗真棒,北斗加油</p> <div class="">
<a href="javascript:void()" target="_blank" class="sn-reply-zan fl">100</a> <% comments_for_doc.each_with_index do |reply,i| %>
<div class="cl"></div> <div class="sn-comment-listbox">
</div> <a href="javascript:void(0)" class="sn-reply-userpic fl"><img src="images/img-news-con.jpg" width="824" height="522" alt="" /></a>
<div class="sn-comment-listbox"> <%= link_to User.find(reply.creator_id).realname, user_url_in_org(reply.creator_id), :class => "sn-reply-username fl" %><span class="fl"><%= time_from_now(reply.created_at) %></span>
<a href="javascript:void(0)" class="sn-reply-userpic fl"><img src="images/img-news-con.jpg" width="824" height="522" alt="" /></a> <p class="fl sn-reply-usertxt "><%= reply.content.html_safe unless reply.content.nil? %></p>
<a href="javascript:void(0)" class="sn-reply-username fl">与再有</a><span class="fl">10分钟</span> <!--<a href="javascript:void(0)" target="_blank" class="sn-reply-zan fl">100</a>-->
<p class="fl sn-reply-usertxt ">北斗真棒,北斗加油</p> <div class="cl"></div>
<a href="javascript:void()" target="_blank" class="sn-reply-zan fl">100</a> </div>
<div class="cl"></div> <% end %>
</div> <div class="sn-reply-more">
<div class="sn-reply-more"> <a href="javascript:void(0)" class="">加载更多</a>
<a href="javascript:void(0)" class="">加载更多</a> </div>
</div>
</div> </div>
</div> </div>
</div> <% end %>
</div>
</div> </div>

View File

@ -81,6 +81,13 @@
<%# end %> <%# end %>
<!--</span>--> <!--</span>-->
</div> </div>
<% if count > 3 %>
<div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%= document.id %>" onclick="expand_reply('#reply_div_<%= document.id %> li','#reply_btn_<%=document.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help">
展开更多
</a>
</div>
<% end %>
</div> </div>
<div class="" id="reply_div_<%= @document.id %>"> <div class="" id="reply_div_<%= @document.id %>">
<% comments_for_doc.each_with_index do |reply,i| %> <% comments_for_doc.each_with_index do |reply,i| %>
@ -132,7 +139,7 @@
<em class="talkWrapArrow"></em> <em class="talkWrapArrow"></em>
<div class="cl"></div> <div class="cl"></div>
<div class="talkConIpt ml5 mb10" id="reply<%= @document.id %>"> <div class="talkConIpt ml5 mb10" id="reply<%= @document.id %>">
<%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'sub_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc', :controller => 'sub_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> <%= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %>
<%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %>
<%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %>