-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-Overlay.js
70 lines (62 loc) · 1.49 KB
/
MMM-Overlay.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
const NOTIFICATIONS = {
SHOW: "OVERLAY.SHOW",
HIDE: "OVERLAY.HIDE",
ACTIVE: "OVERLAY.ACTIVE",
};
Module.register("MMM-Overlay", {
defaults: {
active: false,
},
/**
* Apply the default styles.
*/
getStyles() {
return ["MMM-Overlay.css"];
},
/**
* Pseudo-constructor for our module. Initialize stuff here.
*/
start() {
this.resume();
},
suspend() {
const currentActive = this.getActive();
this.setActive(false);
this.config.active = currentActive;
},
resume() {
this.setActive(this.config.active);
},
/**
* This is the place to receive notifications from other modules or the system.
*
* @param {string} notification The notification ID, it is preferred that it prefixes your module name
* @param {number} payload the payload type.
*/
notificationReceived(notification, payload) {
Log.debug("MMM-Overlay notificationReceived", notification, payload);
switch (notification) {
case NOTIFICATIONS.SHOW:
this.setActive(true);
break;
case NOTIFICATIONS.HIDE:
this.setActive(false);
break;
case NOTIFICATIONS.ACTIVE:
this.setActive(payload);
break;
}
},
setActive(active) {
this.config.active = active;
const overlay = document.getElementsByClassName("region overlay")[0];
if (active) {
overlay.classList.add("active");
} else {
overlay.classList.remove("active");
}
},
getActive() {
return this.config.active;
}
});