make incrementing the notification count optional

This commit is contained in:
Dan Hansen 2011-05-07 07:28:52 -05:00
parent 3767cce149
commit 535954dcc2
3 changed files with 20 additions and 4 deletions

View file

@ -8,8 +8,9 @@ var WebSocketReceiver = {
ws.onclose = function() {
Diaspora.widgets.notifications.showNotification({
html: '<div class="notification">' +
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
'</div>'
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
'</div>',
incrementCount: false
});
WSR.debug("socket closed");

View file

@ -32,14 +32,17 @@
};
};
Notifications.prototype.showNotification = function(notification) { $(notification.html).prependTo(this.notificationArea)
Notifications.prototype.showNotification = function(notification) {
$(notification.html).prependTo(this.notificationArea)
.fadeIn(200)
.delay(8000)
.fadeOut(200, function() {
$(this).detach();
});
this.incrementCount();
if(typeof notification.incrementCount === "undefined" || notification.incrementCount) {
this.incrementCount();
}
};
Notifications.prototype.changeNotificationCount = function(change) {

View file

@ -50,6 +50,18 @@ describe("Diaspora", function() {
expect($("#notifications div").length).toEqual(1);
});
it("only increments the notification count if specified to do so", function() {
var originalCount = Diaspora.widgets.notifications.count;
Diaspora.widgets.notifications.showNotification({
html: '<div class="notification"></div>',
incrementCount: false
});
expect(Diaspora.widgets.notifications.count).toEqual(originalCount);
});
});
});
});