diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 4cc038c02..bc4de8fae 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -1,33 +1,5 @@ -:javascript - $('.stream_element').live('mousedown', function(evt){ - var note = $(this).closest('.stream_element'), - note_id = note.attr('data-guid'), - nBadge = $("#notification_badge_number"); - - if(note.hasClass('unread') ){ - note.removeClass('unread'); - $.ajax({ - url: 'notifications/' + note_id, - type: 'PUT' - }); - } - if(nBadge.html() != null) { - nBadge.html().replace(/\d+/, function(num){ - num = parseInt(num); - nBadge.html(parseInt(num)-1); - if(num == 1) { - nBadge.addClass("hidden"); - } - }); - - } - }); - - $('a.more').live('click', function(){ - $(this).hide(); - $(this).next('span').removeClass('hidden'); - }); - +- content_for :head do + = include_javascripts :notifications .span-1 = image_tag 'icons/mail_big.png', :height => 30, :width => 30, :style=>"margin-top:3px;" .span-10 diff --git a/config/assets.yml b/config/assets.yml index ad1df666f..34d5db119 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -66,6 +66,8 @@ javascripts: - public/javascripts/inbox.js profile: - public/javascripts/vendor/jquery.autoSuggest.custom.js + notifications: + - public/javascripts/notifications.js stylesheets: default: diff --git a/public/javascripts/notifications.js b/public/javascripts/notifications.js new file mode 100644 index 000000000..12aa5263b --- /dev/null +++ b/public/javascripts/notifications.js @@ -0,0 +1,28 @@ +$('.stream_element').live('mousedown', function(evt){ + var note = $(this).closest('.stream_element'), + note_id = note.attr('data-guid'), + nBadge = $("#notification_badge .badge_count") + + if(note.hasClass('unread') ){ + note.removeClass('unread'); + $.ajax({ + url: 'notifications/' + note_id, + type: 'PUT' + }); + } + if(nBadge.html() != null) { + nBadge.html().replace(/\d+/, function(num){ + num = parseInt(num); + nBadge.html(parseInt(num)-1); + if(num == 1) { + nBadge.addClass("hidden"); + } + }); + + } +}); + +$('a.more').live('click', function(){ + $(this).hide(); + $(this).next('span').removeClass('hidden'); +});