From 1396cae14c9a29d5afad0fba4692eb46c2256759 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 3 Jun 2016 08:59:17 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 4 ++++ app/views/layouts/_logined_header.html.erb | 24 +++++++++++++++++++++- public/stylesheets/new_user.css | 12 +++++++++++ public/stylesheets/public.css | 11 ++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 44ef54c95..a07f2421f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -370,6 +370,10 @@ class User < Principal messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count end + def user_messages_unviewed + + end + # 查询指派给我的缺陷记录 def issue_status_update self.status_updates diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index f5b421f62..e3fad5c6a 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -78,12 +78,28 @@ - @@ -95,6 +111,12 @@ $("#navHomepageSearchType").hide(); }); + $("#user_messages").mouseover(function(){ + $("#user_messages_list").show(); + }).mouseout(function(){ + $("#user_messages_list").hide(); + }); + $("#navHomepageProfile").mouseenter(function(){ $("#homepageProfileMenuIcon").addClass("homepageProfileMenuIconhover"); $("#topnav_login_list").show(); diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 0231f6a8a..1edb4ff80 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1616,3 +1616,15 @@ ul.wlist li a{ border:1px solid #15bccf; padding: 1px 4px 1px 4px; margin-left:3 ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} /*.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;}*/ .wlist_select a{background-color: #64bdd9;cursor: default;} + +/*消息弹框*/ +.shadowbox_news{ width:305px; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); position: absolute; left: -131px; top: 45px; z-index: 9999;} +.shadowbox_news_title{ height:40px; line-height:40px;padding-left:10px; font-size:12px; color:#333;border-bottom:1px solid #eee;} +.shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } +.shadowbox_news_list{ max-height:200px; overflow:hidden;} +.shadowbox_news_list a{ color:#999;} +.shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} +.shadowbox_news_list li:hover{ background-color:#eee;} +a.shadowbox_news_user{ color:#3b94d6;} +a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;} + diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 98fd0ec20..c28560506 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1144,3 +1144,14 @@ a.st_down{ display: block; width:8px; float:left; height:13px; background:url(.. /*弹框*/ .apply_content{ border:1px solid #ddd;line-height: 16px; height:80px;width:420px; background:#fff; margin-bottom:10px;} + +/*消息弹框*/ +.shadowbox_news{ width:305px; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); position: absolute; left: -131px; top: 45px; z-index: 9999;} +.shadowbox_news_title{ height:40px; line-height:40px;padding-left:10px; font-size:12px; color:#333;border-bottom:1px solid #eee;} +.shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } +.shadowbox_news_list{ max-height:200px; overflow:hidden;} +.shadowbox_news_list a{ color:#999;} +.shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} +.shadowbox_news_list li:hover{ background-color:#eee;} +a.shadowbox_news_user{ color:#3b94d6;} +a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;} From d27a050ffa428c7f09d0f5805e0eda8de7ba9f1b Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 3 Jun 2016 16:28:11 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 14 ++++ app/models/user.rb | 4 - app/views/layouts/_logined_header.html.erb | 23 ++---- app/views/layouts/_message_loading.html.erb | 6 ++ .../layouts/_show_messages_list.html.erb | 74 +++++++++++++++++++ app/views/users/_user_message_course.html.erb | 4 +- app/views/users/user_messages_unviewed.js.erb | 1 + config/routes.rb | 1 + public/stylesheets/new_user.css | 2 +- public/stylesheets/public.css | 2 +- 10 files changed, 107 insertions(+), 24 deletions(-) create mode 100644 app/views/layouts/_message_loading.html.erb create mode 100644 app/views/layouts/_show_messages_list.html.erb create mode 100644 app/views/users/user_messages_unviewed.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4cb838b8c..e201d8611 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -123,6 +123,20 @@ class UsersController < ApplicationController end + #未读消息弹窗 + def user_messages_unviewed + @message_alls = [] + messages = MessageAll.where("user_id =?", User.current.id).includes(:message).order("created_at desc") + onclick_time = User.current.onclick_time.onclick_time + messages.each do |message_all| + # 未读的消息存放在数组 + if (message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0) || (message_all.message_type == "SystemMessage"&& !message_all.message.nil? && message_all.message.created_at > onclick_time) + @message_alls << message_all.message + break if @message_alls.length == 5 + end + end + end + # 用户消息 # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验 # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) diff --git a/app/models/user.rb b/app/models/user.rb index a07f2421f..44ef54c95 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -370,10 +370,6 @@ class User < Principal messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count end - def user_messages_unviewed - - end - # 查询指派给我的缺陷记录 def issue_status_update self.status_updates diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index e3fad5c6a..7ba0a23be 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -85,20 +85,7 @@ <% end %> <%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %> @@ -111,10 +98,14 @@ $("#navHomepageSearchType").hide(); }); - $("#user_messages").mouseover(function(){ + $("#user_messages").mouseenter(function(){ $("#user_messages_list").show(); - }).mouseout(function(){ + $.get('<%=user_messages_unviewed_users_path %>'); + $("#ajax-indicator").hide(); + }).mouseleave(function(){ $("#user_messages_list").hide(); + $("#user_messages_list").html("<%=escape_javascript(render :partial => 'layouts/message_loading') %>"); + }); $("#navHomepageProfile").mouseenter(function(){ diff --git a/app/views/layouts/_message_loading.html.erb b/app/views/layouts/_message_loading.html.erb new file mode 100644 index 000000000..aae55205c --- /dev/null +++ b/app/views/layouts/_message_loading.html.erb @@ -0,0 +1,6 @@ + +
+ + 正在加载中,请稍后... +
+
\ No newline at end of file diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb new file mode 100644 index 000000000..27e1d8896 --- /dev/null +++ b/app/views/layouts/_show_messages_list.html.erb @@ -0,0 +1,74 @@ + +

未读消息

+ +<%= link_to '查看全部', user_message_path(User.current), :class => "shadowbox_news_all", :target =>"_Blank" %> \ No newline at end of file diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 60d5b6ed8..0c18dbcc3 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -259,7 +259,7 @@ '您申请引用作业"'+HomeworkCommon.find(ma.course_message_id).name+'"的申请已通过' : '您申请引用作业"'+HomeworkCommon.find(ma.course_message_id).name+'"的申请被拒绝' %> - <% if User.current.member_of_course?(ma.course_message.course) || User.current.admin? || ma.course_message.is_open == 1 %> + <% if User.current.member_of_course?(ma.course_message.course) || User.current.admin? || (ma.course_message.is_open == 1 && ma.course_message.course.is_public == 1) %> <%= link_to link_str, student_work_index_path(:homework => ma.course_message.id), :title => link_str,:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey "}", :target => '_blank' %> <% else %> <%=link_str %> @@ -399,7 +399,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% elsif ma.course_message.jour_type == 'HomeworkCommon' %> + <% elsif ma.course_message.jour_type == 'HomeworkCommon' %>