Merge branch 'dev_daiao' into develop

Conflicts:
	app/views/games/_shixun_comment_list.html.erb
This commit is contained in:
daiao 2017-09-30 21:40:23 +08:00
commit 49ffc348e2
20 changed files with 439 additions and 109 deletions

View File

@ -137,17 +137,17 @@ class ForumsController < ApplicationController
@order_str = "reorder_time=desc"
end
=end
@memo = Memo.new(:forum => @forum)
#@memo = Memo.new(:forum => @forum)
@memos = Memo.where("parent_id is null")
@topic_count = @memos.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@memos = @memos.includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
reorder(order).
preload(:author, {:last_reply => :author}).
all
@forums = Forum.find_by_sql("SELECT *,topic_count + memo_count tm FROM `forums` order by tm desc;")
@limit = 20
@is_remote = true
@topic_pages = Paginator.new @topic_count, @limit, params['page'] || 1
@memos = @memos.includes(:last_reply).reorder(order)
@memos = paginateHelper @memos, @limit
#@forums = Forum.find_by_sql("SELECT *,topic_count + memo_count tm FROM `forums` order by tm desc;")
@my_forums_count = Memo.where("author_id =? and parent_id is null", User.current.id).count
@my_memos_count = Memo.where("author_id =? and parent_id is not null", User.current.id).count
@errors = params[:errors]

View File

@ -165,10 +165,9 @@ class MemosController < ApplicationController
@flag = false
respond_to do |format|
if( #@memo.update_column(:subject, params[:memo][:subject]) &&
@memo.update_column(:content, params[:memo][:content]) &&
@memo.update_column(:sticky, params[:memo][:sticky]) &&
@memo.update_column(:lock, params[:memo][:lock]) &&
if( @memo.update_column(:content, params[:memo][:content]) &&
@memo.update_column(:sticky, params[:memo][:sticky].to_i) &&
@memo.update_column(:lock, params[:memo][:lock].to_i) &&
@memo.update_column(:subject,params[:memo][:subject]) &&
@memo.update_column(:updated_at,Time.now))
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))

View File

@ -769,13 +769,13 @@ class ShixunsController < ApplicationController
end
def shixun_discuss
@discusses = @shixun.discusses.where(:parent_id => nil).reorder("created_at desc")
@discusses = @shixun.discusses.reorder("created_at desc")
@discusses_count = @discusses.count
@limit = 15
@is_remote = true
@discusses_pages = Paginator.new @discusses_count, @limit, params['page'] || 1
@offset ||= @discusses_pages.offset
@discusses = paginateHelper @discusses, @limit
#@limit = 15
#@is_remote = true
#@discusses_pages = Paginator.new @discusses_count, @limit, params['page'] || 1
# @offset ||= @discusses_pages.offset
#@discusses = paginateHelper @discusses, @limit
#@game_challenge = params[:challenge_id].blank? ? Challenge.find(@discusses.challenge_id) : Challenge.find(params[:challenge_id])
@game_challenge = Challenge.find(params[:challenge_id].to_i)
end

View File

@ -326,6 +326,11 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Memo'
when 'Challenge'
@reply = Discuss.find params[:reply_id]
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Challenge'
end
respond_to do |format|
format.js
@ -452,6 +457,20 @@ class UsersController < ApplicationController
comment.subject = "#{@root.subject}"
comment.root_id = reply.root_id
reply.children << comment
when 'Challenge'
@game_challenge = Challenge.where(:id => reply.challenge_id).first
@root = reply.root
comment = Discuss.new
comment.user_id = User.current.id
comment.content = params[:reply_message]
comment.root_id = reply.root_id
comment.challenge_id = reply.challenge_id
comment.dis_type = "Shixun"
comment.dis_id = @game_challenge.shixun.try(:id)
comment.praise_count = 0
reply.children << comment
@discusses = @game_challenge.shixun.discusses.reorder("created_at desc")
@discusses_count = @discusses.count
end
update_course_activity(@root.class.to_s,@root.id)
update_user_activity(@root.class.to_s,@root.id)

