chore(notify) new -> module.exports

This commit is contained in:
coderaiser 2017-02-21 17:01:05 +02:00
parent ab196b35a6
commit 3d05a6ee1e

View file

@ -4,48 +4,43 @@
const Events = require('./events');
module.exports = new Notify();
let Show;
function Notify() {
let Show;
Events.add({
'blur': () => {
Show = true;
},
'focus': () => {
Show = false;
}
});
module.exports.send = (msg) => {
const notifications = CloudCmd.config('notifications');
const focus = window.focus.bind(window);
const granted = check();
const Notify = this;
const Notification = window.Notification;
if (!notifications || !granted || !Show)
return;
Events.add({
'blur': () => {
Show = true;
},
'focus': () => {
Show = false;
}
const notify = new Notification(msg, {
icon: '/img/favicon/favicon-notify.png'
});
Events.addClick(notify, focus);
};
module.exports.check = check;
function check() {
const Not = Notification;
const perm = Not && Not.permission;
this.send = (msg) => {
const notifications = CloudCmd.config('notifications');
const focus = window.focus.bind(window);
const granted = Notify.check();
if (notifications && granted && Show) {
const notify = new Notification(msg, {
icon: '/img/favicon/favicon-notify.png'
});
Events.addClick(notify, focus);
}
};
this.check = () => {
const Not = Notification;
const perm = Not && Not.permission;
if (perm === 'granted')
return true;
};
this.request = () => {
if (Notification)
Notification.requestPermission();
};
return perm === 'granted';
}
module.exports.request = () => {
if (Notification)
Notification.requestPermission();
};