archcss 2.0.0 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{css/architect.css → dist/attribution.css} +1 -4
- package/{css/arch.dev.css → dist/css/main.css} +229752 -155771
- package/dist/index.css +317741 -0
- package/dist/js/plugin.js +874 -0
- package/dist/ui/style.css +317741 -0
- package/{css/@fontawesome/css/fontawesome.css → dist/webfonts/fontawesome/css/fontawessome.css} +4 -37
- package/{css/@fontawesome/css/fontawesome.min.css → dist/webfonts/fontawesome/css/fontawessome.min.css} +3 -3
- package/{css/@fontawesome → dist/webfonts/fontawesome}/js/all.js +231 -275
- package/dist/webfonts/fontawesome/js/all.min.js +6 -0
- package/dist/webfonts/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/dist/webfonts/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/dist/webfonts/googleapis/fonts.min.css +1 -0
- package/dist/webfonts/lucide/css/lucide.css +72 -0
- package/dist/webfonts/lucide/css/lucide.min.css +1 -0
- package/dist/webfonts/lucide/js/lucide.min.js +12 -0
- package/license.md +32 -0
- package/package.json +54 -19
- package/readme.md +88 -32
- package/changelog +0 -76
- package/css/@fontawesome/js/all.min.js +0 -6
- package/css/@fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/css/@fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/css/@fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/css/@fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/css/@fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/css/@fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/css/@fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/css/@fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/css/@googleapis/fonts.min.css +0 -1
- package/css/arch.min.css +0 -6
- package/index.js +0 -16
- package/js/dom.js +0 -1106
- package/licence +0 -21
- /package/{css/@fontawesome → dist/webfonts/fontawesome}/LICENSE.txt +0 -0
- /package/{css/@googleapis → dist/webfonts/googleapis}/fonts.css +0 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Name : ArchCSS - Modern CSS framework for responsive and attractive websites and applications.
|
|
4
|
+
* Version : 3.0.0 [beta]
|
|
5
|
+
* Author : @bebagodfried - [archCSS dev.](https://archcss.com/team/@bebagodfried)
|
|
6
|
+
* License : MIT license
|
|
7
|
+
*/
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* AJAX
|
|
19
|
+
* HttpRequest: Create XMLHttpRequest object
|
|
20
|
+
*/
|
|
21
|
+
let HttpRequest = () => {
|
|
22
|
+
if (window.XMLHttpRequest) {
|
|
23
|
+
return new XMLHttpRequest;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
try {
|
|
27
|
+
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
try {
|
|
31
|
+
return new ActiveXObject('Msxml2.XMLHTTP');
|
|
32
|
+
}
|
|
33
|
+
catch (XMLHttpRequest_ERR) {
|
|
34
|
+
console.error(XMLHttpRequest_ERR);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Globals
|
|
42
|
+
* $_: Get/set document vars
|
|
43
|
+
*/
|
|
44
|
+
let $_ = (get, set = '') => {
|
|
45
|
+
switch (get) {
|
|
46
|
+
// DOM Objects
|
|
47
|
+
case 'title':
|
|
48
|
+
if (set) {
|
|
49
|
+
document.title = `${set}`;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return document.title;
|
|
54
|
+
}
|
|
55
|
+
case 'charset':
|
|
56
|
+
return document.characterSet;
|
|
57
|
+
case 'baseURI':
|
|
58
|
+
return document.baseURI;
|
|
59
|
+
case 'links':
|
|
60
|
+
return document.links;
|
|
61
|
+
case 'scripts':
|
|
62
|
+
return document.scripts;
|
|
63
|
+
case 'embeds':
|
|
64
|
+
return document.embeds;
|
|
65
|
+
case 'images':
|
|
66
|
+
return document.images;
|
|
67
|
+
case 'readyState':
|
|
68
|
+
return document.readyState;
|
|
69
|
+
// BOM Objects
|
|
70
|
+
case 'cookies':
|
|
71
|
+
return navigator.cookieEnabled;
|
|
72
|
+
case 'language':
|
|
73
|
+
return navigator.language;
|
|
74
|
+
case 'online':
|
|
75
|
+
return navigator.onLine;
|
|
76
|
+
case 'userAgent':
|
|
77
|
+
return navigator.userAgent;
|
|
78
|
+
// Server & location
|
|
79
|
+
case 'host':
|
|
80
|
+
if (set) {
|
|
81
|
+
location.host = `${set}`;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return location.host;
|
|
86
|
+
}
|
|
87
|
+
case 'hostname':
|
|
88
|
+
if (set) {
|
|
89
|
+
location.hostname = `${set}`;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return location.hostname;
|
|
94
|
+
}
|
|
95
|
+
case 'href':
|
|
96
|
+
if (set) {
|
|
97
|
+
location.href = `${set}`;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return location.href;
|
|
102
|
+
}
|
|
103
|
+
case 'url':
|
|
104
|
+
if (set) {
|
|
105
|
+
location.href = `${set}`;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return location.href;
|
|
110
|
+
}
|
|
111
|
+
case 'pathname':
|
|
112
|
+
if (set) {
|
|
113
|
+
location.pathname = `${set}`;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return location.pathname;
|
|
118
|
+
}
|
|
119
|
+
case 'port':
|
|
120
|
+
if (set) {
|
|
121
|
+
location.port = `${set}`;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return location.port;
|
|
126
|
+
}
|
|
127
|
+
case 'protocol':
|
|
128
|
+
if (set) {
|
|
129
|
+
location.protocol = `${set}`;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return location.protocol;
|
|
134
|
+
}
|
|
135
|
+
case 'search':
|
|
136
|
+
if (set) {
|
|
137
|
+
location.search = `${set}`;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return location.search;
|
|
142
|
+
}
|
|
143
|
+
case 'history':
|
|
144
|
+
switch (set) {
|
|
145
|
+
case -1: return history.back();
|
|
146
|
+
case +1: return history.forward();
|
|
147
|
+
case 0: return history.go();
|
|
148
|
+
case 'back': return history.back();
|
|
149
|
+
case 'forward': return history.forward();
|
|
150
|
+
case 'reload': return history.go();
|
|
151
|
+
default: return history.go();
|
|
152
|
+
}
|
|
153
|
+
case 'update':
|
|
154
|
+
return document.lastModified;
|
|
155
|
+
// Return https(SSl) state of current page
|
|
156
|
+
case 'https':
|
|
157
|
+
return location.protocol === 'https:';
|
|
158
|
+
// Owner
|
|
159
|
+
case 'author-org':
|
|
160
|
+
return 'archcss-dev';
|
|
161
|
+
case 'author-name':
|
|
162
|
+
return 'Beba Godfried';
|
|
163
|
+
case 'author-right':
|
|
164
|
+
return 'Godfried\'Ux';
|
|
165
|
+
case 'author-email':
|
|
166
|
+
return 'me@bebagodfried.com';
|
|
167
|
+
case 'author-site':
|
|
168
|
+
return 'https://bebagodfried.com';
|
|
169
|
+
case 'copyright':
|
|
170
|
+
return 'Powered by Godfried\'Ux';
|
|
171
|
+
case 'owner':
|
|
172
|
+
return 'archcss-dev - by Godfried\'Ux';
|
|
173
|
+
case 'version':
|
|
174
|
+
return '3.0.0';
|
|
175
|
+
default:
|
|
176
|
+
console.info(`[404]: Reference '${get}' not found!`);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
/** end:Globals **/
|
|
181
|
+
// date: Return date
|
|
182
|
+
let date = (format = '', type = '') => {
|
|
183
|
+
// New date object
|
|
184
|
+
var date = new Date();
|
|
185
|
+
// return Alwayse two digits
|
|
186
|
+
const digit = function (i) {
|
|
187
|
+
if (i < 10)
|
|
188
|
+
i = '0' + i;
|
|
189
|
+
return i;
|
|
190
|
+
};
|
|
191
|
+
// H: Hours
|
|
192
|
+
const H = date.getHours();
|
|
193
|
+
// i: Minutes
|
|
194
|
+
const i = digit(date.getMinutes());
|
|
195
|
+
// s: Seconds
|
|
196
|
+
const s = digit(date.getSeconds());
|
|
197
|
+
// ms: Seconds
|
|
198
|
+
const ms = date.getMilliseconds();
|
|
199
|
+
// t: Timezone
|
|
200
|
+
const t = date.getTimezoneOffset();
|
|
201
|
+
// Y: Year
|
|
202
|
+
const Y = date.getFullYear();
|
|
203
|
+
// m: Month
|
|
204
|
+
const m = date.getMonth();
|
|
205
|
+
// d: Day
|
|
206
|
+
const d = date.getDate();
|
|
207
|
+
// f: Weekday
|
|
208
|
+
const f = date.getDay();
|
|
209
|
+
switch (format) {
|
|
210
|
+
case 'H': //=> Hours
|
|
211
|
+
if (isset(type)) {
|
|
212
|
+
if (type == 'En') {
|
|
213
|
+
// return 12 hours format
|
|
214
|
+
return H % 12 || 12;
|
|
215
|
+
}
|
|
216
|
+
else if (type == 'Fr') {
|
|
217
|
+
// return 24 hours format
|
|
218
|
+
return H;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
return H;
|
|
223
|
+
}
|
|
224
|
+
case 'i': return i; //=> Minutes
|
|
225
|
+
case 's': return s; //=> Seconds
|
|
226
|
+
case 'ms': return ms; //=> Milliseconds
|
|
227
|
+
case 't': return t; //=> Timezone
|
|
228
|
+
case 'Y': return Y; //=> Year
|
|
229
|
+
case 'm': //=> Month
|
|
230
|
+
if (isset(type)) {
|
|
231
|
+
if (type == 'En') {
|
|
232
|
+
// return the month in english
|
|
233
|
+
return months_en[m];
|
|
234
|
+
}
|
|
235
|
+
else if (type == 'Fr') {
|
|
236
|
+
// return the month in french
|
|
237
|
+
return months_fr[m];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// return the month as number
|
|
242
|
+
return m + 1;
|
|
243
|
+
}
|
|
244
|
+
case 'd': return (d); //=> Day
|
|
245
|
+
case 'f': return f; //=> Weekday
|
|
246
|
+
case 'En': return weekdays_en[f] + ', ' + months_en[m] + ' ' + digit(d) + ', ' + Y;
|
|
247
|
+
case 'Fr': return weekdays_fr[f] + ' ' + digit(d) + ' ' + months_fr[m] + ' ' + Y;
|
|
248
|
+
case 'DD/MM/YY': return digit(d) + '/' + digit(m + 1) + '/' + Y;
|
|
249
|
+
case 'MM/DD/YY': return digit(m + 1) + '/' + digit(d) + '/' + Y;
|
|
250
|
+
case 'DD-MM-YY': return digit(d) + '-' + digit(m + 1) + '-' + Y;
|
|
251
|
+
case 'MM-DD-YY': return digit(m + 1) + '-' + digit(d) + '-' + Y;
|
|
252
|
+
case 'DD/MM': return digit(d) + '/' + digit(m + 1);
|
|
253
|
+
case 'MM/DD': return digit(m + 1) + '/' + digit(d);
|
|
254
|
+
case 'DD-MM': return digit(d) + '-' + digit(m + 1);
|
|
255
|
+
case 'MM-DD': return digit(m + 1) + '-' + digit(d);
|
|
256
|
+
// hours:minutes
|
|
257
|
+
case 'H:i':
|
|
258
|
+
if (isset(type)) {
|
|
259
|
+
if (type == 'En') {
|
|
260
|
+
// return time in 12 hours format
|
|
261
|
+
return (H % 12 || 12) + ':' + i;
|
|
262
|
+
}
|
|
263
|
+
else if (type == 'Fr') {
|
|
264
|
+
// return time in 24 hours format
|
|
265
|
+
return H + ':' + i;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// return time hours:minutes
|
|
270
|
+
return H + ':' + i;
|
|
271
|
+
}
|
|
272
|
+
// hours:minutes:seconds
|
|
273
|
+
case 'H:i:s':
|
|
274
|
+
if (isset(type)) {
|
|
275
|
+
if (type == 'En') {
|
|
276
|
+
// return time in 12 hours format with seconds
|
|
277
|
+
return (H % 12 || 12) + ':' + i + ':' + s;
|
|
278
|
+
}
|
|
279
|
+
else if (type == 'Fr') {
|
|
280
|
+
// return time in 24 hours format with seconds
|
|
281
|
+
return H + ':' + i + ':' + s;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
// return time in hours:minutes:seconds
|
|
286
|
+
return H + ':' + i + ':' + s;
|
|
287
|
+
}
|
|
288
|
+
default: return date.toLocaleString();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
// Days
|
|
292
|
+
let weekdays_en = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
293
|
+
let weekdays_fr = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
|
|
294
|
+
// Months
|
|
295
|
+
let months_en = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
296
|
+
let months_fr = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'];
|
|
297
|
+
// strcopy: copy a text or the content of an element to the clipboard
|
|
298
|
+
let strcopy = (text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
299
|
+
try {
|
|
300
|
+
// When the argument matches an element on the page, copy its text content
|
|
301
|
+
const el = select(text);
|
|
302
|
+
const value = el != null && el.nodeType ? el.innerText : text;
|
|
303
|
+
yield navigator.clipboard.writeText(value);
|
|
304
|
+
}
|
|
305
|
+
catch (err) {
|
|
306
|
+
console.error('Failed to copy text: ', err);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
// goto: on event redirection to somewhere
|
|
310
|
+
let goto = (_location) => {
|
|
311
|
+
try {
|
|
312
|
+
location.href = _location.toString();
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
console.error('Failed to redirect: ', err);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
// attrib: Return or set an element attribute
|
|
319
|
+
// No `set` value returns the attribute, otherwise it sets it
|
|
320
|
+
let attrib = (el, name, set) => {
|
|
321
|
+
// Element selection
|
|
322
|
+
let dom = select(el);
|
|
323
|
+
if (dom == null)
|
|
324
|
+
return null;
|
|
325
|
+
// Set an attrribute value
|
|
326
|
+
if (set) {
|
|
327
|
+
try {
|
|
328
|
+
dom.setAttribute(`${name}`, `${set}`);
|
|
329
|
+
}
|
|
330
|
+
catch (ATTR_ERR) {
|
|
331
|
+
console.error(`${ATTR_ERR.name}: attrib(el: string, attrib: any, set?: any) => '${el}' has no a ${name} attribute.`);
|
|
332
|
+
}
|
|
333
|
+
// else return attrribute value
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
return dom.getAttribute(`${name}`);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* classlist: add/remove element classes
|
|
341
|
+
* If token is true, adds token (same as [...].classList.add()).
|
|
342
|
+
* If force is false, removes token (same as [...].classList.remove()).
|
|
343
|
+
* */
|
|
344
|
+
let classlist = (el, tokens) => {
|
|
345
|
+
let dom = select(el);
|
|
346
|
+
if (dom == null)
|
|
347
|
+
return null;
|
|
348
|
+
// check for each token force
|
|
349
|
+
tokens.forEach(key => {
|
|
350
|
+
dom.classList.toggle(key);
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
/** end:classlist */
|
|
354
|
+
// create: Create node elements
|
|
355
|
+
let create = (el) => {
|
|
356
|
+
return document.createElement(el);
|
|
357
|
+
};
|
|
358
|
+
// select: Node list selector
|
|
359
|
+
let select = (el, all = false) => {
|
|
360
|
+
try {
|
|
361
|
+
// Remove white space around the element
|
|
362
|
+
if (typeof (el) == 'string' && el != null)
|
|
363
|
+
el = el.trim();
|
|
364
|
+
// By default `all = false` indicate that select the first `el`
|
|
365
|
+
// all = true
|
|
366
|
+
// all = false
|
|
367
|
+
if (all) {
|
|
368
|
+
return [...document.querySelectorAll(el)];
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
return document.querySelector(el);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
catch (select_ERR) {
|
|
375
|
+
// Debug select()
|
|
376
|
+
console.error(`${select_ERR.name}: select(elememt: string, all?: boolean) => '${el}' is not a valid selector.`);
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
// select_tag: HTMLCollection selector
|
|
381
|
+
let select_tag = (el) => {
|
|
382
|
+
try {
|
|
383
|
+
// Remove white space around the element
|
|
384
|
+
if (typeof (el) == 'string' && el != null)
|
|
385
|
+
el = el.trim();
|
|
386
|
+
return document.getElementsByTagName(el);
|
|
387
|
+
}
|
|
388
|
+
catch (select_ERR) {
|
|
389
|
+
// Debug select()
|
|
390
|
+
console.error(`${select_ERR.name}: selectTag(tag: string) => '${el}' is not a valid selector.`);
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
// select_id: Element `Id` selector
|
|
395
|
+
let select_id = (el) => {
|
|
396
|
+
try {
|
|
397
|
+
// Remove white space around the element
|
|
398
|
+
if (typeof (el) == 'string' && el != null)
|
|
399
|
+
el = el.trim();
|
|
400
|
+
return document.getElementById(el);
|
|
401
|
+
}
|
|
402
|
+
catch (select_id_ERR) {
|
|
403
|
+
// Debug select_id()
|
|
404
|
+
console.error(`${select_id_ERR.name}: select_id(id: srting) => '${el}' is not a valid selector.`);
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
// drop_all: Remove element(s) list from DOM
|
|
409
|
+
let drop_all = (list) => {
|
|
410
|
+
list.forEach(el => {
|
|
411
|
+
// Remove each element by its selector
|
|
412
|
+
drop(el);
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
// drop: Remove element first occurence from DOM
|
|
416
|
+
let drop = (token) => {
|
|
417
|
+
// Element selection
|
|
418
|
+
const dom = select(token);
|
|
419
|
+
try {
|
|
420
|
+
dom.remove();
|
|
421
|
+
}
|
|
422
|
+
catch (Drop_ERR) {
|
|
423
|
+
// Escape
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
// echo: Add/Replace the content of element(s)
|
|
428
|
+
let echo = (text, el, all = false) => {
|
|
429
|
+
if (isset(el)) {
|
|
430
|
+
if (all) {
|
|
431
|
+
// all = true
|
|
432
|
+
// Genearate a list of all `el`
|
|
433
|
+
let list = select(el, all);
|
|
434
|
+
// for each element of the list add/replace content
|
|
435
|
+
list.forEach((el) => {
|
|
436
|
+
el.innerHTML = `${text}`;
|
|
437
|
+
});
|
|
438
|
+
// by default
|
|
439
|
+
// add/replace the first `el` occurence
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
const dom = select(el);
|
|
443
|
+
if (dom == null)
|
|
444
|
+
return null;
|
|
445
|
+
return dom.innerHTML = `${text}`;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
console.log(`${text}`);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
// get_innerTEXT: Get element text content
|
|
453
|
+
let get_innerTEXT = (el) => {
|
|
454
|
+
// Element selection
|
|
455
|
+
let dom = select(el);
|
|
456
|
+
if (dom == null)
|
|
457
|
+
return null;
|
|
458
|
+
return dom.innerText;
|
|
459
|
+
};
|
|
460
|
+
// set_innerTEXT: Replace element text content
|
|
461
|
+
let set_innerTEXT = (el, text) => {
|
|
462
|
+
try {
|
|
463
|
+
let dom = select(el);
|
|
464
|
+
if (dom == null)
|
|
465
|
+
return null;
|
|
466
|
+
dom.innerText = `${text}`;
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
// Debug set_innerTEXT()
|
|
470
|
+
console.error(error);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
// get_innerHTML: Get html content of element
|
|
474
|
+
let get_innerHTML = (el) => {
|
|
475
|
+
// Get html content of an element
|
|
476
|
+
const dom = select(el);
|
|
477
|
+
if (dom == null)
|
|
478
|
+
return null;
|
|
479
|
+
return dom.innerHTML;
|
|
480
|
+
};
|
|
481
|
+
// display: Display/hide specific DOM element
|
|
482
|
+
let display = (el, displayValue = 'block') => {
|
|
483
|
+
// Element selection
|
|
484
|
+
const dom = select(el);
|
|
485
|
+
if (dom == null)
|
|
486
|
+
return null;
|
|
487
|
+
// hidden by style attribute or `hidden` class, so show it
|
|
488
|
+
if (dom.style.display == 'none' || dom.classList.contains('hidden')) {
|
|
489
|
+
dom.classList.remove('hidden');
|
|
490
|
+
dom.style.display = displayValue;
|
|
491
|
+
// already shown, so hide it
|
|
492
|
+
}
|
|
493
|
+
else if (dom.style.display == displayValue || dom.classList.contains(displayValue)) {
|
|
494
|
+
dom.style.display = 'none';
|
|
495
|
+
dom.classList.add('hidden');
|
|
496
|
+
// no display value yet, set it
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
dom.style.display = displayValue;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
// hide: make hidden element of first occurence from DOM
|
|
503
|
+
let hide = (el) => {
|
|
504
|
+
// Possible classlist values
|
|
505
|
+
const list = ['block', 'inline-block', 'flex', 'inline-flex'];
|
|
506
|
+
// Element selection
|
|
507
|
+
const dom = select(el);
|
|
508
|
+
if (dom == null)
|
|
509
|
+
return null;
|
|
510
|
+
// Remove any display token, then force `hidden`
|
|
511
|
+
list.forEach(display => {
|
|
512
|
+
if (dom.classList.contains(`${display}`)) {
|
|
513
|
+
dom.classList.remove(`${display}`);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
dom.classList.add('hidden');
|
|
517
|
+
dom.style.display = 'none';
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* Events listners
|
|
521
|
+
* ...
|
|
522
|
+
*/
|
|
523
|
+
// On: Events listner
|
|
524
|
+
let on = (event, listener) => {
|
|
525
|
+
event = event.trim();
|
|
526
|
+
document.addEventListener(event, listener);
|
|
527
|
+
};
|
|
528
|
+
let on_scroll = (el, add_list, rm_list = [], offset = 0) => {
|
|
529
|
+
var dom = select(el);
|
|
530
|
+
// Add or remove class based on scroll position
|
|
531
|
+
if (window.scrollY > offset) {
|
|
532
|
+
add_list.forEach(key => {
|
|
533
|
+
dom.classList.add(key);
|
|
534
|
+
});
|
|
535
|
+
rm_list.forEach(key => {
|
|
536
|
+
dom.classList.remove(key);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
add_list.forEach(key => {
|
|
541
|
+
dom.classList.remove(key);
|
|
542
|
+
});
|
|
543
|
+
rm_list.forEach(key => {
|
|
544
|
+
dom.classList.add(key);
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
let scroll_to = (el, offset = 0) => {
|
|
549
|
+
// JavaScript to scroll to the target element
|
|
550
|
+
const dom = select_id(el);
|
|
551
|
+
if (dom == null)
|
|
552
|
+
return null;
|
|
553
|
+
// Scroll to the element, minus the offset (fixed headers and bars)
|
|
554
|
+
const top = dom.getBoundingClientRect().top + window.scrollY - offset;
|
|
555
|
+
window.scrollTo({ top: top, behavior: 'smooth' });
|
|
556
|
+
};
|
|
557
|
+
// Onclick: Click listner
|
|
558
|
+
let onClick = (el, listener) => {
|
|
559
|
+
const d = select_id(el);
|
|
560
|
+
return d.onclick = listener;
|
|
561
|
+
};
|
|
562
|
+
// Ondlclick: Double click listner
|
|
563
|
+
let onDblClick = (el, listener) => {
|
|
564
|
+
const d = select_id(el);
|
|
565
|
+
return d.ondblclick = listener;
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Validation
|
|
569
|
+
* Check for exist listner
|
|
570
|
+
*/
|
|
571
|
+
// Isset: Return true for no-empty Object/var
|
|
572
|
+
let isset = (key) => {
|
|
573
|
+
if (key != null && key != false && key != undefined) {
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
else if (key != '' && key != ' ') {
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Mixed
|
|
585
|
+
* popUp: create advenced pup-up box style
|
|
586
|
+
* @param popUp
|
|
587
|
+
*/
|
|
588
|
+
let popUp = function (window = { title: ``, favicon: ``, content: ``, html: ``, href: ``, titlebar: true, rounded: true, shadow: true, classlist: [], style: ``, border: true, overlay: false, height: ``, width: ``, top: ``, right: ``, bottom: ``, left: ``, index: 8, timeout: 0 }) {
|
|
589
|
+
// Pop_up
|
|
590
|
+
// #1. Create a new window with basic set
|
|
591
|
+
const WINDOW = create('div');
|
|
592
|
+
// setup
|
|
593
|
+
WINDOW.id = window.title;
|
|
594
|
+
WINDOW.classList.add('rounded', 'flex', 'flex-column', 'select-none');
|
|
595
|
+
WINDOW.style.position = 'fixed';
|
|
596
|
+
// size
|
|
597
|
+
WINDOW.style.height = window.height;
|
|
598
|
+
WINDOW.style.width = window.width;
|
|
599
|
+
// #2. Check window's already exist
|
|
600
|
+
if (select_id(`${WINDOW.id}`)) {
|
|
601
|
+
let el = select_id(WINDOW.id);
|
|
602
|
+
el === null || el === void 0 ? void 0 : el.classList.add('animate-pulse');
|
|
603
|
+
setTimeout(() => {
|
|
604
|
+
el === null || el === void 0 ? void 0 : el.classList.remove('animate-pulse');
|
|
605
|
+
}, 1000);
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
// #3. classlist: Add more features/tweaks
|
|
609
|
+
if (window.classlist) {
|
|
610
|
+
window.classlist.forEach(classItem => {
|
|
611
|
+
WINDOW.classList.add(classItem);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
// #4. index/z-index: add a window priority (default: 8)
|
|
615
|
+
if (window.index) {
|
|
616
|
+
WINDOW.classList.add(`${'z-' + window.index}`);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
WINDOW.classList.add('z-8');
|
|
620
|
+
}
|
|
621
|
+
// #5. style: choose apearence between dark/light (default: light)
|
|
622
|
+
if (`${window.style}` == 'dark') {
|
|
623
|
+
WINDOW.classList.add('bg-dark-900', 'fg-light');
|
|
624
|
+
}
|
|
625
|
+
else if (`${window.style}` == 'light') {
|
|
626
|
+
WINDOW.classList.add('bg-light', 'fg-dark-900');
|
|
627
|
+
}
|
|
628
|
+
else if (`${window.style}` == 'none') {
|
|
629
|
+
WINDOW.style.color = 'inherit';
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
WINDOW.classList.add('bg-light', 'fg-dark-900');
|
|
633
|
+
}
|
|
634
|
+
// #6. border: enable window border (default: true)
|
|
635
|
+
if (window.border == true) {
|
|
636
|
+
WINDOW.classList.add('border');
|
|
637
|
+
}
|
|
638
|
+
else if (window.border == false) {
|
|
639
|
+
// do nothing ...
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
WINDOW.classList.add('border');
|
|
643
|
+
}
|
|
644
|
+
// #7. rounded: enable window rounded border (default: true)
|
|
645
|
+
if (window.rounded == true) {
|
|
646
|
+
WINDOW.classList.add('rounded');
|
|
647
|
+
}
|
|
648
|
+
else if (window.rounded == false) {
|
|
649
|
+
// do nothing ...
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
WINDOW.classList.add('rounded');
|
|
653
|
+
}
|
|
654
|
+
// #8. shadow: enable window shadow (default: true)
|
|
655
|
+
if (window.shadow == true) {
|
|
656
|
+
WINDOW.classList.add('shadow-sm');
|
|
657
|
+
}
|
|
658
|
+
else if (window.shadow == false) {
|
|
659
|
+
// do nothing ...
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
WINDOW.classList.add('shadow-sm');
|
|
663
|
+
}
|
|
664
|
+
// #9. [top, right, bottom, left]: set window position
|
|
665
|
+
if (window.top || window.right || window.bottom || window.left) {
|
|
666
|
+
WINDOW.style.top = window.top;
|
|
667
|
+
WINDOW.style.right = window.right;
|
|
668
|
+
WINDOW.style.bottom = window.bottom;
|
|
669
|
+
WINDOW.style.left = window.left;
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
WINDOW.style.top = '50%';
|
|
673
|
+
WINDOW.style.left = '50%';
|
|
674
|
+
WINDOW.classList.add('translate--50');
|
|
675
|
+
}
|
|
676
|
+
// #10. header/title bar
|
|
677
|
+
// #10.1 Create a title bar
|
|
678
|
+
const HEADER = create('div');
|
|
679
|
+
HEADER.classList.add('flex', 'items-center', 'justify-between', 'full-width');
|
|
680
|
+
HEADER.style.padding = '.2rem';
|
|
681
|
+
// #10.2 favicon: add an icon as window illustrator
|
|
682
|
+
const FAVICON = create('img');
|
|
683
|
+
if (window.favicon) {
|
|
684
|
+
FAVICON.src = window.favicon;
|
|
685
|
+
FAVICON.classList.add('size-32');
|
|
686
|
+
}
|
|
687
|
+
// #10.3 Window action bar
|
|
688
|
+
// * title: set the window title/id
|
|
689
|
+
const TITLE = create('span');
|
|
690
|
+
TITLE.classList.add('pl-1', 'line-clamp-1', 'sm:line-clamp-1');
|
|
691
|
+
TITLE.innerHTML = window.title;
|
|
692
|
+
// * add moving icon
|
|
693
|
+
const WIN_Move = create('button');
|
|
694
|
+
WIN_Move.classList.add('bg-none', 'cursor-default', 'fa-solid', 'fa-up-down-left-right', 'p-0', 'rounded-full', 'size-32', 'muted');
|
|
695
|
+
// * add closing button
|
|
696
|
+
const WIN_Close = create('button');
|
|
697
|
+
WIN_Close.classList.add('bg-none', 'fa-solid', 'fa-times', 'hover:bg-danger', 'p-0', 'rounded-full', 'size-32');
|
|
698
|
+
// #11. views: create adaptable content
|
|
699
|
+
var view = '';
|
|
700
|
+
if (window.content) {
|
|
701
|
+
view = 'p';
|
|
702
|
+
}
|
|
703
|
+
else if (window.html) {
|
|
704
|
+
view = 'div';
|
|
705
|
+
}
|
|
706
|
+
else if (window.href) {
|
|
707
|
+
view = 'iframe';
|
|
708
|
+
}
|
|
709
|
+
// - create main window view
|
|
710
|
+
const CONTENT = create(view);
|
|
711
|
+
if (window.content) {
|
|
712
|
+
CONTENT.classList.add('m-0', 'px-2', 'py-1', 'w-100');
|
|
713
|
+
CONTENT.innerHTML = window.content;
|
|
714
|
+
if (window.titlebar == true) {
|
|
715
|
+
CONTENT.classList.add('border', 'border-0', 'border-top-1');
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else if (window.html) {
|
|
719
|
+
CONTENT.classList.add('max-height', 'border-0', 'border-top-1', 'border-white', 'px-2', 'py-1', 'w-100');
|
|
720
|
+
CONTENT.innerHTML = window.html;
|
|
721
|
+
}
|
|
722
|
+
else if (window.href) {
|
|
723
|
+
CONTENT.classList.add('no-border');
|
|
724
|
+
CONTENT.height = '100%';
|
|
725
|
+
CONTENT.width = '100%';
|
|
726
|
+
CONTENT.src = window.href;
|
|
727
|
+
if (window.titlebar == true) {
|
|
728
|
+
CONTENT.classList.add('border-0', 'border-top-1', 'border-white');
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// #12. Actions
|
|
732
|
+
// #12.1 draging action (double-click)
|
|
733
|
+
WINDOW.ondblclick = () => {
|
|
734
|
+
let move = attrib('.js_focus', 'aria-grabbed');
|
|
735
|
+
WINDOW.classList.toggle('cursor-grabbing');
|
|
736
|
+
if (move == 'true') {
|
|
737
|
+
WINDOW.setAttribute('aria-grabbed', 'false');
|
|
738
|
+
WIN_Move.classList.add('muted');
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
WINDOW.setAttribute('aria-grabbed', 'true');
|
|
742
|
+
WIN_Move.classList.remove('muted');
|
|
743
|
+
}
|
|
744
|
+
// reset drag offset on each grab start
|
|
745
|
+
delete WINDOW.dataset.dragOffsetX;
|
|
746
|
+
delete WINDOW.dataset.dragOffsetY;
|
|
747
|
+
};
|
|
748
|
+
WINDOW.addEventListener('mousemove', (e) => {
|
|
749
|
+
// no focused window, nothing to drag
|
|
750
|
+
let focus = select('.js_focus');
|
|
751
|
+
if (!focus)
|
|
752
|
+
return null;
|
|
753
|
+
let drag = attrib(`#${focus.id}`, 'aria-grabbed');
|
|
754
|
+
// ajust window option according to cursor position
|
|
755
|
+
if (drag == 'true') {
|
|
756
|
+
// keep the grab offset to avoid the window jumping under the cursor
|
|
757
|
+
if (!WINDOW.dataset.dragOffsetX || !WINDOW.dataset.dragOffsetY) {
|
|
758
|
+
WINDOW.dataset.dragOffsetX = String(e.clientX - WINDOW.offsetLeft);
|
|
759
|
+
WINDOW.dataset.dragOffsetY = String(e.clientY - WINDOW.offsetTop);
|
|
760
|
+
}
|
|
761
|
+
WINDOW.style.left = `${e.clientX - Number(WINDOW.dataset.dragOffsetX)}px`;
|
|
762
|
+
WINDOW.style.top = `${e.clientY - Number(WINDOW.dataset.dragOffsetY)}px`;
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
// #12.1 closing action (cross button click)
|
|
766
|
+
WIN_Close.onclick = () => {
|
|
767
|
+
drop('.js_focus');
|
|
768
|
+
try {
|
|
769
|
+
// remove window overlay if enabled
|
|
770
|
+
drop('#window_overlay');
|
|
771
|
+
}
|
|
772
|
+
catch (error) {
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
// #12.2 focus/`switch focus` action priority(hover/click on window)
|
|
777
|
+
WINDOW.addEventListener('mouseover', () => {
|
|
778
|
+
WINDOW.classList.add('js_focus');
|
|
779
|
+
if (!window.index) {
|
|
780
|
+
WINDOW.onclick = () => {
|
|
781
|
+
let lostFocus = select('.z-8');
|
|
782
|
+
if (lostFocus) {
|
|
783
|
+
lostFocus.classList.add('z-7');
|
|
784
|
+
lostFocus.classList.remove('z-8');
|
|
785
|
+
}
|
|
786
|
+
WINDOW.classList.add('z-8');
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
// #12.3 lost focus priority
|
|
791
|
+
WINDOW.addEventListener('mouseleave', () => {
|
|
792
|
+
WINDOW.classList.remove('js_focus');
|
|
793
|
+
});
|
|
794
|
+
// #12.4 timeout
|
|
795
|
+
if (window.timeout != 0 && window.timeout != null) {
|
|
796
|
+
let timeout = window.timeout;
|
|
797
|
+
setTimeout(() => {
|
|
798
|
+
// fade the window out, then remove it once the animation ends
|
|
799
|
+
WINDOW.classList.add('animate-fadeOut');
|
|
800
|
+
setTimeout(() => {
|
|
801
|
+
WINDOW.remove();
|
|
802
|
+
}, timeout);
|
|
803
|
+
}, timeout);
|
|
804
|
+
}
|
|
805
|
+
// #13. final views
|
|
806
|
+
// # header sections
|
|
807
|
+
// - favicon & title block
|
|
808
|
+
let div_1 = create('div');
|
|
809
|
+
div_1.classList.add('flex', 'items-center');
|
|
810
|
+
if (window.favicon) {
|
|
811
|
+
div_1.appendChild(FAVICON);
|
|
812
|
+
}
|
|
813
|
+
div_1.appendChild(TITLE);
|
|
814
|
+
// - window actions block
|
|
815
|
+
let div_2 = create('div');
|
|
816
|
+
div_2.classList.add('flex', 'items-center', 'gap-1');
|
|
817
|
+
div_2.appendChild(WIN_Move);
|
|
818
|
+
div_2.appendChild(WIN_Close);
|
|
819
|
+
HEADER.appendChild(div_1);
|
|
820
|
+
HEADER.appendChild(div_2);
|
|
821
|
+
// #14. Ready header view's
|
|
822
|
+
if (window.titlebar != false) {
|
|
823
|
+
WINDOW.appendChild(HEADER);
|
|
824
|
+
}
|
|
825
|
+
// #15. Ready content view's
|
|
826
|
+
WINDOW.appendChild(CONTENT);
|
|
827
|
+
// *** overlay options view ***
|
|
828
|
+
if (window.overlay == true) {
|
|
829
|
+
let overlay = create('div');
|
|
830
|
+
overlay.id = 'window_overlay';
|
|
831
|
+
overlay.classList.add('absolute', 'fullscreen', 'top-0', 'left-0', 'backdrop-blur-10', 'ease-in', 'animate-fadeIn', 'animated-500');
|
|
832
|
+
if (window.index) {
|
|
833
|
+
let i = window.index;
|
|
834
|
+
overlay.classList.add(`z-${i - 1}`);
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
overlay.classList.add('z-8');
|
|
838
|
+
}
|
|
839
|
+
document.body.appendChild(overlay);
|
|
840
|
+
document.body.appendChild(WINDOW);
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
document.body.appendChild(WINDOW);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
/**
|
|
847
|
+
* Cookies manage
|
|
848
|
+
*/
|
|
849
|
+
let set_cookie = (cookieName, cookieValue, cookieExpiry) => {
|
|
850
|
+
try {
|
|
851
|
+
if (isset(cookieExpiry)) {
|
|
852
|
+
document.cookie = `${cookieName}=${cookieValue}; expires=${cookieExpiry};`;
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
document.cookie = `${cookieName}=${cookieValue}`;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
catch (Cookie_ERR) {
|
|
859
|
+
console.error(Cookie_ERR);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
let unset_cookie = (cookieName, cookieExpiry) => {
|
|
863
|
+
try {
|
|
864
|
+
if (isset(cookieExpiry)) {
|
|
865
|
+
document.cookie = `${cookieName}=; expires=${cookieExpiry};`;
|
|
866
|
+
}
|
|
867
|
+
else {
|
|
868
|
+
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
catch (Cookie_ERR) {
|
|
872
|
+
console.error(Cookie_ERR);
|
|
873
|
+
}
|
|
874
|
+
};
|