This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
87 lines (72 loc) · 2.66 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PNotifyService = exports.PNotifySettings = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _pnotify = require('pnotify');
var _pnotify2 = _interopRequireDefault(_pnotify);
require('pnotify/dist/pnotify.css');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var PNotifySettings = exports.PNotifySettings = function PNotifySettings() {
_classCallCheck(this, PNotifySettings);
};
var PNotifyService = exports.PNotifyService = function () {
_createClass(PNotifyService, null, [{
key: 'parameters',
get: function get() {
return [[PNotifySettings]];
}
}]);
function PNotifyService(settings) {
_classCallCheck(this, PNotifyService);
this.pnotifySettings = Object.assign({ styling: 'brighttheme' }, settings);
if (typeof this.pnotifySettings.styling === 'undefined') {
throw new Error('pnotifySettings.styling must be a string');
}
this.isDesktop = false;
}
_createClass(PNotifyService, [{
key: 'desktop',
value: function desktop() {
_pnotify2.default.desktop.permission();
this.isDesktop = true;
}
}, {
key: 'pnotify',
value: function pnotify(opts) {
opts.styling = this.pnotifySettings.styling;
if (this.isDesktop) {
opts.desktop = opts.desktop || {};
opts.desktop.desktop = true;
}
return new _pnotify2.default(opts);
}
}, {
key: 'success',
value: function success(opts) {
opts.type = 'success';
return this.pnotify(opts);
}
}, {
key: 'notice',
value: function notice(opts) {
opts.type = 'notice';
return this.pnotify(opts);
}
}, {
key: 'error',
value: function error(opts) {
opts.type = 'error';
return this.pnotify(opts);
}
}, {
key: 'info',
value: function info(opts) {
opts.type = 'info';
return this.pnotify(opts);
}
}]);
return PNotifyService;
}();