Notifications: Don't update titles directly, fire an event instead
This commit is contained in:
parent
1bf2a87726
commit
b0c7997128
@ -1,8 +1,5 @@
|
|||||||
|
|
||||||
// Store the title, to later append notifications count
|
var unread_on_load = false;
|
||||||
var page_title = document.title;
|
|
||||||
|
|
||||||
var unread_on_load = 0;
|
|
||||||
var unread_new = 0;
|
var unread_new = 0;
|
||||||
var first_load = false;
|
var first_load = false;
|
||||||
|
|
||||||
@ -83,13 +80,15 @@ function getNotifications(){
|
|||||||
}); // each
|
}); // each
|
||||||
|
|
||||||
if (unread_new > 0) {
|
if (unread_new > 0) {
|
||||||
// Set page title, display notifications and set counter
|
unread_on_load = unread_new;
|
||||||
document.title = '(' + unread_new + ') ' + page_title;
|
|
||||||
|
// Display notifications count
|
||||||
$('#notifications-count').addClass('bloom');
|
$('#notifications-count').addClass('bloom');
|
||||||
$('#notifications-count').html('<span>' + unread_new + '</span>');
|
$('#notifications-count').html('<span>' + unread_new + '</span>');
|
||||||
$('#notifications-toggle i').removeClass('pi-notifications-none').addClass('pi-notifications-active');
|
$('#notifications-toggle i').removeClass('pi-notifications-none').addClass('pi-notifications-active');
|
||||||
|
|
||||||
|
$('body').trigger('pillar:notifications-total-updated', unread_new);
|
||||||
} else {
|
} else {
|
||||||
document.title = page_title;
|
|
||||||
$('#notifications-count').removeAttr('class');
|
$('#notifications-count').removeAttr('class');
|
||||||
$('#notifications-toggle i').removeClass('pi-notifications-active').addClass('pi-notifications-none');
|
$('#notifications-toggle i').removeClass('pi-notifications-active').addClass('pi-notifications-none');
|
||||||
};
|
};
|
||||||
@ -167,6 +166,8 @@ function checkPopNotification(id,username,username_avatar,action,date,context_ob
|
|||||||
|
|
||||||
// pop in!
|
// pop in!
|
||||||
popNotification();
|
popNotification();
|
||||||
|
|
||||||
|
$('body').trigger('pillar:notifications-total-updated', unread_new);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -311,11 +312,12 @@ $(function() {
|
|||||||
$(this).addClass('is_read');
|
$(this).addClass('is_read');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.title = page_title;
|
|
||||||
$('#notifications-count').removeAttr('class');
|
$('#notifications-count').removeAttr('class');
|
||||||
$('#notifications-toggle i').removeClass('pi-notifications-active').addClass('pi-notifications-none');
|
$('#notifications-toggle i').removeClass('pi-notifications-active').addClass('pi-notifications-none');
|
||||||
|
|
||||||
unread_on_load = unread_new;
|
unread_on_load = 0;
|
||||||
|
|
||||||
|
$('body').trigger('pillar:notifications-total-updated', unread_on_load);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user