View File

@ -2099,7 +2099,7 @@ module ApplicationHelper
elsif @organization
title << (@organization.name.nil? ? "创新源于实践" : @organization.name)
elsif @forum || params[:controller] == "forums"
title << "问吧"
title << "论坛"
elsif @my_syllabuses
title << "我的课堂"
elsif @user
@ -4550,6 +4550,8 @@ def get_reply_by_type type, reply_id
reply = JournalsForMessage.find reply_id
when 'Memo'
reply = Memo.find reply_id
when 'Challenge'
reply = Discuss.find reply_id
end
reply
end

View File

@ -7,4 +7,12 @@ class Discuss < ActiveRecord::Base
acts_as_tree :foreign_key => 'parent_id'
belongs_to :dis, :polymorphic => true
validates_presence_of :dis, :user, :content
def creator_user
User.find(self.user_id)
end
def content_detail
self.content
end
end

View File

@ -41,7 +41,7 @@
<span class="btn-top btn-cir-red mt7 ml5 fl">顶</span>
<% end %>
</p>
<p style="width: 1091px;" class="overellipsis color-dark-grey mb10"><%= memo.content.html_safe %></p>
<div style="width: 1091px; height: 30px;" class="overellipsis color-dark-grey mb10"><%= memo.content.html_safe %></div>
<div class="clearfix">
<a href="<%= user_path(memo.author_id) %>" class="fl"><%= User.find(memo.author_id).try(:show_name) %></a>
<span class="fl ml30"><%= time_from_now memo.updated_at %></span>
@ -86,6 +86,12 @@
</div>
</div>
<% if false %>
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>

View File

@ -81,7 +81,7 @@
<div class="-layout-h -padding-h-16 -horizontal -footer-left" id="bottom_points" style = "position:relative;">
<ul class="-task-ml80 -layout" style="overflow:hidden;align-items:flex-end;flex-wrap:wrap;">
<%= render :partial => "games/shixun_comment_block" %>
<li class="fl mt10 ml20 " style="width:54px;margin-bottom:10px;"><a href="javascript:void(0);" onclick="send_dis_to_shixun()" class="course-bth-blue color_white">发送</a></li>
<!-- <li class="fl mt10 ml20 " style="width:54px;margin-bottom:10px;"><a href="javascript:void(0);" onclick="send_dis_to_shixun()" class="course-bth-blue color_white">发送</a></li>-->
<li class="fl ml20 mt15" style="width:85px;margin-bottom:10px;">
<span data-tip-top="<%= @praise.nil? ? "点赞" : "取消点赞" %>" onclick="game_praise('<%= @game_challenge.id %>', '<%= @game_challenge.class %>')" id="game_praise_tread" class="pt5 color-grey mr20">
<i class="fa fa-thumbs-up font-20 mr3 <%= @praise.nil? ? "" : "color-light-green" %>" alt="赞" ></i><span class="font-12 font-bd" id="game_praise_count"><%= @praise_count %></span>

View File

