From d9e7fc24fec8f4f3993984ed5173d599f0add2fe Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 8 Oct 2019 16:25:03 +0200 Subject: [PATCH] Focus the tab when clicking on a notification --- www/common/notify.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/www/common/notify.js b/www/common/notify.js index 77a1e6815..a3c8cd2b8 100644 --- a/www/common/notify.js +++ b/www/common/notify.js @@ -30,10 +30,19 @@ define(['/api/config'], function (ApiConfig) { icon = DEFAULT_ALT; } - return new Notification(title,{ + var n = new Notification(title,{ icon: icon, body: msg, }); + n.onclick = function () { + if (!document) { return; } + try { + parent.focus(); + window.focus(); //just in case, older browsers + this.close(); + } catch (e) {} + }; + return n; }; Module.system = function (msg, title, icon) {