client: clicking the popup refocus browser window, switch to PM tab as necessary
This commit is contained in:
parent
d862a3f703
commit
af324441b7
@ -146,17 +146,23 @@ var date_format = function(d, format) {
|
||||
|
||||
/* */
|
||||
|
||||
var notify = function(title, body) {
|
||||
var notify = function(title, body, tab) {
|
||||
if (!("Notification" in window)) {
|
||||
return; // not supported by browser
|
||||
}
|
||||
|
||||
switch (window.Notification.permission) {
|
||||
case "granted": {
|
||||
new Notification(title, {
|
||||
var n = new Notification(title, {
|
||||
body: body,
|
||||
icon: EXTERN_ROOT + "/favicon.ico"
|
||||
});
|
||||
n.onclick = function() {
|
||||
parent.focus(); // recent chrome
|
||||
window.focus(); // older browsers
|
||||
tab_set(tab);
|
||||
this.close();
|
||||
};
|
||||
} break;
|
||||
|
||||
case "denied": return;
|
||||
@ -857,7 +863,7 @@ var desktop_notifications_toggle = function(ev) {
|
||||
};
|
||||
|
||||
var desktop_notifications_onEnable = function() {
|
||||
notify(hub_hubname, "Desktop popups enabled");
|
||||
notify(hub_hubname, "Desktop popups enabled", "tab-main");
|
||||
}
|
||||
|
||||
var scrollback_move = function(delta) {
|
||||
@ -1083,7 +1089,7 @@ window.onload = function() {
|
||||
tab_mark_unread( pm_tabs[data.user] );
|
||||
|
||||
if (desktop_notifications_enabled) {
|
||||
notify("Message from " + data.user, data.message);
|
||||
notify("Message from " + data.user, data.message, pm_tabs[data.user]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user