@ -1,43 +1,57 @@
<li class="comment-input fl" id="shixun_comment_block">
<%= form_for('', :url => {:controller => 'discusses', :action => 'create', :dis_id => @shixun.id, :dis_type => "Shixun", :challenge_id => @game_challenge.try(:id)}, :method => "post", :remote => true, :html => {:id => 'new_comment_form'}) do |f| %>
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<% end %>
<li class="comment-input fl" id="shixun_comment_block" style="width: 80%;;">
<!-- <%#= form_for('', :url => {:controller => 'discusses', :action => 'create', :dis_id => @shixun.id, :dis_type => "Shixun", :challenge_id => @game_challenge.try(:id)}, :method => "post", :remote => true, :html => {:id => 'new_comment_form'}) do |f| %>
<textarea id="comment_news" name="content" placeholder="我想说点什么~" MultiLine = True ScrollBars = 2 type="text"></textarea>
<input type="hidden" id="dis_reply_id" name="reply_id" value="">
<% end %>
<%# end %>-->
<div nhname='new_message_<%= @shixun.id%>' class="fr" style="display:none; width: 99%;">
<%= form_for('discuss', :url => {:controller => 'discusses', :action => 'create', :dis_id => @shixun.id, :dis_type => "Shixun", :challenge_id => @game_challenge.try(:id)}, :method => "post", :remote => true, :html => {:id => 'new_comment_form'}) do |f| %>
<div nhname='toolbar_container_<%= @shixun.id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= @shixun.id %>' name="content"></textarea>
<a id="new_message_submit_btn_<%= @shixun.id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="mt10 task-btn task-btn-blue fr">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= @shixun.id%>'></p>
<% end%>
</div>
</li>
<script>
$(function(){
autoTextarea(document.getElementById("comment_news"),0,150);
});
var click = true;
function send_dis_to_shixun(){
if($("#comment_news").val() == ""){
return
} else{
if(click){
click = false;
$("#new_comment_form").submit();
$(function(){
//autoTextarea(document.getElementById("comment_news"),0,150);
sd_create_editor_from_shixun_data(<%= @shixun.id %>, null, "100%", "<%= @shixun.class.to_s %>");
});
var click = true;
function send_dis_to_shixun(){
if($("#comment_news").val() == ""){
return
} else{
if(click){
click = false;
$("#new_comment_form").submit();
return
}
}
}
}
$(".comment-input").on("keydown", "input[name='content']", function(event){
var target, code, tag;
if (!event) {
event = window.event; //针对ie浏览器
code = event.keyCode;
}
else {
code = event.keyCode;
}
if(code == 13) {
send_dis_to_shixun();
return false;
}
});
$("#comment_news").on('blur', function(){
$("#comment_news").attr("placeholder", "我想说点什么~");
$("#dis_reply_id").val();
});
$(".comment-input").on("keydown", "input[name='content']", function(event){
var target, code, tag;
if (!event) {
event = window.event; //针对ie浏览器
code = event.keyCode;
}
else {
code = event.keyCode;
}
if(code == 13) {
send_dis_to_shixun();
return false;
}
});
$("#comment_news").on('blur', function(){
$("#comment_news").attr("placeholder", "我想说点什么~");
$("#dis_reply_id").val();
});
</script>

View File

@ -1,21 +1,132 @@
<% no_children_comments = get_no_children_comments_all @discusses %>
<div class="fit -scroll">
<div class="-layout-v -fit">
<div class="-flex -scroll panel-box-sizing new_li task-padding10" id="game_comment_show" style="padding: 10px 15px;">
<div id="comments_content">
<% if @shixun.discusses.blank? %>
<div class="-flex -scroll panel-box-sizing new_li task-padding10" id="game_comment_show" style="padding: 0px;">
<div class="panel-comment_item">
<% if @discusses.blank? %>
<%= render :partial => "welcome/no_data" %>
<% else %>
<% @discusses.each do |dis| %>
<div class="comments_item_content comment_item_bottom clearfix mt5" onmouseover="$('#discuss_opr_<%= dis.id %>').show();$('#child_discuss_opr_<%= dis.id %>').show();" onmouseout="$('#discuss_opr_<%= dis.id %>').hide();$('#child_discuss_opr_<%= dis.id %>').hide();">
<%= link_to image_tag(url_to_avatar(dis.user), :alt => "头像", :width => 35, :height => 35), user_path(dis.user),:class => "fl mt5", :target => '_blank' %>
<div class="fl comment_item_one ml10">
<p class="clearfix">
<%= link_to dis.user.show_name, user_path(dis.user), :class => "fl link-color-grey mr20" ,:style => "display: block" %>
<span class="fl color-grey font-12 mt3 mr20"><%= time_from_now dis.created_at %></span>
<% if dis.try(:challenge_id).present? %>
<span class="fl color-light-green font-12 mt3">[第<%= Challenge.find(dis.try(:challenge_id)).try(:position) %>关]</span>
<% end %>
<span class="fr color-grey font-12 color_Purple_grey" id="dis_praise_<%= dis.id %>">
<% no_children_comments.each do |comment| %>
<% unless comment.nil? %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<div class="comment_item_cont clearfix" style="padding:10px 10px">
<div class="J_Comment_Face fl">
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 50, :height => 50, :alt => "用户头像"), user_url_in_org(comment.creator_user), :target => '_blank' %>
</div>
<div class="t_content fl" style="width: 87%;">
<div class="J_Comment_Reply">
<div class="comment_orig_content" style="margin:0px">
<% if !comment.parent.nil? %>
<% parents_rely = [] %>
<% parents_rely = get_reply_parents parents_rely, comment %>
<% length = parents_rely.length %>
<div id="comment_reply_<%= comment.id %>" class="mb5">
<% if length <= 5 %>
<%=render :partial => 'student_work/homework_reply', :locals => {:comment => comment.parent, :parent_id => comment.id, :user_activity_id => @game_challenge.id, :type => @game_challenge.class.to_s} %>
<% else %>
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[length - 1], :type => @game_challenge.class.to_s, :user_activity_id => @game_challenge.id, :parent_id => comment.id} %>
</div>
<div class="orig_cont_hide clearfix">
<i class="fa fa-long-arrow-down mr5"></i>
<%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class, :user_activity_id => @game_challenge.id, :parent_id => comment.id),:remote=>true, :class => '' %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[3], :type => @game_challenge.class.to_s, :user_activity_id => @game_challenge.id, :parent_id => comment.id} %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[2], :type => @game_challenge.class.to_s, :user_activity_id => @game_challenge.id, :parent_id => comment.id} %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[1], :type => @game_challenge.class.to_s, :user_activity_id => @game_challenge.id, :parent_id => comment.id} %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[0], :type => @game_challenge.class.to_s, :user_activity_id => @game_challenge.id, :parent_id => comment.id} %>
</div>
<% end %>
</div>
<% end %>
<!--onmouseover="$('#delete_reply_<%#=activity.id %>_<%#=comment.id %>').show();" onmouseout="$('#delete_reply_<%#=activity.id %>_<%#=comment.id %>').hide();"-->
<div class="comment_content clearfix" >
<div class="color-grey3"><%= comment.content.html_safe %></div>
<div class="">
<div class="cl"></div>
<div id="reply_message_<%= comment.id%>" class="reply_to_message"></div>
</div>
</div>
<!--回复end-->
</div>
</div>
<div class="J_Comment_Info clearfix">
<div class="t_info fl">
<%= link_to comment.creator_user.show_real_name, user_url_in_org(comment.creator_user), :class => "content-username hide fl" %>
<span class="t_area fl"><%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %></span>
</div>
<p class="fr mr10 orig_reply">
<% if comment.creator_user == User.current || User.current.admin? || User.current.manager_of_shixun?(comment.dis_id) %>
<a href="javascript:void(0);" class="color-grey" id="delete_reply_<%=@game_challenge.id %>_<%=comment.id %>" onclick="delete_confirm_box_2('<%= discuss_path(comment, :challenge_id => @game_challenge) %>', '确定要删除该条回复吗?')"><i class="fa fa-trash-o mr5"></i>删除</a>
<% end %>
<span class="ml5 mr5 color-grey">|</span>
<%= link_to(
'<i class="fa fa-mail-reply mr5"></i>回复'.html_safe,
{:controller => 'users' ,:action => 'reply_to',:reply_id => comment.id, :type => @game_challenge.class.to_s, :user_activity_id => @game_challenge.id},
:remote => true,
:method => 'get',
:title => l(:button_reply),:class => "color-grey") %>
<span class="ml5 mr5 color-grey">|</span>
<span class="reply_praise_count_<%= comment.id %>">
<%=render :partial=> "praise_tread/edu_praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%>
</span>
</p>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
<script>
function ThumbUp(item){
$(item).toggleClass("orange-btn");
$(item).toggleClass("orange-bg-btn");
if($(item).attr("attr-thumb")=="0"){
$(item).find("span").html(parseInt($(item).find("span").html())+1);
$(item).attr("attr-thumb","1");
}else{
$(item).find("span").html(parseInt($(item).find("span").html())-1);
$(item).attr("attr-thumb","0");
}
}
</script>
<% if false %>
<div class="fit -scroll">
<div class="-layout-v -fit">
<div class="-flex -scroll panel-box-sizing new_li task-padding10" id="game_comment_show" style="padding: 10px 15px;">
<div id="comments_content">
<% if @shixun.discusses.blank? %>
<%= render :partial => "welcome/no_data" %>
<% else %>
<% @discusses.each do |dis| %>
<div class="comments_item_content comment_item_bottom clearfix mt5" onmouseover="$('#discuss_opr_<%= dis.id %>').show();$('#child_discuss_opr_<%= dis.id %>').show();" onmouseout="$('#discuss_opr_<%= dis.id %>').hide();$('#child_discuss_opr_<%= dis.id %>').hide();">
<%= link_to image_tag(url_to_avatar(dis.user), :alt => "头像", :width => 35, :height => 35), user_path(dis.user),:class => "fl mt5", :target => '_blank' %>
<div class="fl comment_item_one ml10">
<p class="clearfix">
<%= link_to dis.user.show_name, user_path(dis.user), :class => "fl link-color-grey mr20" ,:style => "display: block" %>
<span class="fl color-grey font-12 mt3 mr20"><%= time_from_now dis.created_at %></span>
<% if dis.try(:challenge_id).present? %>
<span class="fl color-grey font-12 mt3">[第<%= Challenge.find(dis.try(:challenge_id)).try(:position) %>关]</span>
<% end %>
<span class="fr color-grey font-12 color_Purple_grey" id="dis_praise_<%= dis.id %>">
<%= render :partial => "discusses/dis_praise", :locals => {:discuss => dis} %>
</span>
<span class="fr none mt5 mr10" id="discuss_opr_<%= dis.id %>">
@ -27,15 +138,15 @@
<% end %>
</span>
</p>
<p class="mb10"><%= dis.content %></p>
</p>
<p class="mb10"><%= dis.content %></p>
<div class="cl"></div>
<% dis.children.each do |child| %>
<div class="comments_return comment_item_top">
<p class="clearfix comment_item_left_green return_item pl5">
<span class="fl color-grey mr20">老师回复</span>
<span class="fl color-grey font-12"><%= time_from_now child.created_at %></span>
<div class="cl"></div>
<% dis.children.each do |child| %>
<div class="comments_return comment_item_top">
<p class="clearfix comment_item_left_green return_item pl5">
<span class="fl color-grey mr20">老师回复</span>
<span class="fl color-grey font-12"><%= time_from_now child.created_at %></span>
<span class="fr color-grey font-12 color_Purple_grey" id="dis_praise_<%= child.id %>">
<%= render :partial => "discusses/dis_praise", :locals => {:discuss => child} %>
</span>
@ -44,9 +155,9 @@
<a href="javascript:void(0);" onclick="delete_confirm_box_2('<%= discuss_path(dis) %>', '确定要删除该条回复吗?')" class="fr font-12 link-color-green">删除</a>
<% end %>
</span>
</p>
<p class="pl8 mb10"><%= child.content %></p>
<!--<p class="fl pl8">
</p>
<p class="pl8 mb10"><%= child.content %></p>
<!--<p class="fl pl8">
<span class="fl color-grey"><%#= time_from_now child.created_at %></span>
</p>
<p class="fr pl8 none" id="child_discuss_opr_<%#= dis.id %>">
@ -54,34 +165,34 @@
<a href="javascript:void(0);" onclick="delete_confirm_box_2('<%#= discuss_path(dis) %>', '确定要删除该条回复吗?')" class="fr font-12 link-color-green">删除</a>
<%# end %>
</p>-->
<div class="cl"></div>
</div>
<% end %>
<div class="cl"></div>
</div>
<% end %>
</div>
</div>
<% end %>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @discusses_pages, @discusses_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @discusses_pages, @discusses_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>
</div>
<!--评论区域的分页-->
</div>
</div>
<!--评论区域的分页-->
</div>
</div>
</div>
<% end %>
<script>
//二次回复的提示结构
var $points = $("<div class = \"points-data-tip-top\">"+
"<div class = \"data-tip-top1 \">请在此输入回复</div>"+
"</div>").appendTo("#bottom_points");
//二次回复的提示结构
var $points = $("<div class = \"points-data-tip-top\">"+
"<div class = \"data-tip-top\">请在此输入回复</div>"+
"</div>").appendTo("#bottom_points");
$("#reversion").click(function(){
$points.show();
});
@ -90,4 +201,7 @@
$points.hide();
}
});
$("textarea[nhname='new_message_textarea_"+id+"']").focus();
$("#dis_reply_id").val(dis_id);
}
</script>

