make incrementing the notification count optional
This commit is contained in:
parent
3767cce149
commit
535954dcc2
3 changed files with 20 additions and 4 deletions
|
|
@ -9,7 +9,8 @@ var WebSocketReceiver = {
|
||||||
Diaspora.widgets.notifications.showNotification({
|
Diaspora.widgets.notifications.showNotification({
|
||||||
html: '<div class="notification">' +
|
html: '<div class="notification">' +
|
||||||
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
|
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
|
||||||
'</div>'
|
'</div>',
|
||||||
|
incrementCount: false
|
||||||
});
|
});
|
||||||
|
|
||||||
WSR.debug("socket closed");
|
WSR.debug("socket closed");
|
||||||
|
|
|
||||||
|
|
@ -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)
|
.fadeIn(200)
|
||||||
.delay(8000)
|
.delay(8000)
|
||||||
.fadeOut(200, function() {
|
.fadeOut(200, function() {
|
||||||
$(this).detach();
|
$(this).detach();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(typeof notification.incrementCount === "undefined" || notification.incrementCount) {
|
||||||
this.incrementCount();
|
this.incrementCount();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Notifications.prototype.changeNotificationCount = function(change) {
|
Notifications.prototype.changeNotificationCount = function(change) {
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,18 @@ describe("Diaspora", function() {
|
||||||
|
|
||||||
expect($("#notifications div").length).toEqual(1);
|
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);
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue