From b3919256fa22f002e56ef796f6c207912d9ce111 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Sep 2015 09:17:12 +0800 Subject: [PATCH 1/9] 111 --- app/controllers/users_controller.rb | 2 - app/views/users/_course_news.html.erb | 23 +-------- app/views/users/_user_activities.html.erb | 58 ----------------------- 3 files changed, 1 insertion(+), 82 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0058e6e4c..5260cd8d1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -627,9 +627,7 @@ class UsersController < ApplicationController end def show - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" course_types = "('Message','News','HomeworkCommon','poll')" diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index d6c32def6..bc090fa03 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -1,4 +1,4 @@ -
+
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> @@ -42,25 +42,7 @@ <%if count>2 %> <% end %> -
- <%#= render :partial => 'course_news_reply',:locals => { :contest => @contest, :journals => @jour, :state => false}%> - - <% replies_all_i = 0 %> <% unless activity.comments.empty? %>
@@ -79,9 +61,6 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_date(comment.created_on) %> - <%#= link_to_if_authorized_course l(:button_delete), {:controller => 'comments', :action => 'destroy', :id => activity, :comment_id => comment}, - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> -
<%= comment.comments.html_safe %>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index b43d0d54e..511c416c2 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,51 +1,9 @@ <% user_activities.each do |user_activity| unless user_activities.nil? %> <% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %> <% case user_activity.container_type.to_s %> @@ -25,7 +30,7 @@ <% when 'HomeworkCommon' %> <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %> <% when 'News' %> - <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity =>user_activity} %> + <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'Message'%> <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %> <% when 'Poll' %> diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 556069a1f..035391472 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -1,29 +1,4 @@ - - - - - - - - -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %> - - - - +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %>
diff --git a/public/javascripts/init_KindEditor.js b/public/javascripts/init_KindEditor.js new file mode 100644 index 000000000..38aabda79 --- /dev/null +++ b/public/javascripts/init_KindEditor.js @@ -0,0 +1,100 @@ +function init_editor(params){ + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:"100%",height:"80px", + items:['emoticons'], + afterChange:function(){//按键事件 + nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); + }, + afterCreate:function(){ + var toolbar = $("div[class='ke-toolbar']",params.div_form); + $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); + params.toolbar_container.append(toolbar); + } + }).loadPlugin('paste'); + return editor; +} + +function nh_check_field(params){ + var result=true; + if(params.content!=undefined){ + if(params.content.isEmpty()){ + result=false; + } + if(params.content.html()!=params.textarea.html() || params.issubmit==true){ + params.textarea.html(params.content.html()); + params.content.sync(); + if(params.content.isEmpty()){ + params.contentmsg.html('内容不能为空'); + params.contentmsg.css({color:'#ff0000'}); + }else{ + params.contentmsg.html('填写正确'); + params.contentmsg.css({color:'#008000'}); + } + params.contentmsg.show(); + } + } + return result; +} +function init_form(params){ + params.form.submit(function(){ + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = nh_check_field({ + issubmit:true, + content:params.editor, + contentmsg:params.contentmsg, + textarea:params.textarea + }); + if(is_checked){ + if(flag){ + return true; + }else{ + $(this)[0].submit(); + return false; + } + } + return false; + }); +} +function nh_reset_form(params){ + params.form[0].reset(); + params.textarea.empty(); + if(params.editor != undefined){ + params.editor.html(params.textarea.html()); + } + params.contentmsg.hide(); +} + +function init_KindEditor_data(id){ + 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']", params.div_form); + params.contentmsg = $("p[nhname='contentmsg']", params.div_form); + params.toolbar_container = $("div[nhname='toolbar_container']", params.div_form); + params.cancel_btn = $("#new_message_cancel_btn"); + params.submit_btn = $("#new_message_submit_btn"); + + if (params.textarea.data('init') == undefined) { + params.editor = init_editor(params); + init_form(params); + params.cancel_btn.click(function () { + nh_reset_form(params); + }); + params.submit_btn.click(function () { + params.form.submit(); + }); + params.textarea.data('init', 1); + $(this).show(); + } + }); + }); +} \ No newline at end of file diff --git a/public/javascripts/user.js b/public/javascripts/user.js index b032221f8..6a5d93139 100644 --- a/public/javascripts/user.js +++ b/public/javascripts/user.js @@ -1,74 +1,5 @@ //个人动态 $(function(){ - function init_editor(params){ - var editor = params.kindutil.create(params.textarea, { - resizeType : 1,minWidth:"1px",width:"100%",height:"80px", - items:['emoticons'], - afterChange:function(){//按键事件 - nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); - }, - afterCreate:function(){ - var toolbar = $("div[class='ke-toolbar']",params.div_form); - $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); - params.toolbar_container.append(toolbar); - } - }).loadPlugin('paste'); - return editor; - } - - function nh_check_field(params){ - var result=true; - if(params.content!=undefined){ - if(params.content.isEmpty()){ - result=false; - } - if(params.content.html()!=params.textarea.html() || params.issubmit==true){ - params.textarea.html(params.content.html()); - params.content.sync(); - if(params.content.isEmpty()){ - params.contentmsg.html('内容不能为空'); - params.contentmsg.css({color:'#ff0000'}); - }else{ - params.contentmsg.html('填写正确'); - params.contentmsg.css({color:'#008000'}); - } - params.contentmsg.show(); - } - } - return result; - } - function init_form(params){ - params.form.submit(function(){ - var flag = false; - if(params.form.attr('data-remote') != undefined ){ - flag = true - } - var is_checked = nh_check_field({ - issubmit:true, - content:params.editor, - contentmsg:params.contentmsg, - textarea:params.textarea - }); - if(is_checked){ - if(flag){ - return true; - }else{ - $(this)[0].submit(); - return false; - } - } - return false; - }); - } - function nh_reset_form(params){ - params.form[0].reset(); - params.textarea.empty(); - if(params.editor != undefined){ - params.editor.html(params.textarea.html()); - } - params.contentmsg.hide(); - } - KindEditor.ready(function(K){ $("a[nhname='reply_btn']").live('click',function(){ var params = {}; @@ -167,110 +98,4 @@ $(function(){ }); }); }); -function init_list_more_div(params){ - var p=params; - p.exbtn.click(function(){ - var isclose = p.container.data('isclose'); - var hasmore = p.container.data('hasmore'); - if(isclose == '1'){ - $("div[nhname='rec']",p.container).show(); - p.container.data('isclose','0'); - change_status_4_list_more_div(params); - return; - } - if(hasmore == '0'){ - change_status_4_list_more_div(params,'get'); - return; - } - var url = p.container.data('url'); - if($("div[nhname='rec']",p.container).length > 0){ - var lastid = $("div[nhname='rec']",p.container).filter(':last').data('id'); - url += "?lastid="+lastid; - var lasttime = $("div[nhname='rec']",p.container).filter(':last').data('time'); - if(lasttime != undefined){ - url += "&lasttime="+lasttime; - } - } - $.ajax( {url:url,dataType:'text',success:function(data){ - var html = $("
"+data+"
"); - var lens = $("div[nhname='rec']",html).length; - if(lens < p.size){ - p.container.data('hasmore','0'); - } - if(lens>0){ - var currpage = parseInt(p.container.data('currpage'))+1; - p.container.data('currpage',currpage); - p.container.append(html.html()) - } - change_status_4_list_more_div(params,'get'); - p.div.show(); - }} ); - }); - p.clbtn.click(function(){ - var i=0; - $("div[nhname='rec']",p.container).each(function(){ - i++; - if(i> p.size){ - $(this).hide(); - } - }); - p.container.data('isclose','1'); - change_status_4_list_more_div(params); - }); - p.exbtn.click(); -} -function change_status_4_list_more_div(params,opt){ - var p=params; - if($("div[nhname='rec']",p.container).length == 0 && opt != 'get'){ - p.exbtn.click(); - return; - } - var show_lens = $("div[nhname='rec']",p.container).length - $("div[nhname='rec']",p.container).filter(':hidden').length; - if( show_lens > p.size ){ - p.clbtn.show(); - }else{ - p.clbtn.hide(); - } - if($("div[nhname='rec']",p.container).length == 0){ - p.exbtn.html(p.nodatamsg); - }else if( p.container.data('hasmore') == '1' || p.container.data('isclose')=='1' ){ - p.exbtn.html('点击展开更多'); - }else{ - p.exbtn.html('没有更多了'); - } -} -function init_list_more_div_params(div){ - var params = {}; - params.div = div; - params.container = $("div[nhname='container']",div); - params.exbtn = $("a[nhname='expand']",div); - params.clbtn = $("a[nhname='close']",div); - params.size = params.container.data('pagesize'); - params.nodatamsg = params.container.data('nodatamsg'); - if( params.size == undefined ){ - params.size = 13; - } - return params; -} -$(function(){ - $("div[nhname='list_more_div']").each(function(){ - var params = init_list_more_div_params($(this)); - init_list_more_div(params) - }); -}); - -$(function(){ - $(".newsType").mouseover(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"}); - }); - $(".newsType").mouseout(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"}); - }); - $(".resourcesSelected").mouseover(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"}); - }); - $(".resourcesSelected").mouseout(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"}); - }); -}); //个人动态 end \ No newline at end of file diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 1e729cce2..54280b1c4 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -587,7 +587,7 @@ a.postTypeGrey:hover {color:#269ac9;} .homepagePostReplyBannerCount{width:255px; display:inline-block; margin-left:20px;} .homepagePostReplyBannerTime{width:85px; display:inline-block;} .homepagePostReplyBannerMore{width:330px; display:inline-block; text-align:right;} -.homepagePostReplyInputContainer {width:670px; margin:0px auto;} +.homepagePostReplyInputContainer {width:670px; margin: 10px auto 0 auto;} .homepagePostReplyInput {width:663px; height:45px; max-width:663px; max-height:45px; border:1px solid #d9d9d9; outline:none; margin:20px auto 10px auto;} .homepagePostReplyEmotion {background:url(../images/homepage_icon.png) -90px -88px no-repeat; width:50px; height:24px; float:left; padding-left:30px;} .homepagePostReplySubmit {float:right; width:45px; height:24px; text-align:center; line-height:24px; vertical-align:middle; font-size:12px; color:#ffffff; background-color:#269ac9;} @@ -955,6 +955,20 @@ img.ui-datepicker-trigger { .is_public{display: none !important;} .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.recall_con{width:570px;} +div.recall_con .reply_btn{margin-left:525px;margin-top:5px;} +.fr.cr{ clear: right} + From 62360175d18223d88e2fcec54b57bbfbdc962651 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Sep 2015 11:25:52 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=97=B6=EF=BC=8C=E6=89=80=E6=9C=89=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=A1=86=E9=83=BD=E4=BC=9A=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_news.html.erb | 10 +++++----- public/javascripts/init_KindEditor.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index fb9561df6..3b19eded1 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -48,11 +48,11 @@
<%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - -

-
- 取消 - 发送 + +

+
+ 取消 + 发送 <% end%>
diff --git a/public/javascripts/init_KindEditor.js b/public/javascripts/init_KindEditor.js index 38aabda79..fc02146bb 100644 --- a/public/javascripts/init_KindEditor.js +++ b/public/javascripts/init_KindEditor.js @@ -77,11 +77,11 @@ function init_KindEditor_data(id){ if (params.form == undefined || params.form.length == 0) { return; } - params.textarea = $("textarea[nhname='new_message_textarea']", params.div_form); - params.contentmsg = $("p[nhname='contentmsg']", params.div_form); - params.toolbar_container = $("div[nhname='toolbar_container']", params.div_form); - params.cancel_btn = $("#new_message_cancel_btn"); - params.submit_btn = $("#new_message_submit_btn"); + params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form); + params.contentmsg = $("p[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); if (params.textarea.data('init') == undefined) { params.editor = init_editor(params); From b1de6623384f6314d07308df278e594333174f51 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Sep 2015 14:18:44 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 36 ++++---------------- app/views/messages/reply.js.erb | 3 ++ app/views/users/_course_message.html.erb | 40 +++++++++++++---------- app/views/users/_user_activities.html.erb | 20 +++++++++--- app/views/users/user_newfeedback.html.erb | 10 ++++++ public/stylesheets/new_user.css | 27 ++++++++++----- 6 files changed, 76 insertions(+), 60 deletions(-) create mode 100644 app/views/messages/reply.js.erb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index a242587fb..965aacab0 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -177,6 +177,7 @@ class MessagesController < ApplicationController @reply.board = @board @reply.safe_attributes = params[:reply] @reply.content = @quote + @reply.content + @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] @topic.children << @reply #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? @@ -185,41 +186,18 @@ class MessagesController < ApplicationController update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE 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}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) else #render file: 'messages#show', layout: 'base_courses' 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 redirect_to project_boards_path(@project) elsif @course diff --git a/app/views/messages/reply.js.erb b/app/views/messages/reply.js.erb new file mode 100644 index 000000000..b1a18a8af --- /dev/null +++ b/app/views/messages/reply.js.erb @@ -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%>); \ No newline at end of file diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 0f3201e64..bd660ca7d 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -1,5 +1,5 @@ -
-
+
+
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@@ -12,7 +12,6 @@ <% end %> 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_path(activity.course), :class => "newsBlue ml15 mr5"%>
<% if activity.parent_id.nil? %> @@ -26,14 +25,14 @@
-
帖子描述: +
帖子描述: <% if activity.parent_id.nil? %> <%= activity.content.to_s.html_safe%> <% else %> <%= activity.parent.content.to_s.html_safe%> <% end %>
- - +
+ <% activity= activity.parent_id.nil? ? activity:activity.parent%> <% replies_all_i = 0 %> <% unless activity.children.empty? %> -
+
    <% activity.children.reorder("created_on desc").each do |reply|%> <% replies_all_i=replies_all_i+1 %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 4e705157a..a5325342c 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,4 +1,14 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> + <% user_activities.each do |user_activity| if user_activities %>