View File

@ -18,7 +18,7 @@
<li><%= link_to "全部实训", shixuns_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "实训路径", subjects_path, :class => "new-nav-a font-16" %></li>
<li><%= link_to "在线课堂", courses_path, :class => "new-nav-a font-16" %></li>
<!-- <li><%#= link_to "论", forums_path, :class => "new-nav-a font-16" %></li>-->
<li><%= link_to "论", forums_path, :class => "new-nav-a font-16" %></li>
<!-- <li><%#= link_to "论坛", forums_path, :class =>"new-nav-a", :target => "_blank" %></li>-->
<!-- <li><%#= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "new-nav-a", :target=>"_blank" %></li>-->

View File

@ -1,7 +1,7 @@
<div class="orig_cont clearfix">
<% if !comment.parent.nil? && !comment.parent.parent.nil? %>
<div>
<%= render :partial => 'student_work/homework_reply', :locals => {:comment => comment.parent, :parent_id => parent_id, :type => type, :user_activity_id => user_activity_id} %>
<%= render :partial => 'messages/message_reply', :locals => {:comment => comment.parent, :parent_id => parent_id, :type => type, :user_activity_id => user_activity_id} %>
</div>
<% end %>
<%= render :partial => 'student_work/homework_reply_detail', :locals => {:comment => comment, :parent_id => parent_id, :type => type, :user_activity_id => user_activity_id} %>

