diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 0013e3be3..45d504841 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -1,7 +1,8 @@ :javascript $('.message').live('click', function(evt){ var note = $(this).closest('.message'), - note_id = note.attr('data-guid'); + note_id = note.attr('data-guid'), + nBadge = $("#notification_badge_number"); if(note.hasClass('unread') ){ note.removeClass('unread'); @@ -10,8 +11,15 @@ type: 'PUT' }); } - }); + nBadge.html().replace(/\d+/, function(num){ + num = parseInt(num); + nBadge.html(parseInt(num)-1); + if(num == 1) { + nBadge.addClass("hidden"); + } + }); + }); .span-1 = image_tag 'icons/mail_big.png', :height => 30, :width => 30, :style=>"margin-top:3px;" diff --git a/public/javascripts/web-socket-receiver.js b/public/javascripts/web-socket-receiver.js index 4a1bdefe4..a6bd2554e 100644 --- a/public/javascripts/web-socket-receiver.js +++ b/public/javascripts/web-socket-receiver.js @@ -54,7 +54,6 @@ var WebSocketReceiver = { processNotification: function(notification){ - var nBadge = $("#notification_badge_number"); nBadge.html().replace(/\d+/, function(num){