You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptpad/www/common/common-notifier.js

30 lines
715 B
JavaScript

define([
'/common/visible.js',
'/common/notify.js'
], function (Visible, Notify) {
var Notifier = {};
var notify = {};
Notifier.unnotify = function () {
if (notify.tabNotification &&
typeof(notify.tabNotification.cancel) === 'function') {
notify.tabNotification.cancel();
}
};
Notifier.notify = function () {
if (Visible.isSupported() && !Visible.currently()) {
Notifier.unnotify();
notify.tabNotification = Notify.tab(1000, 10);
}
};
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { Notifier.unnotify(); }
});
}
return Notifier;
});