View File

@ -1,6 +1,6 @@
<div class="<%= User.current.logged? ? 'orig_reply_box' : 'orig_reply_box2' %> borderBottomNone" id="reply_to_message_<%= reply.id%>">
<% if User.current.logged? %>
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="homepagePostReplyPortrait mr15 imageFuzzy fl" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="orig_textarea mb10 fl">
<div nhname='new_message_<%= reply.id%>'>
<% if @type == 'Message' %>

View File

@ -7,8 +7,8 @@
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<div class="" onmouseout="$(this).find('.reply-right').hide();" onmouseover="$(this).find('.reply-right').show();">
<div class="orig_right fl" style="width: 90%">
<div class="with90 fl" onmouseout="$(this).find('.reply-right').hide();" onmouseover="$(this).find('.reply-right').show();">
<div class="orig_right" style="width: 96%">
<div class="orig_content clearfix" id="reply_content_<%= comment.id %>">
<%= comment.content_detail.html_safe %>
</div>

View File

@ -1,6 +1,6 @@
<div class="<%= User.current.logged? ? 'orig_reply_box' : 'orig_reply_box2' %> borderBottomNone reply_to_message" id="reply_to_message_<%= reply.id%>">
<% if User.current.logged? %>
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="homepagePostReplyPortrait mr15 imageFuzzy fl" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="orig_textarea mb10 fl">
<div nhname='new_message_<%= reply.id%>'>
<% if @type == 'HomeworkCommon' %>
@ -109,7 +109,15 @@
<div class="cl"></div>
<p nhname='contentmsg_<%= reply.id%>'></p>
<% end%>
<% end %>
<% else @type == 'Memo' %>
<%= form_for('discuss', :url => {:controller => 'discusses', :action => 'create', :dis_id => reply.dis_id, :dis_type => "Shixun", :challenge_id => reply.try(:challenge_id)}, :method => "post", :remote => true, :html => {:id => 'new_comment_form'}) do |f| %>
<input type="hidden" id="dis_reply_id" name="reply_id" value="<%= reply.id %>">
<div nhname='toolbar_container_<%= reply.id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= reply.id %>' name="content"></textarea>
<a id="new_message_submit_btn_<%= reply.id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="mt10 task-btn task-btn-blue fr">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= reply.id%>'></p>
<% end%> <% end %>
</div>
<div class="cl"></div>
</div>

