From 658b824d5a1da6662910b767b82546b6e7fbe9dc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 6 Jun 2014 13:14:02 -0400 Subject: [PATCH] update channels --- dashboard-ui/scripts/extensions.js | 55 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 21 deletions(-) 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 () {