forked from ReDEnergy/SessionSync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification-system.js
More file actions
54 lines (39 loc) · 1.42 KB
/
Copy pathnotification-system.js
File metadata and controls
54 lines (39 loc) · 1.42 KB
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
define(function(require, exports) {
'use strict';
// *****************************************************************************
// Custom Modules
const { HTMLCreator } = require('../utils/dom');
const { WindowEvents } = require('../utils/global-events');
// *****************************************************************************
// NotificationSystem
function NotificationSystem(document)
{
var DomElem = HTMLCreator(document);
var panel = DomElem('div', {class : 'notification-system'});
var info = DomElem('div', {class : 'info'});
var warning = DomElem('div', {class : 'warning'});
panel.appendChild(info);
panel.appendChild(warning);
// ------------------------------------------------------------------------
// Events
var infoTimeout = 0;
var closeInfoBox = function closeInfoBox()
{
info.removeAttribute('active');
};
var showInfo = function showInfo(options)
{
info.textContent = options.message;
info.setAttribute('active', '');
clearTimeout(infoTimeout);
infoTimeout = setTimeout(closeInfoBox, options.timeout ? options.timeout : 1500);
};
WindowEvents.on(document, 'Notification', showInfo);
// ------------------------------------------------------------------------
// Public data
this.DOMRoot = panel;
}
// *****************************************************************************
// Public API
exports.NotificationSystem = NotificationSystem;
});