二级帖子子页面

hjq_beidou
huang 9 years ago
parent 59988f17da
commit acf4a64e6a

@ -38,6 +38,11 @@ class OrgDocumentCommentsController < ApplicationController
def show def show
@document = OrgDocumentComment.find(params[:id]) @document = OrgDocumentComment.find(params[:id])
@org_subfield = OrgSubfield.where(:id => @document.org_subfield_id).first
@subfield_content = @organization.org_subfields.order("priority")
respond_to do |format|
format.html {render :layout => @organization.switch_type ? 'base_org_custom' : 'base_org'}
end
end end
def index def index
@ -91,7 +96,7 @@ class OrgDocumentCommentsController < ApplicationController
def add_reply_in_doc def add_reply_in_doc
@document = OrgDocumentComment.find(params[:id]).root @document = OrgDocumentComment.find(params[:id]).root
@comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
@comment.content = params[:org_comment][:org_content] @comment.content = params[:org_content]
@document.children << @comment @document.children << @comment
@document.save @document.save
respond_to do |format| respond_to do |format|

@ -0,0 +1,111 @@
<div class="sn-innner-content">
<div class="sn-row sn-bg-white">
<div class="sn-content-position sn-hidden"> 您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> &gt;
<%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> &gt;
<a class = "sn-link-grey2 sn-hidden" ><%= @document.title %></a>
</div>
</div>
<div class="sn-inner-newslist">
<h2 class="sn-inner-newsh2 sn-hidden"><%= @document.title %></h2>
<div class="sn-inner-newscon">
<p class=" sn-inner-psmall">来源:<%= @org_subfield.name %> 发布时间:<%= format_date(@document.created_at) %></p>
<p class=" sn-inner-pcon"><%= @document.content.html_safe %></p>
</div>
</div>
<!--回复-->
<% if User.current.logged? %>
<% comments_for_doc = @document.children.reorder("created_at desc") %>
<% count = @document.children.count() %>
<div class="sn-replybox">
<h2 class="sn-reply-h2">留言板<span class="sn-fr sn-f14 sn-font-grey3 sn-mt10"><%= count %>条留言</span></h2>
<%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id, :flag => true}, :html => {:multipart => true, :id => 'message_form', :class => "sn-reply-form", } do |f| %>
<textarea class="sn-reply-text" name="org_content" id="text_submain"></textarea>
<%#= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor', :class => "sn-reply-text" %>
<div class="sn-reply-btnbox">
<a href="javascript:void(0)" onclick = "org_new_files_upload()" class = "submit-btn">发表</a>
</div>
<p id="sub_domain_reply" style="display: none;color: #ff0000">内容不能为空</p>
<%#= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %>
<% end %>
<div class="sn-reply-comment">
<h2 class="sn-comment-h2">全部评论</h2>
<div id="newstyle_reply_div_<%= @document.id %>" style="display:<%= count == 0 ? 'none' : 'block' %>">
<% comments_for_doc.each_with_index do |reply,i| %>
<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>
<%= 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>
<div class="fl sn-reply-usertxt ">
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => reply.id, :content=> reply.content} %>
<%#= reply.content.html_safe unless reply.content.nil? %>
</div>
<!--<a href="javascript:void(0)" target="_blank" class="sn-reply-zan fl">100</a>-->
<div class="cl"></div>
</div>
<% end %>
</div>
<% if count > 3 %>
<div class="sn-reply-more">
<a id="reply_btn_<%= @document.id %>" onclick="expand_reply('#newstyle_reply_div_<%= @document.id %>','#reply_btn_<%= @document.id%>')" data-count="<%= count %>" data-init="0" href="javascript:void(0)" value="show_help">
展开更多
</a>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
<script>
$(document).ready(function(){
var replyCount = $(".sn-comment-listbox").size();
if (replyCount >3){
for(var i= 3; i < replyCount+1; i++){
$(".sn-comment-listbox").eq(i).hide();
}
}
});
function expand_reply(container, btnid) {
var target = $(container).children();
var btn = $(btnid);
if (btn.data('init') == '0') {
btn.data('init', 1);
btn.html('收起回复');
target.show();
} else {
btn.data('init', 0);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
}
//验证搜索时输入字
function regexName_submain(content) {
var name = $.trim($("#name").val());
if (name.length == 0) {
$("#project_name_span").text(content);
$("#project_name_span").css('color', '#ff0000');
$("#project_name_span").focus();
return false;
}
else {
$("#project_name_span").text("");
return true;
}
}
function org_new_files_upload(){
var name = $.trim($("#text_submain").val());
// content = $("#text_submain").val();
if (name.length == 0) {
$("#sub_domain_reply").show();
}
else {
$("#message_form").submit();
}
}
</script>

@ -1,72 +1,75 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"create_kindeditor",'blog' %> <% if @organization.switch_type %>
<script> <%= render :partial => 'show_custom_org_document_comment' %>
$(function() { <% else %>
sd_create_editor_from_data(<%= @document.id%>,null,"100%", "<%=@document.class.to_s%>"); <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"create_kindeditor",'blog' %>
showNormalImage('message_description_<%= @document.id %>'); <script>
}); $(function() {
</script> sd_create_editor_from_data(<%= @document.id%>,null,"100%", "<%=@document.class.to_s%>");
<div class="resources" style="margin-top:<%= User.current.logged? ? '0px':'10px' %>;" id="organization_document_<%= @document.id %>"> showNormalImage('message_description_<%= @document.id %>');
<div class="homepagePostBrief"> });
<div class="homepagePostPortrait"> </script>
<%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %> <div class="resources" style="margin-top:<%= User.current.logged? ? '0px':'10px' %>;" id="organization_document_<%= @document.id %>">
</div> <div class="homepagePostBrief">
<div class="homepagePostDes"> <div class="homepagePostPortrait">
<div class="homepagePostTo"> <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %>
<%= link_to User.find(@document.creator_id), user_url_in_org(@document.creator_id), :class => "newsBlue mr15" %> </div>
TO&nbsp;&nbsp;<%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> <div class="homepagePostDes">
| <div class="homepagePostTo">
<% if @document.organization.home_id == @document.id %> <%= link_to User.find(@document.creator_id), user_url_in_org(@document.creator_id), :class => "newsBlue mr15" %>
<span style="color:#269ac9;">首页</span> TO&nbsp;&nbsp;<%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %>
<% else %> |
<span style="color:#269ac9;">组织文章</span> <% if @document.organization.home_id == @document.id %>
<% end %> <span style="color:#269ac9;">首页</span>
</div> <% else %>
<div class="homepagePostTitle postGrey"><%= link_to @document.title, org_document_comment_path(:id => @document.id, :organization_id => @document.organization.id) %></div> <span style="color:#269ac9;">组织文章</span>
<div class="homepagePostDate"> <% end %>
发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %></div>
<% unless @document.content.blank? %>
<div class="homepagePostIntro" style="width:640px;" id="intro_content_<%= @document.id%>">
<%= @document.content.html_safe %>
</div> </div>
<% end %> <div class="homepagePostTitle postGrey"><%= link_to @document.title, org_document_comment_path(:id => @document.id, :organization_id => @document.organization.id) %></div>
<div class=" fl"> <div class="homepagePostDate">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @document} %> 发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %></div>
<%#= link_to_attachments_course @document, :author => false %> <% unless @document.content.blank? %>
</div> <div class="homepagePostIntro" style="width:640px;" id="intro_content_<%= @document.id%>">
<!-- <%# if defined?(home_id) %> <%= @document.content.html_safe %>
</div>
<% end %>
<div class=" fl">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @document} %>
<%#= link_to_attachments_course @document, :author => false %>
</div>
<!-- <%# if defined?(home_id) %>
<div style="float:right;">最后编辑:<%#= User.find() %></div> <div style="float:right;">最后编辑:<%#= User.find() %></div>
<%# end %>--> <%# end %>-->
<% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %> <% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %>
<div class="homepagePostSetting"> <div class="homepagePostSetting">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<li> <li>
<%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %> <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %>
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a> <a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
<% end %> <% end %>
</li> </li>
<li> <li>
<%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :flag => 1), :class => "postOptionLink" %> <%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :flag => 1), :class => "postOptionLink" %>
</li> </li>
<li> <li>
<%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :detail_page => 1), :method => 'delete', <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :detail_page => 1), :method => 'delete',
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:remote => true, :class => 'postOptionLink' %> :remote => true, :class => 'postOptionLink' %>
</li>
</ul>
</li> </li>
</ul> </ul>
</li> </div>
</ul> <div class="cl"></div>
</div> <% end %>
<div class="cl"></div> </div>
<% end %> </div>
</div> <% comments_for_doc = @document.children.reorder("created_at desc") %>
</div> <% count = @document.children.count() %>
<% comments_for_doc = @document.children.reorder("created_at desc") %>
<% count = @document.children.count() %>
<div class="homepagePostReply fl" style="background-color: #f1f1f1;" id="<%= @document.id %>"> <div class="homepagePostReply fl" style="background-color: #f1f1f1;" id="<%= @document.id %>">
<%# if count > 0 %> <%# if count > 0 %>
<div class="homepagePostReplyBanner"> <div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复 <div class="homepagePostReplyBannerCount">回复
<sapn class="mr15"><%= count>0 ? "#{count}" : "" %></sapn><span style="color: #cecece;">▪</span> <sapn class="mr15"><%= count>0 ? "#{count}" : "" %></sapn><span style="color: #cecece;">▪</span>
@ -123,50 +126,51 @@
<% end %> <% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<%# end %> <%# end %>
<%# if User.current.logged?%> <%# if User.current.logged?%>
<div class="talkWrapMsg" nhname="about_talk_reply"> <div class="talkWrapMsg" nhname="about_talk_reply">
<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 => 'org_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= f.kindeditor :org_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> <%= f.kindeditor :org_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;" %>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<%# end %> <%# end %>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
$("#intro_content_<%= @document.id%> p,#intro_content_<%= @document.id%> span,#intro_content_<%= @document.id%> em").each(function(){ $("#intro_content_<%= @document.id%> p,#intro_content_<%= @document.id%> span,#intro_content_<%= @document.id%> em").each(function(){
var postContent = $(this).html(); var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," "); postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; "); postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;"); postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; "); postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent); $(this).html(postContent);
});
autoUrl('intro_content_<%= @document.id %>');
}); });
autoUrl('intro_content_<%= @document.id %>'); function expand_reply(container, btnid) {
}); var target = $(container);
function expand_reply(container, btnid) { var btn = $(btnid);
var target = $(container); if (btn.data('init') == '0') {
var btn = $(btnid); btn.data('init', 1);
if (btn.data('init') == '0') { btn.html('收起回复');
btn.data('init', 1); target.show();
btn.html('收起回复'); } else {
target.show(); btn.data('init', 0);
} else { btn.html('展开更多');
btn.data('init', 0); target.hide();
btn.html('展开更多'); target.eq(0).show();
target.hide(); target.eq(1).show();
target.eq(0).show(); target.eq(2).show();
target.eq(1).show(); }
target.eq(2).show();
} }
} </script>
</script> <% end %>

Loading…
Cancel
Save