forked from AlexDespain01/mm-hide-all
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMMM-HideAll.js
executable file
·94 lines (83 loc) · 2.47 KB
/
MMM-HideAll.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
88
89
90
91
92
93
94
/* global Module */
/* Magic Mirror
* Module: MMM Hide All
* Created by: masters1222 (https://github.com/masters1222)
* Modified my Snille (https://github.com/Snille)
*
* By EoF https://forum.magicmirror.builders/user/eof
* MIT Licensed.
*/
Module.register("MMM-HideAll",{
/**
* Module config defaults
*/
defaults: {
// Button "Hide" text.
hidetext: "",
// Button "Show" text.
showtext: "",
// Fade Speed
fadeSpeed: 1000,
// Visibility of button when modules are hidden 1.0 (full visibility) - 0.0 (no visibility).
vishidden: 0.3,
// Font awesome symbol to show when modules are hidden (instead of text).
symbolhide: "toggle-off",
// Font awesome symbol to show when modules are shown (instead of text).
symbolshow: "toggle-on"
},
// Load the jquery file.
getScripts: function() {
return ["modules/MMM-HideAll/js/jquery.js"];
},
// Load the font awesome symbols and the defined styles.
getStyles: function() {
return ["font-awesome.css", "MMM-HideAll.css"];
},
getDom: function() {
var wrapper = document.createElement("div");
var button = document.createElement("div");
var text = document.createElement("div");
var symbol = document.createElement("div");
var overlay = document.createElement("div");
var hidden = true;
var buttontexthide = this.config.hidetext;
var buttontextshow = this.config.showtext;
var fadeSpeed = this.config.fadeSpeed;
var visshown = this.config.visshown;
var vishidden = this.config.vishidden;
var symbolhide = this.config.symbolhide;
var symbolshow = this.config.symbolshow;
overlay.className = "paint-it-black";
button.className = "hide-toggle";
button.appendChild(text);
text.innerHTML = buttontexthide;
if (symbolshow) {
symbol.className = "hideall-picture fa fa-" + symbolshow;
button.appendChild(symbol);
}
wrapper.appendChild(button);
wrapper.appendChild(overlay);
$(button).on("click", function(){
if (hidden) {
$(overlay).fadeIn(fadeSpeed);
$(button).fadeTo(fadeSpeed, vishidden);
$(text).html(buttontextshow);
if (symbolhide) {
symbol.className = "hideall-picture fa fa-" + symbolhide;
button.appendChild(symbol);
}
hidden = false;
} else {
$(overlay).fadeOut(fadeSpeed);
$(button).fadeTo(fadeSpeed, 1);
$(text).html(buttontexthide);
if (symbolshow) {
symbol.className = "hideall-picture fa fa-" + symbolshow;
button.appendChild(symbol);
}
hidden = true;
}
});
return wrapper;
}
});