[Notifications] Extract autoDismiss logic
This commit is contained in:
@@ -332,21 +332,7 @@ define(
|
|||||||
|
|
||||||
onDismiss: function (callback) {
|
onDismiss: function (callback) {
|
||||||
topic.listen(callback);
|
topic.listen(callback);
|
||||||
},
|
|
||||||
|
|
||||||
autoDismiss: (function () {
|
|
||||||
if (notificationModel.severity === "info") {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return notificationModel.autoDismiss;
|
|
||||||
})(),
|
|
||||||
|
|
||||||
autoDismissTimeout: (function () {
|
|
||||||
if (typeof notificationModel.autoDismiss === "number") {
|
|
||||||
return notificationModel.autoDismiss;
|
|
||||||
}
|
|
||||||
return self.AUTO_DISMISS_TIMEOUT;
|
|
||||||
})()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Notifications support a 'dismissable' attribute. This is a
|
//Notifications support a 'dismissable' attribute. This is a
|
||||||
@@ -399,15 +385,25 @@ define(
|
|||||||
*/
|
*/
|
||||||
NotificationService.prototype.setActiveNotification = function (notification) {
|
NotificationService.prototype.setActiveNotification = function (notification) {
|
||||||
var timeout;
|
var timeout;
|
||||||
|
var shouldAutoDismiss;
|
||||||
|
var usesCustomTimeout;
|
||||||
this.active.notification = notification;
|
this.active.notification = notification;
|
||||||
|
|
||||||
/*
|
if (!notification) {
|
||||||
If autoDismiss has been specified, OR there are other
|
delete this.active.timeout;
|
||||||
notifications queued for display, setup a timeout to
|
return;
|
||||||
dismiss the dialog.
|
}
|
||||||
*/
|
|
||||||
if (notification && (notification.autoDismiss || this.selectNextNotification())) {
|
usesCustomTimeout = typeof notification.model.autoDismiss === "number";
|
||||||
timeout = notification.autoDismissTimeout || this.AUTO_DISMISS_TIMEOUT;
|
|
||||||
|
if (notification.model.severity === "info" || usesCustomTimeout) {
|
||||||
|
shouldAutoDismiss = true;
|
||||||
|
} else {
|
||||||
|
shouldAutoDismiss = notification.model.autoDismiss;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldAutoDismiss || this.selectNextNotification()) {
|
||||||
|
timeout = usesCustomTimeout ? notification.model.autoDismiss : this.AUTO_DISMISS_TIMEOUT;
|
||||||
this.active.timeout = this.$timeout(function () {
|
this.active.timeout = this.$timeout(function () {
|
||||||
notification.dismissOrMinimize();
|
notification.dismissOrMinimize();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|||||||
Reference in New Issue
Block a user