View File

@ -1,6 +1,6 @@
<div class="<%= User.current.logged? ? 'orig_reply_box' : 'orig_reply_box2' %> borderBottomNone mt10" id="reply_to_message_<%= reply.id%>">
<% if User.current.logged? %>
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="homepagePostReplyPortrait mr15 imageFuzzy fl" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="orig_textarea mb10 fl">
<div nhname='new_message_<%= reply.id%>'>
<%= form_for('new_form',:url => {:controller => 'users', :action => 'reply_detail', :reply_id => reply.id, :type => @type, :is_project => @is_project, :user_activity_id => @user_activity_id},:method => "post", :remote => true) do |f| %>

View File

@ -54,5 +54,17 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'syllabuses/syllabus_post_reply', :locals => {:activity => @root, :user_activity_id => @user_activity_id}) %>");
<% elsif @type == 'Memo' %>
window.location.href = "<%=forum_memo_path(@root.forum_id, @root) %>";
<% elsif @type == 'Challenge' %>
$(".-tab-nav li").removeClass("tab_hover");
$('#tab_nav_4').addClass("tab_hover");
$(".tab-info").hide();
$('#tab_con_4').show().html("<%= j(render :partial => "games/shixun_comment_list") %>");
<% if @discusses_count > 0 %>
$("#discusses_count").html("<%= @discusses_count %>");
<% end %>
<% end %>
<% if @discusses_count > 0 %>
$("#discusses_count").html("<%= @discusses_count %>");
//window.location.href = "<%#= myshixun_game_path(@challenge.current_user_game, :myshixun_id => @challenge.current_user_game.try(:myshixun)) %>";
<% end %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");

