讨论区回复功能,修改引用样式

This commit is contained in:
sw 2015-09-01 14:18:44 +08:00
parent 62360175d1
commit b1de662338
6 changed files with 76 additions and 60 deletions

View File

@ -177,6 +177,7 @@ class MessagesController < ApplicationController
@reply.board = @board @reply.board = @board
@reply.safe_attributes = params[:reply] @reply.safe_attributes = params[:reply]
@reply.content = @quote + @reply.content @reply.content = @quote + @reply.content
@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
@topic.children << @reply @topic.children << @reply
#@topic.update_attribute(:updated_on, Time.now) #@topic.update_attribute(:updated_on, Time.now)
if !@reply.new_record? if !@reply.new_record?
@ -185,41 +186,18 @@ class MessagesController < ApplicationController
update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE
end end
# 与我相关动态的记录add start
if(@board && @board.course) #项目的先不管
notifyto_arr = {}
notifyto_arr[@topic.author_id] = @topic.author_id
if( params[:parent_topic] != nil && params[:parent_topic] != '')
parent_topic = Message.find(params[:parent_topic])
notifyto_arr[parent_topic.author_id] = parent_topic.author_id
end
notifyto_arr.each do |k,user_id|
if(user_id != User.current.id)
notify = ActivityNotify.new()
if(@board.course)
notify.activity_container_id = @board.course_id
notify.activity_container_type = 'Course'
else
notify.activity_container_id = @board.project_id
notify.activity_container_type = 'Project'
end
notify.activity_id = @reply.id
notify.activity_type = 'Message'
notify.notify_to = user_id
notify.is_read = 0
notify.save()
end
end
end
# 与我相关动态的记录add end
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments]) attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply) render_attachment_warning_if_needed(@reply)
else else
#render file: 'messages#show', layout: 'base_courses' #render file: 'messages#show', layout: 'base_courses'
end end
if params[:is_board] if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
respond_to do |format|
format.js
end
elsif params[:is_board]
if @project if @project
redirect_to project_boards_path(@project) redirect_to project_boards_path(@project)
elsif @course elsif @course

View File

@ -0,0 +1,3 @@
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
init_KindEditor_data(<%= @user_activity_id%>);

View File

@ -1,5 +1,5 @@
<div class="resources mt10"> <div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief"> <!-- onmouseover="$('#act-<%=user_activity.id %>').css('visibility','visible')" onmouseout="$('.homepagePostSetting').css('visibility','hidden')"--> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
</div> </div>
@ -12,7 +12,6 @@
<% end %> <% end %>
TO TO
<%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%> <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%>
<%#= link_to activity.course.name.to_s+"(课程讨论区)", course_path(activity.course), :class => "newsBlue ml15 mr5"%>
</div> </div>
<div class="homepagePostTitle break_word"> <div class="homepagePostTitle break_word">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> <% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
@ -26,14 +25,14 @@
</div> </div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity.id%>">帖子描述: <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<% if activity.parent_id.nil? %> <% if activity.parent_id.nil? %>
<%= activity.content.to_s.html_safe%> <%= activity.content.to_s.html_safe%>
<% else %> <% else %>
<%= activity.parent.content.to_s.html_safe%> <%= activity.parent.content.to_s.html_safe%>
<% end %> <% end %>
</div> </div>
<div class="homepagePostSetting" id="act-<%= user_activity.id %>" style="visibility: hidden"> <div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
@ -61,26 +60,33 @@
)</div> )</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> <div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
<%if count>2 %> <%if count>2 %>
<div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity.id%>" onclick="expand_reply('#reply_div_<%= user_activity.id %> li','#reply_btn_<%=user_activity.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >点击展开更多回复(<%= count.to_s%>)</a></div> <div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
点击展开更多回复(<%= count.to_s%>)
</a>
</div>
<% end %> <% end %>
<!--<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" nhname='reply_ex_btn' class="replyGrey">点击展开更多回复</a>
</div>-->
</div>
<!--<div class="homepagePostReplyInputContainer">
<textarea class="homepagePostReplyInput" placeholder="请输入回复"></textarea>
</div> </div>
<div class="homepagePostReplyInputContainer"> <div class="homepagePostReplyInputContainer">
<div class="homepagePostReplyEmotion"><a href="javascript:void(0);" class="replyGrey">表情</a></div> <div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<div class="homepagePostReplyCancel"><a href="javascript:void(0);" class="postReplyCancel">取消</a> <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
</div> <input type="hidden" name="quote[quote]" value="">
<div class="homepagePostReplySubmit"><a href="javascript:void(0);" class="postReplySubmit">发送</a> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<% end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div>--> </div>
<% activity= activity.parent_id.nil? ? activity:activity.parent%> <% activity= activity.parent_id.nil? ? activity:activity.parent%>
<% replies_all_i = 0 %> <% replies_all_i = 0 %>
<% unless activity.children.empty? %> <% unless activity.children.empty? %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity.id %>"> <div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<ul> <ul>
<% activity.children.reorder("created_on desc").each do |reply|%> <% activity.children.reorder("created_on desc").each do |reply|%>
<% replies_all_i=replies_all_i+1 %> <% replies_all_i=replies_all_i+1 %>

View File

@ -1,4 +1,14 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %>
<style type="text/css">
/*回复框*/
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
</style>
<% user_activities.each do |user_activity| <% user_activities.each do |user_activity|
if user_activities %> if user_activities %>
<script> <script>
@ -28,22 +38,22 @@
<% if act %> <% if act %>
<% case user_activity.act_type.to_s %> <% case user_activity.act_type.to_s %>
<% when 'HomeworkCommon' %> <% when 'HomeworkCommon' %>
<%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %> <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
<% when 'News' %> <% when 'News' %>
<%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
<% when 'Message'%> <% when 'Message'%>
<%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %> <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
<% when 'Poll' %> <% when 'Poll' %>
<%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity => user_activity} %> <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% end %> <% end %>
<% end %> <% end %>
<% when 'Project' %> <% when 'Project' %>
<% if act %> <% if act %>
<% case user_activity.act_type.to_s %> <% case user_activity.act_type.to_s %>
<% when 'Issue' %> <% when 'Issue' %>
<%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity =>user_activity} %> <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
<% when 'Message' %> <% when 'Message' %>
<%= render :partial => 'project_message', :locals => {:activity => act,:user_activity =>user_activity} %> <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,4 +1,14 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %>
<style type="text/css">
/*回复框*/
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
</style>
<div > <div >
<div class="resources mb10"> <div class="resources mb10">
<div class="homepageRightBanner"> <div class="homepageRightBanner">

View File

@ -955,20 +955,29 @@ img.ui-datepicker-trigger {
.is_public{display: none !important;} .is_public{display: none !important;}
.ui-corner-left{background: #64bdd9;} .ui-corner-left{background: #64bdd9;}
/*回复框*/
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;} div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;} div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;} div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
.fr.cr{ clear: right} .fr.cr{ clear: right}
blockquote {
/* font-style: italic; */
border-left: 1px solid #e0e0e0;
border-right: 1px solid #e0e0e0;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
padding-left: 0.6em;
padding-top: 0.6em;
padding-right: 0.6em;
padding-bottom: 0.6em;
margin-left: 1.4em;
margin-right: 0.4em;
border-radius: 4px;
font-family: "Microsoft YaHei";
background: url('../images/requirements/reference.jpg');
background-size: 100% 100%;
}