-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAngle_preloader.js
168 lines (145 loc) · 6.34 KB
/
Angle_preloader.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
var angle_preloader_element = document.getElementById("Angle_Preloader");
class createElement {
constructor(tag, style) {
this.element = document.createElement(tag);
this.element.style = style;
return this.element;
}
}
class Angle_Preloader {
constructor(option) {
// get Element Id
angle_preloader_element = document.getElementById("Angle_Preloader");
// set Option in Class
this.option = option;
// set default window mode ____ If not set
var window = this.getOptionValue(this.option.window, "body");
// Set window mode
if (window == "body") angle_preloader_element.style = "width: 100%;height: 100%;background-color: #fff;position: fixed;z-index: 99;";
if (window == "element") angle_preloader_element.style = "width: 100%;height: 100%;background-color: #fff;z-index: 1;";
// Set Default Message ___ If not set
var message = this.getOptionValue(this.option.message, "");
// Create Elements
this.spans = [];
this.mainDiv = new createElement("div", "position: relative;width:50%;height:50%;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 100");
this.insideDiv1 = new createElement("div", "position: relative;top: 50%;left: 50%;transform: translate(-50%, -50%)");
this.loadingMessage = new createElement("h4", "position:relative;transform:translateY(-50%);font-size:18px;font-family: 'Comic Neue', cursive;text-align: center;color:var(--text-color)");
this.loadingMessage.innerText = message;
// Create Style Node
this.styleNode = document.createElement("style");
this.styleNode.type = "text/css";
var insideStyle = document.createTextNode(":root{--first-color:rgba(0,0,0,1);--second-color:rgba(0,0,0,0.7);--3th-color:rgba(0,0,0,0.7);--text-color:rgba(0,0,0,1);--diameter:50px} *{padding:0px;margin:0px;box-sizing: border-box;} @keyframes angle_preloader_fadeout {from{opacity: 1;display:block;} to{opacity: 0;display:none;z-index: -1}}");
this.styleNode.appendChild(insideStyle);
// Run Preloader
if (option.type == "wave") this.wave(option);
if (option.type == "flag") this.flag(option);
if (option.type == "loading") this.loading(option);
if (option.type == "orbital_1") this.orbital(option);
if (option.type == "orbital_2") this.orbital2(option);
if (option.type == "radio_wave") this.radioWave(option);
if (option.type == "balls") this.balls(option);
if (option.type == "anime_text") this.anime_text(option);
if (option.type == "diamond") this.diamond(option);
if (option.type == "square") this.square(option);
// Append elements to main Element
angle_preloader_element.appendChild(this.mainDiv);
angle_preloader_element.appendChild(this.loadingMessage);
// append style Node
document.getElementsByTagName("head")[0].appendChild(this.styleNode);
}
setSettings() {
if (this.option.darkTheme == true) {
this.darkTheme(true);
}
if (this.option.color1 != undefined && this.option.color1 != "") {
this.setFirstColor(this.option.color1);
}
if (this.option.color2 != undefined && this.option.color2 != "") {
this.setSecondColor(this.option.color2);
}
if (this.option.color3 != undefined && this.option.color3 != "") {
this.set3thColor(this.option.color3);
}
if (this.option.messageColor != undefined && this.option.messageColor != "") {
this.setTextColor(this.option.messageColor);
}
if (this.option.websiteColor != undefined && this.option.websiteColor != "") {
this.siteColor(this.option.websiteColor);
}
if (this.option.domainColor != undefined && this.option.domainColor != "") {
this.domainColor(this.option.domainColor);
}
if (this.option.dotColor != undefined && this.option.dotColor != "") {
this.dotColor(this.option.dotColor);
}
}
getOptionValue(option, defaultVal) {
if (option == undefined || option == "") {
return defaultVal;
} else {
return option;
}
}
//! OTHER FUNCTIONS ______ => TOOLS
hide() {
angle_preloader_element.style.animation = "angle_preloader_fadeout 1s 1 linear forwards";
}
setText(text) {
this.loadingMessage.innerText = text;
}
setTextColor(color) {
document.documentElement.style.setProperty("--text-color", color);
}
setTextFontFamily(fontName) {
this.loadingMessage.style.fontFamily = fontName;
}
setTextFontSize(fontSize) {
this.loadingMessage.style.fontSize = fontSize + "px";
}
setBlockColor(color) {
document.documentElement.style.setProperty("--first-color", color);
document.documentElement.style.setProperty("--second-color", color);
for (let i = 0; i < this.spans.length; i++) {
this.spans[i].style.background = color;
}
}
setFirstColor(color) {
document.documentElement.style.setProperty("--first-color", color);
for (let i = 0; i < this.spans.length; i++) {
this.spans[i].style.background = color;
}
}
setSecondColor(color) {
document.documentElement.style.setProperty("--second-color", color);
}
set3thColor(color) {
document.documentElement.style.setProperty("--3th-color", color);
}
darkTheme(darkTheme) {
//! for dark mode
if (darkTheme) {
this.setTextColor("#fff");
this.setFirstColor("#fff");
angle_preloader_element.style.backgroundColor = "#000";
switch (this.option.type) {
case "wave":
var spanCount = this.getOptionValue(this.option.spanCount, 6)
for (let i = 0; i < spanCount; i++) {
this.secondSpans[i].style.backgroundColor = "rgba(255,255,255,0.1)";
}
break;
default:
break;
}
}
}
siteColor(color) {
this.insideDiv1.style.color = color;
}
domainColor(color) {
this.insideDiv2.style.color = color;
}
dotColor(color) {
this.insideDiv3.style.color = color;
}
}