View File

@ -757,6 +757,8 @@ RedmineApp::Application.routes.draw do
end
member do
get "change_sticky"
post "reply"
match "message_replies", :via => [:get, :post]
end
end
end

View File

@ -0,0 +1,11 @@
class ModifyStickyForMemos < ActiveRecord::Migration
def up
memos = Memo.where(:sticky => nil)
if memos.present?
memos.update_all(:sticky => 0)
end
end
def down
end
end

View File

@ -92,6 +92,96 @@ function sd_create_editor(params){
return editor;
}
function sd_create_shixun_editor(params){
// var minHeight; //最小高度
var paramsHeight = params.height; //设定的高度
var id = arguments[1] ? arguments[1] : undefined;
var type = arguments[2] ? arguments[2] : '';
var paramsWidth = params.width == undefined ? "100%" : params.width;
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"94%",
height:"33px",// == undefined ? "30px":paramsHeight+"px",
minHeight:"33px",// == undefined ? "30px":paramsHeight+"px",
width:params.width,
/*
items:['emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','more'],*/
items : ['imagedirectupload'],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//edit.iframe.height(paramsHeight);
//this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : (params.kindutil.GECKO ? body.offsetHeight+26:body.offsetHeight+7)) , 15));
},
afterBlur:function(){
//params.toolbar_container.hide();
params.textarea.blur();
sd_check_editor_form_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
if(this.isEmpty()) {
this.edit.html("<span id='hint' style='color:#999999;font-size:12px;'>我要回复</span>");
}
//params.toolbar_container.hide();
$('#reply_image_' + id).addClass('imageFuzzy');
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){
params.submit_btn.hide();
params.toolbar_container.hide();
this.resize("100%", "30px");
}else if(this.edit.html().trim() != ""){
params.submit_btn.show();
params.toolbar_container.show();
}
//params.submit_btn.css("display","none");
$("#dis_reply_id").val("");
},
afterFocus: function(){
var edit = this.edit;
var body = edit.doc.body;
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
edit.html("");
}
params.submit_btn.show();
params.contentmsg.hide();
params.toolbar_container.show();
// params.toolbar_container.show();
$('#reply_image_' + id).removeClass('imageFuzzy');
//edit.iframe.width(paramsWidth);
console.log(this);
this.resize("100%", "150px");
this.resize(paramsWidth, "150px");
//params.submit_btn.show();
},
afterCreate:function(){
//params.submit_btn.hide();
var toolbar = $("div[class='ke-toolbar']",params.div_form);
toolbar.css('display','inline');
toolbar.css('padding',0);
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
params.toolbar_container.append(toolbar);
params.toolbar_container.hide();
params.submit_btn.hide();
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
edit.iframe.height(paramsHeight);
edit.html("<span id='hint' style='color:#999999;font-size:12px;'>我要回复</span>");
this.resize(null,paramsHeight);// Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ paramsHeight , paramsHeight)
// params.toolbar_container.hide();
if(typeof enableAt === 'function'){
enableAt(this, id, type);
}
}
}).loadPlugin('paste');
return editor;
}
function sd_check_editor_form_field(params){
var result=true;
if(params.content!=undefined){
@ -183,6 +273,51 @@ function sd_create_editor_from_data(id){
});
});
div_form = $("div[nhname='new_message_" + id + "']");
$(".ke-edit", div_form).css("height","33px");
$(".ke-edit-iframe",div_form).css("height","33px");
}
//第二个参数是高度,可以传,可以不传
function sd_create_editor_from_shixun_data(id){
var height = arguments[1] ? arguments[1] : undefined;
var width = arguments[2] ? arguments[2] : undefined;
var type = arguments[3] ? arguments[3] : undefined;
KindEditor.ready(function (K) {
$("div[nhname='new_message_" + id + "']").each(function () {
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form", params.div_form);
if (params.form == undefined || params.form.length == 0) {
return;
}
params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form);
params.contentmsg = $("span[nhname='contentmsg_" + id + "']", params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
params.cancel_btn = $("#new_message_cancel_btn_" + id);
params.submit_btn = $("#new_message_submit_btn_" + id);
params.height = height;
params.width = width;
if (params.textarea.data('init') == undefined) {
params.editor = sd_create_shixun_editor(params,id, type);
sd_create_form(params);
params.cancel_btn.click(function () {
sd_reset_editor_form(params);
});
params.submit_btn.click(function () {
params.form.submit();
});
params.textarea.focus(function (){
params.editor.focus();
});
params.textarea.data('init', 1);
$(this).show();
}
});
});
div_form = $("div[nhname='new_message_" + id + "']");
$(".ke-edit", div_form).css("height","33px");
$(".ke-edit-iframe",div_form).css("height","33px");