Enable browser notifications for messaging tools

This commit is contained in:
yflory
2018-10-02 12:08:25 +02:00
parent 1201f2dcc4
commit c5c6dc8223
5 changed files with 38 additions and 13 deletions

View File

@@ -12,13 +12,25 @@ define([
}
};
Notifier.notify = function () {
Notifier.notify = function (data) {
if (Visible.isSupported() && !Visible.currently()) {
if (data) {
var title = data.title;
if (document.title) { title += ' (' + document.title + ')'; }
Notify.system(data.msg, title);
return;
}
Notifier.unnotify();
notify.tabNotification = Notify.tab(1000, 10);
}
};
Notifier.getPermission = function () {
if (Notify.isSupported()) {
Notify.getPermission();
}
};
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { Notifier.unnotify(); }