This commit is contained in:
sw 2015-06-05 17:17:44 +08:00
commit 360c08bb8b
4 changed files with 29 additions and 4 deletions

View File

@ -6,6 +6,7 @@ class CoursesController < ApplicationController
helper :members helper :members
helper :words helper :words
helper :attachments helper :attachments
helper :activity_notifys
before_filter :auth_login1, :only => [:show, :feedback] before_filter :auth_login1, :only => [:show, :feedback]
menu_item :overview menu_item :overview

View File

@ -0,0 +1,7 @@
module ActivityNotifysHelper
def get_new_notify_count(container,type)
logger.info('xxoo')
query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=?',container.id,type,User.current.id);
return query.count()
end
end

View File

@ -1,7 +1,9 @@
<div class="project_r_h"> <div class="project_r_h">
<% if @controller_name=='ActivityNotifys' %> <% if @controller_name=='ActivityNotifys' %>
<a class="fl about_me" href="<%=course_path(@course)%>"><%= l(:label_activity)%></a> <a class="fl about_me" style="width:80px;" href="<%=course_path(@course)%>"><%= l(:label_activity)%></a>
<h2 class="fl project_h2">与我相关</h2> <h2 class="fl project_h2" style="width:100px;">与我相关
<span class="c_orange f12" style="display:none;">(<font id="new_notify_count"><%=get_new_notify_count(@course,'Course')%></font>)</span>
</h2>
<div class="fr mt10 mr5 c_grey02"> <div class="fr mt10 mr5 c_grey02">
<a class="c_dblue"> <a class="c_dblue">
<label class="mr5" style="cursor:pointer;" data-href="<%= course_activity_notifys_path(@course) %>/chang_read_flag" nhname='nh_act_link_all'>全部标为已读</label> <label class="mr5" style="cursor:pointer;" data-href="<%= course_activity_notifys_path(@course) %>/chang_read_flag" nhname='nh_act_link_all'>全部标为已读</label>
@ -10,7 +12,9 @@
<% else %> <% else %>
<h2 class="fl project_h2"><%= l(:label_activity)%></h2> <h2 class="fl project_h2"><%= l(:label_activity)%></h2>
<% if User.current.logged? %> <% if User.current.logged? %>
<a class="fl about_me" href="<%=course_activity_notifys_path(@course)%>">与我相关</a> <a class="fl about_me" href="<%=course_activity_notifys_path(@course)%>">与我相关
<span class="c_orange f12" style="display:none;">(<font id="new_notify_count"><%=get_new_notify_count(@course,'Course')%></font>)</span>
</a>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@ -80,6 +84,14 @@
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
function nh_new_notify_count_show(){
var new_notify_count = $("#new_notify_count").html();
if(new_notify_count>0){
$("#new_notify_count").parent('span').show();
}else{
$("#new_notify_count").parent('span').hide();
}
}
$("div[nhname='container']").each(function(){ $("div[nhname='container']").each(function(){
var container = $(this); var container = $(this);
var btn = $("a[nhname='nh_act_link']",container); var btn = $("a[nhname='nh_act_link']",container);
@ -92,6 +104,8 @@
$.ajax({url:url,dataType:'text',success:function(data){ $.ajax({url:url,dataType:'text',success:function(data){
if(data == 'true'){ if(data == 'true'){
flag.remove(); flag.remove();
$("#new_notify_count").html($("#new_notify_count").html()-1);
nh_new_notify_count_show();
} }
}}); }});
} }
@ -104,8 +118,11 @@
$.ajax({url:url,dataType:'text',success:function(data){ $.ajax({url:url,dataType:'text',success:function(data){
if(data == 'true'){ if(data == 'true'){
$("span[nhname='nh_act_flag']").remove(); $("span[nhname='nh_act_flag']").remove();
$("#new_notify_count").html('0');
nh_new_notify_count_show();
} }
}}); }});
}); });
nh_new_notify_count_show();
}); });
</script> </script>

View File

@ -677,7 +677,7 @@ input#score{ width:40px;}
/* 与我相关 */ /* 与我相关 */
.new_icon{background:url(../images/new_icon.png) 0px 0px no-repeat; width:35px; height:15px; display:block;} .new_icon{background:url(../images/new_icon.png) 0px 0px no-repeat; width:35px; height:15px; display:block;}
a.about_me{ width:80px;text-align:center;font-size:16px; color:#64bdd9; margin:10px 0 0 10px;} a.about_me{text-align:center;font-size:16px; color:#64bdd9; margin:10px 0 0 10px;}
a:hover.about_me{ color:#0781b4;} a:hover.about_me{ color:#0781b4;}