Move js out of notifications index, fix reference to notifications badge
This commit is contained in:
parent
a0f98d888a
commit
5afe5f667e
3 changed files with 32 additions and 30 deletions
|
|
@ -1,33 +1,5 @@
|
||||||
:javascript
|
- content_for :head do
|
||||||
$('.stream_element').live('mousedown', function(evt){
|
= include_javascripts :notifications
|
||||||
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');
|
|
||||||
});
|
|
||||||
|
|
||||||
.span-1
|
.span-1
|
||||||
= image_tag 'icons/mail_big.png', :height => 30, :width => 30, :style=>"margin-top:3px;"
|
= image_tag 'icons/mail_big.png', :height => 30, :width => 30, :style=>"margin-top:3px;"
|
||||||
.span-10
|
.span-10
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ javascripts:
|
||||||
- public/javascripts/inbox.js
|
- public/javascripts/inbox.js
|
||||||
profile:
|
profile:
|
||||||
- public/javascripts/vendor/jquery.autoSuggest.custom.js
|
- public/javascripts/vendor/jquery.autoSuggest.custom.js
|
||||||
|
notifications:
|
||||||
|
- public/javascripts/notifications.js
|
||||||
|
|
||||||
stylesheets:
|
stylesheets:
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
28
public/javascripts/notifications.js
Normal file
28
public/javascripts/notifications.js
Normal file
|
|
@ -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');
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue