archcss 2.0.0 → 3.0.0

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.
Files changed (38) hide show
  1. package/changelog +92 -3
  2. package/css/{arch.dev.css → arch.css} +229748 -155773
  3. package/css/{architect.css → attribution.css} +1 -4
  4. package/index.js +1 -1
  5. package/js/plugin.js +874 -0
  6. package/package.json +3 -1
  7. package/readme.md +144 -21
  8. package/{css/@fontawesome/css/fontawesome.css → webfonts/fontawesome/css/fontawessome.css} +5221 -2686
  9. package/webfonts/fontawesome/css/fontawessome.min.css +8104 -0
  10. package/webfonts/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  11. package/webfonts/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  12. package/webfonts/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  13. package/webfonts/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  14. package/webfonts/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  15. package/webfonts/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  16. package/webfonts/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
  17. package/webfonts/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
  18. package/{css/@googleapis → webfonts/googleapis}/fonts.css +1 -1
  19. package/webfonts/googleapis/fonts.min.css +71 -0
  20. package/webfonts/lucide/css/lucide.css +72 -0
  21. package/webfonts/lucide/css/lucide.min.css +1 -0
  22. package/webfonts/lucide/js/lucide.min.js +12 -0
  23. package/css/@fontawesome/LICENSE.txt +0 -165
  24. package/css/@fontawesome/css/fontawesome.min.css +0 -9
  25. package/css/@fontawesome/js/all.js +0 -6026
  26. package/css/@fontawesome/js/all.min.js +0 -6
  27. package/css/@fontawesome/webfonts/fa-brands-400.ttf +0 -0
  28. package/css/@fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  29. package/css/@fontawesome/webfonts/fa-regular-400.ttf +0 -0
  30. package/css/@fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  31. package/css/@fontawesome/webfonts/fa-solid-900.ttf +0 -0
  32. package/css/@fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  33. package/css/@fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
  34. package/css/@fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
  35. package/css/@googleapis/fonts.min.css +0 -1
  36. package/css/arch.min.css +0 -6
  37. package/js/dom.js +0 -1106
  38. /package/{licence → license} +0 -0
