diff --git a/dashboard-ui/scripts/extensions.js b/dashboard-ui/scripts/extensions.js index cd705f3e85..b235b1f263 100644 --- a/dashboard-ui/scripts/extensions.js +++ b/dashboard-ui/scripts/extensions.js @@ -70,25 +70,7 @@ if (!Array.prototype.filter) { var WebNotifications = { show: function (data) { - if (window.webkitNotifications) { - if (!webkitNotifications.checkPermission()) { - var notif = webkitNotifications.createNotification(data.icon, data.title, data.body); - notif.show(); - - if (data.timeout) { - setTimeout(function () { - notif.cancel(); - }, data.timeout); - } - - return notif; - } else { - webkitNotifications.requestPermission(function () { - return WebNotifications.show(data); - }); - } - } - else if (window.Notification) { + if (window.Notification) { var level = Notification.permissionLevel ? Notification.permissionLevel() : Notification.permission; @@ -99,9 +81,15 @@ var WebNotifications = { notif.show(); } - if (data.timeout && notif.cancel) { + if (data.timeout) { setTimeout(function () { - notif.cancel(); + + if (notif.close) { + notif.close(); + } + else if (notif.cancel) { + notif.cancel(); + } }, data.timeout); } @@ -112,6 +100,31 @@ var WebNotifications = { }); } } + + else if (window.webkitNotifications) { + if (!webkitNotifications.checkPermission()) { + var notif = webkitNotifications.createNotification(data.icon, data.title, data.body); + notif.show(); + + if (data.timeout) { + setTimeout(function () { + + if (notif.close) { + notif.close(); + } + else if (notif.cancel) { + notif.cancel(); + } + }, data.timeout); + } + + return notif; + } else { + webkitNotifications.requestPermission(function () { + return WebNotifications.show(data); + }); + } + } }, requestPermission: function () {