package/js/dom.js DELETED
@@ -1,1106 +0,0 @@
1
- "use strict";
2
- /**
3
- * @package : ArchCSS - Modern CSS framework for responsive and attractive websites and applications.
4
- * @version : 2.0.0
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
- /** GLOBALS */
41
- /**
42
- * get: getter
43
- * @param key
44
- * @returns
45
- */
46
- let get = (key) => {
47
- switch (key) {
48
- // DOM Objects
49
- case 'title':
50
- return document.title;
51
- case 'charset':
52
- return document.characterSet;
53
- case 'baseURI':
54
- return document.baseURI;
55
- case 'links':
56
- return document.links;
57
- case 'scripts':
58
- return document.scripts;
59
- case 'embeds':
60
- return document.embeds;
61
- case 'images':
62
- return document.images;
63
- case 'readyState':
64
- return document.readyState;
65
- // BOM Objects
66
- case 'cookies':
67
- return navigator.cookieEnabled;
68
- case 'language':
69
- return navigator.language;
70
- case 'online':
71
- return navigator.onLine;
72
- case 'userAgent':
73
- return navigator.userAgent;
74
- // Server & location
75
- case 'host':
76
- return location.host;
77
- case 'hostname':
78
- return location.hostname;
79
- case 'href':
80
- return location.href;
81
- case 'url':
82
- return location.href;
83
- case 'pathname':
84
- return location.pathname;
85
- case 'port':
86
- return location.port;
87
- case 'protocol':
88
- return location.protocol;
89
- case 'search':
90
- return location.search;
91
- case 'update':
92
- return document.lastModified;
93
- // Return https(SSl) state of current page
94
- case 'https':
95
- if (location.protocol = 'https') {
96
- return true;
97
- }
98
- else {
99
- return false;
100
- }
101
- // Owner
102
- case 'author-org':
103
- return 'archcss-dev';
104
- case 'author-name':
105
- return 'Beba Godfried';
106
- case 'author-right':
107
- return 'Beba Godfried';
108
- case 'author-email':
109
- return 'me@bebagodfried.com';
110
- case 'author-site':
111
- return 'https://bebagodfried.com';
112
- case 'copyright':
113
- return 'Write with love by @bebagodfried';
114
- case 'owner':
115
- return 'archcss-dev - @bebagodfried';
116
- case 'version':
117
- return '2.0.0';
118
- default:
119
- console.info(`[404]: Reference '${key}' not found!`);
120
- return null;
121
- }
122
- };
123
- /**
124
- * set: setter
125
- * @param key string
126
- * @param value string|number
127
- * @returns void
128
- */
129
- let set = (key, value = '') => {
130
- switch (key) {
131
- // DOM Objects
132
- case 'title':
133
- if (value) {
134
- document.title = `${value}`;
135
- }
136
- break;
137
- // Server & location
138
- case 'host':
139
- if (value) {
140
- location.host = `${value}`;
141
- }
142
- break;
143
- case 'hostname':
144
- if (value) {
145
- location.hostname = `${value}`;
146
- }
147
- break;
148
- case 'href':
149
- if (value) {
150
- location.href = `${value}`;
151
- }
152
- break;
153
- case 'url':
154
- if (value) {
155
- location.href = `${value}`;
156
- }
157
- break;
158
- case 'pathname':
159
- if (value) {
160
- location.pathname = `${value}`;
161
- }
162
- break;
163
- case 'port':
164
- if (value) {
165
- location.port = `${value}`;
166
- }
167
- break;
168
- case 'protocol':
169
- if (value) {
170
- location.protocol = `${value}`;
171
- }
172
- break;
173
- case 'search':
174
- if (value) {
175
- location.search = `${value}`;
176
- }
177
- break;
178
- default:
179
- console.info(`[404]: Reference '${key}' not found!`);
180
- return null;
181
- }
182
- };
183
- /** end:GLOBALS **/
184
- /**
185
- * date: date object
186
- * @param format string
187
- * @param type string
188
- * @returns date
189
- */
190
- let date = (format = '', type = '') => {
191
- // New date object
192
- var date = new Date();
193
- // return Alwayse two digits
194
- const digit = function (i) {
195
- if (i < 10)
196
- i = '0' + i;
197
- return i;
198
- };
199
- // H: Hours
200
- const H = date.getHours();
201
- // i: Minutes
202
- const i = digit(date.getMinutes());
203
- // s: Seconds
204
- const s = digit(date.getSeconds());
205
- // ms: Seconds
206
- const ms = date.getMilliseconds();
207
- // t: Timezone
208
- const t = date.getTimezoneOffset();
209
- // Y: Year
210
- const Y = date.getFullYear();
211
- // m: Month
212
- const m = date.getMonth();
213
- // d: Day
214
- const d = date.getDate();
215
- // f: Weekday
216
- const f = date.getDay();
217
- switch (format) {
218
- case 'H': //=> Hours
219
- if (isset(type)) {
220
- if (type == 'En') {
221
- // return 12 hours format
222
- if (H >> 12) {
223
- return (H - 12);
224
- }
225
- else {
226
- return H;
227
- }
228
- }
229
- else if (type == 'Fr') {
230
- // return 24 hours format
231
- return H;
232
- }
233
- }
234
- else {
235
- return H;
236
- }
237
- case 'i': return i; //=> Minutes
238
- case 's': return s; //=> Seconds
239
- case 'ms': return s; //=> Seconds
240
- case 't': return t; //=> Timezone
241
- case 'Y': return Y; //=> Year
242
- case 'm': //=> Month
243
- if (isset(type)) {
244
- if (type == 'En') {
245
- // return the month in english
246
- return months_en[m];
247
- }
248
- else if (type == 'Fr') {
249
- // return the month in french
250
- return months_fr[m];
251
- }
252
- }
253
- else {
254
- // return the month as number
255
- return m;
256
- }
257
- case 'd': return (d); //=> Day
258
- case 'f': return f; //=> Weekday
259
- case 'En': return weekdays_en[f] + ', ' + months_en[m] + ' ' + digit(d) + ', ' + Y;
260
- case 'Fr': return weekdays_fr[f] + ' ' + digit(d) + ' ' + months_fr[m] + ' ' + Y;
261
- case 'DD/MM/YY': return digit(d) + '/' + digit(m) + '/' + Y;
262
- case 'MM/DD/YY': return digit(m) + '/' + digit(d) + '/' + Y;
263
- case 'DD-MM-YY': return digit(d) + '-' + digit(m) + '-' + Y;
264
- case 'MM-DD-YY': return digit(m) + '-' + digit(d) + '-' + Y;
265
- case 'DD/MM': return digit(d) + '/' + digit(m);
266
- case 'MM/DD': return digit(m) + '/' + digit(d);
267
- case 'DD-MM': return digit(d) + '-' + digit(m);
268
- case 'MM-DD': return digit(m) + '-' + digit(d);
269
- // hours:minutes
270
- case 'H:i':
271
- if (isset(type)) {
272
- if (type == 'En') {
273
- // return time in 12 hours format
274
- if (H >> 12) {
275
- return (H - 12) + ':' + i;
276
- }
277
- else {
278
- return H + ':' + i;
279
- }
280
- }
281
- else if (type == 'Fr') {
282
- // return time in 24 hours format
283
- return H + ':' + i;
284
- }
285
- }
286
- else {
287
- // return time hours:minutes
288
- return H + ':' + i;
289
- }
290
- // hours:minutes:seconds
291
- case 'H:i:s':
292
- if (isset(type)) {
293
- if (type == 'En') {
294
- // return time in 12 hours format with seconds
295
- if (H >> 12) {
296
- return (H - 12) + ':' + i + ':' + s;
297
- }
298
- else {
299
- return H + ':' + i + ':' + s;
300
- }
301
- }
302
- else if (type == 'Fr') {
303
- // return time in 24 hours format with seconds
304
- return H + ':' + i + ':' + s;
305
- }
306
- }
307
- else {
308
- // return time in hours:minutes:seconds
309
- return H + ':' + i + ':' + s;
310
- }
311
- default: return date.toLocaleString();
312
- }
313
- };
314
- // Days
315
- let weekdays_en = ['Sunday', 'Monday', 'Thuesday', 'Wednesday', 'Tursday', 'Friday', 'Saturday'];
316
- let weekdays_fr = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
317
- // Months
318
- let months_en = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
319
- let months_fr = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'];
320
- /** end:date */
321
- /**
322
- * DOM: Document Objects Manipulation
323
- * @param el string
324
- * @param all string
325
- * @returns Object
326
- */
327
- let dom = (el, all = true) => {
328
- try {
329
- // Remove white space around the element
330
- if (typeof (el) == 'string' && el != null)
331
- el = el.trim();
332
- // By default `all = true` indicate that all `el` are selected
333
- // all = true
334
- // all = false
335
- if (all) {
336
- return [...document.querySelectorAll(el)];
337
- }
338
- else {
339
- return document.querySelector(el);
340
- }
341
- }
342
- catch (DOM_ERR) {
343
- // DOM() debug
344
- // console.error(DOM_ERR)
345
- console.error('DOM(el: string)' + `: => '${el}' is not a valid selector.`);
346
- return null;
347
- }
348
- };
349
- /**
350
- * strcopy: send string to clipboard
351
- * @param text string
352
- */
353
- let strcopy = (text) => __awaiter(void 0, void 0, void 0, function* () {
354
- try {
355
- yield navigator.clipboard.writeText(text);
356
- }
357
- catch (err) {
358
- console.error('Failed to copy text: ', err);
359
- }
360
- });
361
- /**
362
- * goto: url redirection
363
- * @param _location Location
364
- */
365
- let goto = (_location) => {
366
- try {
367
- location.href = _location.toString();
368
- }
369
- catch (err) {
370
- console.error('Failed redirect: ', err);
371
- }
372
- };
373
- /**
374
- * get_attribute: Get an attrribute value of element
375
- * @param el string
376
- * @param attrib string
377
- * @returns any
378
- */
379
- let get_attribute = (el, attrib) => {
380
- // Element selection
381
- let dom = select(el);
382
- // Return the attrribute value of the element
383
- try {
384
- return dom.getAttribute(`${attrib}`);
385
- }
386
- catch (ATTR_ERR) {
387
- // Debug get_attrib()
388
- console.error(`${ATTR_ERR.name}: get_attrib(el: string, attrib: any) => '${el}' has no a ${attrib} attribute.`);
389
- return null;
390
- }
391
- };
392
- /**
393
- * set_attribute: Set an attrribute value of element
394
- * @param el string
395
- * @param attrib string
396
- * @param value any
397
- */
398
- let set_attribute = (el, attrib, value) => {
399
- // Element selection
400
- let dom = select(el);
401
- // Apply the attrribute value to element
402
- if (value) {
403
- dom.setAttribute(`${attrib}`, `${value}`);
404
- }
405
- else {
406
- console.warn('set_attrib(el: string, attrib: any, value?: any)' + `: => '${el}.atribute(${attrib}) will be empty.`);
407
- dom.setAttribute(`${attrib}`, '');
408
- }
409
- };
410
- /** classList */
411
- /**
412
- * get_classlist: return all defined class of an element
413
- * @param el string
414
- * @returns string[]
415
- */
416
- let get_classlist = (el) => {
417
- let dom = select(el);
418
- return dom.classList.value.split();
419
- };
420
- /**
421
- * set_classlist: add/remove element classes
422
- * If token is true, adds token (same as [...].classList.add()).
423
- * If force is false, removes token (same as [...].classList.remove()).
424
- *
425
- * @param el string
426
- * @param tokens string[]
427
- */
428
- let set_classlist = (el, tokens) => {
429
- let dom = select(el);
430
- // check for each token force
431
- tokens.forEach(key => {
432
- dom.classList.toggle(key);
433
- });
434
- };
435
- /** end: classList */
436
- /** Node */
437
- /**
438
- * create: Create node elements
439
- * @param el string
440
- * @returns ElementCreationOptions
441
- */
442
- let create = (el) => {
443
- return document.createElement(el);
444
- };
445
- /**
446
- * select: Node list selector
447
- * @param el string
448
- * @param all boolean
449
- * @returns NodeList
450
- */
451
- let select = (el, all = false) => {
452
- try {
453
- // Remove white space around the element
454
- if (typeof (el) == 'string' && el != null)
455
- el = el.trim();
456
- // By default `all = false` indicate that select the first `el`
457
- // all = true
458
- // all = false
459
- if (all) {
460
- return [...document.querySelectorAll(el)];
461
- }
462
- else {
463
- return document.querySelector(el);
464
- }
465
- }
466
- catch (select_ERR) {
467
- // Debug get_attrib()
468
- console.error(`${select_ERR.name}: select(elememt: string, all?: boolean) => '${el}' is not a valid selector.`);
469
- return null;
470
- }
471
- };
472
- /**
473
- * select_tag: HTMLCollection selector
474
- * @param el string
475
- * @returns HTMLCollection
476
- */
477
- let select_tag = (el) => {
478
- try {
479
- // Remove white space around the element
480
- if (typeof (el) == 'string' && el != null)
481
- el = el.trim();
482
- return document.getElementsByTagName(el);
483
- }
484
- catch (select_ERR) {
485
- // Debug select()
486
- console.error(`${select_ERR.name}: selectTag(tag: string) => '${el}' is not a valid selector.`);
487
- return null;
488
- }
489
- };
490
- /**
491
- * select_id: Element `Id` selector
492
- * @param el string
493
- * @returns HTMLElement
494
- */
495
- let select_id = (el) => {
496
- try {
497
- // Remove white space around the element
498
- if (typeof (el) == 'string' && el != null)
499
- el = el.trim();
500
- return document.getElementById(el);
501
- }
502
- catch (select_id_ERR) {
503
- // Debug select_id()
504
- console.error(`${select_id_ERR.name}: select_id(id: srting) => '${el}' is not a valid selector.`);
505
- return null;
506
- }
507
- };
508
- /**
509
- * drop_all: Remove element(s) list from DOM
510
- * @param list string[]
511
- */
512
- let drop_all = (list) => {
513
- list.forEach(el => {
514
- // Element selection from list
515
- const dom = select(el);
516
- try {
517
- dom.remove();
518
- }
519
- catch (Drop_ERR) {
520
- // Escape
521
- return null;
522
- }
523
- });
524
- };
525
- /**
526
- *
527
- * @param token string[]
528
- * @returns any
529
- */
530
- let drop = (token) => {
531
- // Element selection
532
- const dom = select(token);
533
- try {
534
- dom.remove();
535
- }
536
- catch (Drop_ERR) {
537
- // Escape
538
- return null;
539
- }
540
- };
541
- /**
542
- * echo: replace the content of element(s)
543
- * @param text string
544
- * @param el string
545
- * @param match_all boolean
546
- * @returns string
547
- */
548
- let echo = (text, el, match_all = false) => {
549
- if (isset(el)) {
550
- if (match_all) {
551
- // all = true
552
- // Genearate a list of all `el`
553
- let list = select(el, match_all);
554
- // for each element of the list add/replace content
555
- list.forEach((el) => {
556
- el.innerHTML = `${text}`;
557
- });
558
- // by default
559
- // add/replace the first `el` occurence
560
- }
561
- else {
562
- try {
563
- return document.querySelector(el).innerHTML = `${text}`;
564
- }
565
- catch (e) {
566
- return el.innerHTML = `${text}`;
567
- }
568
- }
569
- }
570
- else {
571
- console.log(`${text}`);
572
- }
573
- };
574
- /**
575
- * get_innerTEXT: Get element text content
576
- * @param el string
577
- * @returns string
578
- */
579
- let get_innerTEXT = (el) => {
580
- // Element selection
581
- let dom = select(el);
582
- return dom.innerTEXT;
583
- };
584
- /**
585
- * set_innerTEXT: Replace element text content
586
- * @param el string
587
- * @param text string
588
- */
589
- let set_innerTEXT = (el, text) => {
590
- try {
591
- document.querySelector(el).innerTEXT = `${text}`;
592
- }
593
- catch (error) {
594
- // Debug set_innerTEXT()
595
- console.error(error);
596
- }
597
- };
598
- /**
599
- * get_innerHTML: Get html content of element
600
- * @param el string
601
- * @returns string
602
- */
603
- let get_innerHTML = (el) => {
604
- // Get html content of an element
605
- return document.querySelector(el).innerHTML;
606
- };
607
- /**
608
- * set_innerHTML: Replace html content of element
609
- * @param el string
610
- * @param concent string
611
- */
612
- let set_innerHTML = (el, concent) => {
613
- try {
614
- document.querySelector(el).innerHTML = `${concent}`;
615
- }
616
- catch (error) {
617
- // Debug get_innerHTML()
618
- console.error(error);
619
- }
620
- };
621
- /** end:Node */
622
- /**
623
- * display: display/hide specific DOM element
624
- * @param el string
625
- * @param displayValue string
626
- * @returns string
627
- */
628
- function _display(el, displayValue) {
629
- // Element selection
630
- let dom = select(el);
631
- // if hidden by style attribute then display as `displayValue`
632
- if (dom.style.display == 'none') {
633
- dom.style.display == `${displayValue}`;
634
- // if displayed by style attribute then change the value to `none`
635
- }
636
- else if (dom.style.display == `${displayValue}`) {
637
- dom.style.display == 'none';
638
- }
639
- else {
640
- // if hidden by class attribute containing `hidden` token
641
- // then remove the `hidden` class and add the `displayValue` class
642
- if (dom.classList.contains('hidden')) {
643
- try {
644
- dom.classList.remove('hidden');
645
- dom.classList.add(`${displayValue}`);
646
- }
647
- catch (display_ERR) {
648
- // Debug display() #1
649
- console.error(display_ERR);
650
- }
651
- // if displayed by class attribute as containing `displayValue` token
652
- // then remove the `displayValue` class and add the `hidden` class
653
- }
654
- else if (dom.classList.contains(`${displayValue}`)) {
655
- try {
656
- dom.classList.remove(`${displayValue}`);
657
- dom.classList.add('hidden');
658
- }
659
- catch (display_ERR) {
660
- // Debug display() #2
661
- console.error(display_ERR);
662
- }
663
- }
664
- else {
665
- // if hidden by hidden attribute
666
- // then remove the `hidden` class and add the `displayValue` class
667
- // Get the attribute
668
- try {
669
- let hide = dom.getAttribute('hidden');
670
- if (isset(hide)) {
671
- if (hide == true) {
672
- hide = false;
673
- }
674
- else {
675
- hide = true;
676
- }
677
- }
678
- }
679
- catch (display_ERR) {
680
- // Debug display() #3
681
- console.error(display_ERR);
682
- }
683
- }
684
- }
685
- }
686
- let display = (el, display = 'block') => {
687
- if (typeof (el) == 'string') {
688
- _display(el, display);
689
- }
690
- else {
691
- el.forEach((e) => {
692
- _display(e, display);
693
- });
694
- }
695
- };
696
- /**
697
- * hide: make a hidden element
698
- * @param el string
699
- * @returns void
700
- */
701
- function _hide(el) {
702
- // Possible classlist values
703
- const list = ['block', 'inline', 'inline-block', 'flex', 'inline-flex'];
704
- // Element selection
705
- const dom = select(el);
706
- try {
707
- // for each display token from list
708
- // if `el` classList.contains a token display then change it to `hidden`
709
- list.forEach(display => {
710
- if (dom.classList.contains(`${display}`)) {
711
- dom.classList.remove(`${display}`);
712
- dom.classList.add('hidden');
713
- }
714
- });
715
- }
716
- catch (hide_ERR) {
717
- // hide `el` by attribute
718
- let hide = dom.getAttribute('hidden');
719
- try {
720
- if (!isset(hide)) {
721
- return hide = true;
722
- }
723
- }
724
- catch (display_ERR) {
725
- // Debug hide()
726
- console.error(display_ERR);
727
- }
728
- }
729
- }
730
- let hide = (el) => {
731
- if (typeof (el) == 'string') {
732
- _hide(el);
733
- }
734
- else {
735
- el.forEach((e) => {
736
- _hide(e);
737
- });
738
- }
739
- };
740
- /** EventListener */
741
- /**
742
- * on: envent listener
743
- * @param event string
744
- * @param listener Function
745
- */
746
- let on = (event, listener) => {
747
- event = event.trim();
748
- document.addEventListener(event, listener());
749
- };
750
- /**
751
- * at_scroll: based on scroll offset, this while add/remove some classname to an object
752
- * @param el string
753
- * @param add_list string[]
754
- * @param rm_list string[]
755
- * @param offset number
756
- */
757
- let at_scroll = (el, add_list, rm_list = [], offset = 0) => {
758
- var dom = select(el);
759
- // Add or remove class based on scroll position
760
- if (window.scrollY > offset) {
761
- add_list.forEach(key => {
762
- dom.classList.add(key);
763
- });
764
- rm_list.forEach(key => {
765
- dom.classList.remove(key);
766
- });
767
- }
768
- else {
769
- add_list.forEach(key => {
770
- dom.classList.remove(key);
771
- });
772
- rm_list.forEach(key => {
773
- dom.classList.add(key);
774
- });
775
- }
776
- };
777
- /**
778
- * scroll_to: scroll to element on page
779
- * @param el string
780
- */
781
- let scroll_to = (el) => {
782
- // JavaScript to scroll to the target element
783
- var dom = select_id(el);
784
- dom.scrollIntoView({ behavior: 'smooth', block: 'start' });
785
- };
786
- /** Validation */
787
- /**
788
- * isset: Return true for no-empty Object/var
789
- * @param key string
790
- * @returns boolean
791
- */
792
- let isset = (key) => {
793
- if (key != null && key != false && key != undefined) {
794
- return true;
795
- }
796
- else if (key != '' && key != ' ') {
797
- return true;
798
- }
799
- else {
800
- return false;
801
- }
802
- };
803
- /** Mixin */
804
- /**
805
- * pop: create advenced pop-up box style
806
- */
807
- class frame {
808
- constructor(title) {
809
- this.title = title;
810
- this.favicon = "";
811
- this.content = "";
812
- this.html = "";
813
- this.href = "";
814
- this.titlebar = true;
815
- this.rounded = true;
816
- this.shadow = true;
817
- this.classlist = [];
818
- this.style = "";
819
- this.border = true;
820
- this.overlay = false;
821
- this.height = 96;
822
- this.width = 250;
823
- this.top = 0;
824
- this.right = 0;
825
- this.bottom = 0;
826
- this.left = 0;
827
- this.index = 8;
828
- this.timeout = 0;
829
- this.title = title;
830
- }
831
- pop() {
832
- // Pop
833
- // #1. Create a new window with basic value
834
- const WINDOW = create('div');
835
- // setup
836
- WINDOW.id = this.title;
837
- WINDOW.classList.add('rounded', 'select-none');
838
- WINDOW.style.position = 'fixed';
839
- // size
840
- WINDOW.style.height = this.height;
841
- WINDOW.style.width = this.width;
842
- // #2. Check window's already exist
843
- if (select_id(`${WINDOW.id}`)) {
844
- let el = select_id(WINDOW.id);
845
- el === null || el === void 0 ? void 0 : el.classList.add('animate-pulse');
846
- setTimeout(() => {
847
- el === null || el === void 0 ? void 0 : el.classList.remove('animate-pulse');
848
- }, 1000);
849
- return null;
850
- }
851
- // #3. classlist: Add more features/tweaks
852
- if (isset(this.classlist)) {
853
- this.classlist.forEach(classItem => {
854
- WINDOW.classList.add(classItem);
855
- });
856
- }
857
- // #4. index/z-index: add a window priority (default: 8)
858
- if (isset(this.index)) {
859
- WINDOW.classList.add(`${'z-' + this.index}`);
860
- }
861
- else {
862
- WINDOW.classList.add('z-8');
863
- }
864
- // #5. style: choose apearence between dark/light (default: light)
865
- if (`${this.style}` == 'dark') {
866
- WINDOW.classList.add('bg-dark-900', 'fg-light');
867
- }
868
- else if (`${this.style}` == 'light') {
869
- WINDOW.classList.add('bg-light', 'fg-dark-900');
870
- }
871
- else if (`${this.style}` == 'none') {
872
- WINDOW.style.color = 'inherit';
873
- }
874
- else {
875
- WINDOW.classList.add('bg-light', 'fg-dark-900');
876
- }
877
- // #6. border: enable window border (default: true)
878
- if (isset(this.border == true)) {
879
- WINDOW.classList.add('border');
880
- }
881
- else if (isset(this.border == false)) {
882
- // do nothing ...
883
- }
884
- else {
885
- WINDOW.classList.add('border');
886
- }
887
- // #7. rounded: enable window rounded border (default: true)
888
- if (isset(this.rounded == true)) {
889
- WINDOW.classList.add('rounded');
890
- }
891
- else if (isset(this.rounded == false)) {
892
- // do nothing ...
893
- }
894
- else {
895
- WINDOW.classList.add('rounded');
896
- }
897
- // #8. shadow: enable window shadow (default: true)
898
- if (isset(this.shadow == true)) {
899
- WINDOW.classList.add('shadow-1');
900
- }
901
- else if (isset(this.shadow == false)) {
902
- // do nothing ...
903
- }
904
- else {
905
- WINDOW.classList.add('shadow-1');
906
- }
907
- // #9. [top, right, bottom, left]: value window position
908
- if (isset(this.top) || isset(this.right) || isset(this.bottom) || isset(this.left)) {
909
- WINDOW.style.top = this.top;
910
- WINDOW.style.right = this.right;
911
- WINDOW.style.bottom = this.bottom;
912
- WINDOW.style.left = this.left;
913
- }
914
- else {
915
- WINDOW.style.top = '50%';
916
- WINDOW.style.left = '50%';
917
- WINDOW.classList.add('translate-center');
918
- }
919
- // #10. header/title bar
920
- // #10.1 Create a title bar
921
- const HEADER = create('div');
922
- HEADER.classList.add('flex', 'items-center', 'justify-between', 'full-width');
923
- HEADER.style.padding = '.2rem';
924
- // #10.2 favicon: add an icon as window illustrator
925
- const FAVICON = create('img');
926
- if (isset(this.favicon)) {
927
- FAVICON.src = this.favicon;
928
- FAVICON.classList.add('size-32');
929
- }
930
- // #10.3 Window action bar
931
- // * title: value the window title/id
932
- const TITLE = create('span');
933
- TITLE.classList.add('pl-1', 'line-clamp-1', 'sm:line-clamp-1');
934
- TITLE.innerHTML = this.title;
935
- // * add moving icon
936
- const WIN_Move = create('button');
937
- WIN_Move.classList.add('bg-none', 'cursor-default', 'fa-solid', 'fa-up-down-left-right', 'p-0', 'rounded-full', 'size-32', 'muted');
938
- // * add closing button
939
- const WIN_Close = create('button');
940
- WIN_Close.classList.add('bg-none', 'fa-solid', 'fa-times', 'hover:bg-danger', 'p-0', 'rounded-full', 'size-32');
941
- // #11. views: create adaptable content
942
- var view = '';
943
- if (isset(this.content)) {
944
- view = 'p';
945
- }
946
- else if (isset(this.html)) {
947
- view = 'div';
948
- }
949
- else if (isset(this.href)) {
950
- view = 'iframe';
951
- }
952
- // - create main window view
953
- const CONTENT = create(view);
954
- if (isset(this.content)) {
955
- CONTENT.classList.add('m-0', 'px-2', 'py-1', 'w-full');
956
- CONTENT.innerHTML = this.content;
957
- if (isset(this.titlebar == true)) {
958
- CONTENT.classList.add('border', 'border-0', 'border-t-1');
959
- }
960
- }
961
- else if (isset(this.html)) {
962
- CONTENT.classList.add('max-height', 'border-0', 'border-t-1', 'border-white', 'px-2', 'py-1', 'w-full');
963
- CONTENT.innerHTML = this.html;
964
- }
965
- else if (isset(this.href)) {
966
- CONTENT.classList.add('no-border');
967
- CONTENT.height = '100%';
968
- CONTENT.width = '100%';
969
- CONTENT.src = this.href;
970
- if (isset(this.titlebar == true)) {
971
- CONTENT.classList.add('border-0', 'border-t-1', 'border-white');
972
- }
973
- }
974
- // #12. Actions
975
- // #12.1 draging action (double-click)
976
- WINDOW.ondblclick = () => {
977
- let move = get_attribute('.js_focus', 'aria-grabbed');
978
- WINDOW.classList.toggle('cursor-grabbing');
979
- if (move == 'true') {
980
- WINDOW.setAttribute('aria-grabbed', 'false');
981
- WIN_Move.classList.add('muted');
982
- }
983
- else {
984
- WINDOW.setAttribute('aria-grabbed', 'true');
985
- WIN_Move.classList.remove('muted');
986
- }
987
- };
988
- WINDOW.addEventListener('mousemove', (e) => {
989
- let focus = select('.js_focus');
990
- let drag = get_attribute(`#${focus.id}`, 'aria-grabbed');
991
- // ajust window option according to cursor position
992
- if (focus && drag == 'true') {
993
- let x = e.clientX;
994
- let y = e.clientY;
995
- WINDOW.style.left = `${x}px`;
996
- WINDOW.style.top = `${y}px`;
997
- }
998
- });
999
- // #12.1 closing action (cross button click)
1000
- WIN_Close.onclick = () => {
1001
- drop('.js_focus');
1002
- try {
1003
- // remove window overlay if enabled
1004
- drop('#window_overlay');
1005
- }
1006
- catch (error) {
1007
- return null;
1008
- }
1009
- };
1010
- // #12.2 focus/`switch focus` action priority(hover/click on window)
1011
- WINDOW.addEventListener('mouseover', () => {
1012
- WINDOW.classList.add('js_focus');
1013
- if (!this.index) {
1014
- WINDOW.onclick = () => {
1015
- let lostFocus = select('.z-8');
1016
- if (lostFocus) {
1017
- lostFocus.classList.add('z-7');
1018
- lostFocus.classList.remove('z-8');
1019
- }
1020
- WINDOW.classList.add('z-8');
1021
- };
1022
- }
1023
- });
1024
- // #12.3 lost focus priority
1025
- WINDOW.addEventListener('mouseleave', () => {
1026
- WINDOW.classList.remove('js_focus');
1027
- });
1028
- // #12.4 timeout
1029
- if (isset(this.timeout != 0 && this.timeout != null)) {
1030
- let timeout = this.timeout;
1031
- setTimeout(() => {
1032
- WINDOW.classList.add('animate-fadeOut');
1033
- }, timeout);
1034
- WINDOW.remove();
1035
- }
1036
- // #13. final views
1037
- // # header sections
1038
- // - favicon & title block
1039
- let div_1 = create('div');
1040
- div_1.classList.add('flex', 'items-center');
1041
- if (isset(this.favicon)) {
1042
- div_1.appendChild(FAVICON);
1043
- }
1044
- div_1.appendChild(TITLE);
1045
- // - window actions block
1046
- let div_2 = create('div');
1047
- div_2.classList.add('flex', 'items-center', 'g-1');
1048
- div_2.appendChild(WIN_Move);
1049
- div_2.appendChild(WIN_Close);
1050
- HEADER.appendChild(div_1);
1051
- HEADER.appendChild(div_2);
1052
- // #14. Ready header view's
1053
- if (isset(this.titlebar != false)) {
1054
- WINDOW.appendChild(HEADER);
1055
- }
1056
- // #15. Ready content view's
1057
- WINDOW.appendChild(CONTENT);
1058
- // *** overlay options view ***
1059
- if (isset(this.overlay == true)) {
1060
- let overlay = create('div');
1061
- overlay.id = 'window_overlay';
1062
- overlay.classList.add('absolute', 'fullscreen', 'top-0', 'left-0', 'backdrop-blur-10', 'ease-in', 'animate-fadeIn', 'animated-500');
1063
- if (isset(this.index)) {
1064
- let i = this.index;
1065
- overlay.classList.add(`z-${i - 1}`);
1066
- }
1067
- else {
1068
- overlay.classList.add('z-8');
1069
- }
1070
- document.body.appendChild(overlay);
1071
- document.body.appendChild(WINDOW);
1072
- }
1073
- else {
1074
- document.body.appendChild(WINDOW);
1075
- }
1076
- }
1077
- }
1078
- /**
1079
- * Cookies manage
1080
- */
1081
- let set_cookie = (cookieName, cookieValue, cookieExpiry) => {
1082
- try {
1083
- if (isset(cookieExpiry)) {
1084
- document.cookie = `${cookieName = cookieValue}; expires=${cookieExpiry};`;
1085
- }
1086
- else {
1087
- document.cookie = `${cookieName = cookieValue}`;
1088
- }
1089
- }
1090
- catch (Cookie_ERR) {
1091
- console.error(Cookie_ERR);
1092
- }
1093
- };
1094
- let unset_cookie = (cookieName, cookieExpiry) => {
1095
- try {
1096
- if (isset(cookieExpiry)) {
1097
- document.cookie = `username=${cookieName}; expires=${cookieExpiry};`;
1098
- }
1099
- else {
1100
- document.cookie = `username=${cookieName}; expires=Thu, 01 Jan 1970 00:00:00 UTC`;
1101
- }
1102
- }
1103
- catch (Cookie_ERR) {
1104
- console.error(Cookie_ERR);
1105
- }
1106
- };