archcss 1.0.0 → 2.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.
- package/changelog +76 -0
- package/css/@fontawesome/css/{fontawessome.css → fontawesome.css} +37 -4
- package/css/@fontawesome/css/{fontawessome.min.css → fontawesome.min.css} +3 -3
- package/css/@fontawesome/js/all.js +275 -231
- package/css/@fontawesome/js/all.min.js +2 -2
- 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 +1 -1
- package/css/arch.dev.css +32231 -4541
- package/css/arch.min.css +2 -2
- package/css/{arch.css → architect.css} +3 -3
- package/index.js +2 -2
- package/js/dom.js +527 -398
- package/package.json +7 -18
- package/readme.md +50 -6
- /package/css/@fontawesome/{license → LICENSE.txt} +0 -0
package/js/dom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @package : ArchCSS - Modern CSS framework for responsive and attractive websites and applications.
|
|
4
|
-
* @version :
|
|
4
|
+
* @version : 2.0.0
|
|
5
5
|
* @author : @bebagodfried - [archCSS dev.](https://archcss.com/team/@bebagodfried)
|
|
6
6
|
* @license : MIT license
|
|
7
7
|
*/
|
|
@@ -37,21 +37,17 @@ let HttpRequest = () => {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
+
/** GLOBALS */
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
* get: getter
|
|
43
|
+
* @param key
|
|
44
|
+
* @returns
|
|
43
45
|
*/
|
|
44
|
-
let
|
|
45
|
-
switch (
|
|
46
|
+
let get = (key) => {
|
|
47
|
+
switch (key) {
|
|
46
48
|
// DOM Objects
|
|
47
49
|
case 'title':
|
|
48
|
-
|
|
49
|
-
document.title = `${set}`;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return document.title;
|
|
54
|
-
}
|
|
50
|
+
return document.title;
|
|
55
51
|
case 'charset':
|
|
56
52
|
return document.characterSet;
|
|
57
53
|
case 'baseURI':
|
|
@@ -77,79 +73,21 @@ let $_ = (get, set = '') => {
|
|
|
77
73
|
return navigator.userAgent;
|
|
78
74
|
// Server & location
|
|
79
75
|
case 'host':
|
|
80
|
-
|
|
81
|
-
location.host = `${set}`;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return location.host;
|
|
86
|
-
}
|
|
76
|
+
return location.host;
|
|
87
77
|
case 'hostname':
|
|
88
|
-
|
|
89
|
-
location.hostname = `${set}`;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return location.hostname;
|
|
94
|
-
}
|
|
78
|
+
return location.hostname;
|
|
95
79
|
case 'href':
|
|
96
|
-
|
|
97
|
-
location.href = `${set}`;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return location.href;
|
|
102
|
-
}
|
|
80
|
+
return location.href;
|
|
103
81
|
case 'url':
|
|
104
|
-
|
|
105
|
-
location.href = `${set}`;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
return location.href;
|
|
110
|
-
}
|
|
82
|
+
return location.href;
|
|
111
83
|
case 'pathname':
|
|
112
|
-
|
|
113
|
-
location.pathname = `${set}`;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return location.pathname;
|
|
118
|
-
}
|
|
84
|
+
return location.pathname;
|
|
119
85
|
case 'port':
|
|
120
|
-
|
|
121
|
-
location.port = `${set}`;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
return location.port;
|
|
126
|
-
}
|
|
86
|
+
return location.port;
|
|
127
87
|
case 'protocol':
|
|
128
|
-
|
|
129
|
-
location.protocol = `${set}`;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return location.protocol;
|
|
134
|
-
}
|
|
88
|
+
return location.protocol;
|
|
135
89
|
case 'search':
|
|
136
|
-
|
|
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
|
-
}
|
|
90
|
+
return location.search;
|
|
153
91
|
case 'update':
|
|
154
92
|
return document.lastModified;
|
|
155
93
|
// Return https(SSl) state of current page
|
|
@@ -166,24 +104,89 @@ let $_ = (get, set = '') => {
|
|
|
166
104
|
case 'author-name':
|
|
167
105
|
return 'Beba Godfried';
|
|
168
106
|
case 'author-right':
|
|
169
|
-
return 'Godfried
|
|
107
|
+
return 'Beba Godfried';
|
|
170
108
|
case 'author-email':
|
|
171
109
|
return 'me@bebagodfried.com';
|
|
172
110
|
case 'author-site':
|
|
173
111
|
return 'https://bebagodfried.com';
|
|
174
112
|
case 'copyright':
|
|
175
|
-
return '
|
|
113
|
+
return 'Write with love by @bebagodfried';
|
|
176
114
|
case 'owner':
|
|
177
|
-
return 'archcss-dev -
|
|
115
|
+
return 'archcss-dev - @bebagodfried';
|
|
178
116
|
case 'version':
|
|
179
117
|
return '2.0.0';
|
|
180
118
|
default:
|
|
181
|
-
console.info(`[404]: Reference '${
|
|
119
|
+
console.info(`[404]: Reference '${key}' not found!`);
|
|
182
120
|
return null;
|
|
183
121
|
}
|
|
184
122
|
};
|
|
185
|
-
/**
|
|
186
|
-
|
|
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
|
+
*/
|
|
187
190
|
let date = (format = '', type = '') => {
|
|
188
191
|
// New date object
|
|
189
192
|
var date = new Date();
|
|
@@ -314,8 +317,14 @@ let weekdays_fr = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi'
|
|
|
314
317
|
// Months
|
|
315
318
|
let months_en = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
316
319
|
let months_fr = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'];
|
|
317
|
-
|
|
318
|
-
|
|
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) => {
|
|
319
328
|
try {
|
|
320
329
|
// Remove white space around the element
|
|
321
330
|
if (typeof (el) == 'string' && el != null)
|
|
@@ -337,7 +346,10 @@ let DOM = (el, all = true) => {
|
|
|
337
346
|
return null;
|
|
338
347
|
}
|
|
339
348
|
};
|
|
340
|
-
|
|
349
|
+
/**
|
|
350
|
+
* strcopy: send string to clipboard
|
|
351
|
+
* @param text string
|
|
352
|
+
*/
|
|
341
353
|
let strcopy = (text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
342
354
|
try {
|
|
343
355
|
yield navigator.clipboard.writeText(text);
|
|
@@ -346,73 +358,96 @@ let strcopy = (text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
346
358
|
console.error('Failed to copy text: ', err);
|
|
347
359
|
}
|
|
348
360
|
});
|
|
349
|
-
|
|
361
|
+
/**
|
|
362
|
+
* goto: url redirection
|
|
363
|
+
* @param _location Location
|
|
364
|
+
*/
|
|
350
365
|
let goto = (_location) => {
|
|
351
366
|
try {
|
|
352
367
|
location.href = _location.toString();
|
|
353
368
|
}
|
|
354
369
|
catch (err) {
|
|
355
|
-
console.error('Failed
|
|
370
|
+
console.error('Failed redirect: ', err);
|
|
356
371
|
}
|
|
357
372
|
};
|
|
358
|
-
|
|
359
|
-
|
|
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) => {
|
|
360
380
|
// Element selection
|
|
361
381
|
let dom = select(el);
|
|
362
|
-
//
|
|
363
|
-
|
|
364
|
-
dom.setAttribute(`${attrib}`, `${set}`);
|
|
365
|
-
// else return attrribute value
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
382
|
+
// Return the attrribute value of the element
|
|
383
|
+
try {
|
|
368
384
|
return dom.getAttribute(`${attrib}`);
|
|
369
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
|
+
}
|
|
370
391
|
};
|
|
371
|
-
|
|
372
|
-
|
|
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) => {
|
|
373
399
|
// Element selection
|
|
374
400
|
let dom = select(el);
|
|
375
401
|
// Apply the attrribute value to element
|
|
376
|
-
if (
|
|
377
|
-
dom.setAttribute(`${attrib}`, `${
|
|
402
|
+
if (value) {
|
|
403
|
+
dom.setAttribute(`${attrib}`, `${value}`);
|
|
378
404
|
}
|
|
379
405
|
else {
|
|
380
|
-
console.warn('set_attrib(el: string, attrib: any,
|
|
406
|
+
console.warn('set_attrib(el: string, attrib: any, value?: any)' + `: => '${el}.atribute(${attrib}) will be empty.`);
|
|
381
407
|
dom.setAttribute(`${attrib}`, '');
|
|
382
408
|
}
|
|
383
409
|
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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) => {
|
|
387
417
|
let dom = select(el);
|
|
388
|
-
|
|
389
|
-
try {
|
|
390
|
-
return dom.getAttribute(`${attrib}`);
|
|
391
|
-
}
|
|
392
|
-
catch (ATTR_ERR) {
|
|
393
|
-
// Debug get_attrib()
|
|
394
|
-
console.error(`${ATTR_ERR.name}: get_attrib(el: string, attrib: any) => '${el}' has no a ${attrib} attribute.`);
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
418
|
+
return dom.classList.value.split();
|
|
397
419
|
};
|
|
398
420
|
/**
|
|
399
|
-
*
|
|
421
|
+
* set_classlist: add/remove element classes
|
|
400
422
|
* If token is true, adds token (same as [...].classList.add()).
|
|
401
423
|
* If force is false, removes token (same as [...].classList.remove()).
|
|
402
|
-
*
|
|
403
|
-
|
|
424
|
+
*
|
|
425
|
+
* @param el string
|
|
426
|
+
* @param tokens string[]
|
|
427
|
+
*/
|
|
428
|
+
let set_classlist = (el, tokens) => {
|
|
404
429
|
let dom = select(el);
|
|
405
430
|
// check for each token force
|
|
406
431
|
tokens.forEach(key => {
|
|
407
432
|
dom.classList.toggle(key);
|
|
408
433
|
});
|
|
409
434
|
};
|
|
410
|
-
/** end:
|
|
411
|
-
|
|
435
|
+
/** end: classList */
|
|
436
|
+
/** Node */
|
|
437
|
+
/**
|
|
438
|
+
* create: Create node elements
|
|
439
|
+
* @param el string
|
|
440
|
+
* @returns ElementCreationOptions
|
|
441
|
+
*/
|
|
412
442
|
let create = (el) => {
|
|
413
443
|
return document.createElement(el);
|
|
414
444
|
};
|
|
415
|
-
|
|
445
|
+
/**
|
|
446
|
+
* select: Node list selector
|
|
447
|
+
* @param el string
|
|
448
|
+
* @param all boolean
|
|
449
|
+
* @returns NodeList
|
|
450
|
+
*/
|
|
416
451
|
let select = (el, all = false) => {
|
|
417
452
|
try {
|
|
418
453
|
// Remove white space around the element
|
|
@@ -434,7 +469,11 @@ let select = (el, all = false) => {
|
|
|
434
469
|
return null;
|
|
435
470
|
}
|
|
436
471
|
};
|
|
437
|
-
|
|
472
|
+
/**
|
|
473
|
+
* select_tag: HTMLCollection selector
|
|
474
|
+
* @param el string
|
|
475
|
+
* @returns HTMLCollection
|
|
476
|
+
*/
|
|
438
477
|
let select_tag = (el) => {
|
|
439
478
|
try {
|
|
440
479
|
// Remove white space around the element
|
|
@@ -448,7 +487,11 @@ let select_tag = (el) => {
|
|
|
448
487
|
return null;
|
|
449
488
|
}
|
|
450
489
|
};
|
|
451
|
-
|
|
490
|
+
/**
|
|
491
|
+
* select_id: Element `Id` selector
|
|
492
|
+
* @param el string
|
|
493
|
+
* @returns HTMLElement
|
|
494
|
+
*/
|
|
452
495
|
let select_id = (el) => {
|
|
453
496
|
try {
|
|
454
497
|
// Remove white space around the element
|
|
@@ -462,7 +505,10 @@ let select_id = (el) => {
|
|
|
462
505
|
return null;
|
|
463
506
|
}
|
|
464
507
|
};
|
|
465
|
-
|
|
508
|
+
/**
|
|
509
|
+
* drop_all: Remove element(s) list from DOM
|
|
510
|
+
* @param list string[]
|
|
511
|
+
*/
|
|
466
512
|
let drop_all = (list) => {
|
|
467
513
|
list.forEach(el => {
|
|
468
514
|
// Element selection from list
|
|
@@ -476,7 +522,11 @@ let drop_all = (list) => {
|
|
|
476
522
|
}
|
|
477
523
|
});
|
|
478
524
|
};
|
|
479
|
-
|
|
525
|
+
/**
|
|
526
|
+
*
|
|
527
|
+
* @param token string[]
|
|
528
|
+
* @returns any
|
|
529
|
+
*/
|
|
480
530
|
let drop = (token) => {
|
|
481
531
|
// Element selection
|
|
482
532
|
const dom = select(token);
|
|
@@ -488,13 +538,19 @@ let drop = (token) => {
|
|
|
488
538
|
return null;
|
|
489
539
|
}
|
|
490
540
|
};
|
|
491
|
-
|
|
492
|
-
|
|
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) => {
|
|
493
549
|
if (isset(el)) {
|
|
494
|
-
if (
|
|
550
|
+
if (match_all) {
|
|
495
551
|
// all = true
|
|
496
552
|
// Genearate a list of all `el`
|
|
497
|
-
let list = select(el,
|
|
553
|
+
let list = select(el, match_all);
|
|
498
554
|
// for each element of the list add/replace content
|
|
499
555
|
list.forEach((el) => {
|
|
500
556
|
el.innerHTML = `${text}`;
|
|
@@ -515,13 +571,21 @@ let echo = (text, el, all = false) => {
|
|
|
515
571
|
console.log(`${text}`);
|
|
516
572
|
}
|
|
517
573
|
};
|
|
518
|
-
|
|
574
|
+
/**
|
|
575
|
+
* get_innerTEXT: Get element text content
|
|
576
|
+
* @param el string
|
|
577
|
+
* @returns string
|
|
578
|
+
*/
|
|
519
579
|
let get_innerTEXT = (el) => {
|
|
520
580
|
// Element selection
|
|
521
581
|
let dom = select(el);
|
|
522
582
|
return dom.innerTEXT;
|
|
523
583
|
};
|
|
524
|
-
|
|
584
|
+
/**
|
|
585
|
+
* set_innerTEXT: Replace element text content
|
|
586
|
+
* @param el string
|
|
587
|
+
* @param text string
|
|
588
|
+
*/
|
|
525
589
|
let set_innerTEXT = (el, text) => {
|
|
526
590
|
try {
|
|
527
591
|
document.querySelector(el).innerTEXT = `${text}`;
|
|
@@ -531,12 +595,20 @@ let set_innerTEXT = (el, text) => {
|
|
|
531
595
|
console.error(error);
|
|
532
596
|
}
|
|
533
597
|
};
|
|
534
|
-
|
|
598
|
+
/**
|
|
599
|
+
* get_innerHTML: Get html content of element
|
|
600
|
+
* @param el string
|
|
601
|
+
* @returns string
|
|
602
|
+
*/
|
|
535
603
|
let get_innerHTML = (el) => {
|
|
536
604
|
// Get html content of an element
|
|
537
605
|
return document.querySelector(el).innerHTML;
|
|
538
606
|
};
|
|
539
|
-
|
|
607
|
+
/**
|
|
608
|
+
* set_innerHTML: Replace html content of element
|
|
609
|
+
* @param el string
|
|
610
|
+
* @param concent string
|
|
611
|
+
*/
|
|
540
612
|
let set_innerHTML = (el, concent) => {
|
|
541
613
|
try {
|
|
542
614
|
document.querySelector(el).innerHTML = `${concent}`;
|
|
@@ -546,17 +618,23 @@ let set_innerHTML = (el, concent) => {
|
|
|
546
618
|
console.error(error);
|
|
547
619
|
}
|
|
548
620
|
};
|
|
549
|
-
|
|
550
|
-
|
|
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) {
|
|
551
629
|
// Element selection
|
|
552
|
-
|
|
630
|
+
let dom = select(el);
|
|
553
631
|
// if hidden by style attribute then display as `displayValue`
|
|
554
632
|
if (dom.style.display == 'none') {
|
|
555
|
-
|
|
633
|
+
dom.style.display == `${displayValue}`;
|
|
556
634
|
// if displayed by style attribute then change the value to `none`
|
|
557
635
|
}
|
|
558
636
|
else if (dom.style.display == `${displayValue}`) {
|
|
559
|
-
|
|
637
|
+
dom.style.display == 'none';
|
|
560
638
|
}
|
|
561
639
|
else {
|
|
562
640
|
// if hidden by class attribute containing `hidden` token
|
|
@@ -591,10 +669,10 @@ let display = (el, displayValue = 'block') => {
|
|
|
591
669
|
let hide = dom.getAttribute('hidden');
|
|
592
670
|
if (isset(hide)) {
|
|
593
671
|
if (hide == true) {
|
|
594
|
-
|
|
672
|
+
hide = false;
|
|
595
673
|
}
|
|
596
674
|
else {
|
|
597
|
-
|
|
675
|
+
hide = true;
|
|
598
676
|
}
|
|
599
677
|
}
|
|
600
678
|
}
|
|
@@ -604,11 +682,25 @@ let display = (el, displayValue = 'block') => {
|
|
|
604
682
|
}
|
|
605
683
|
}
|
|
606
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
|
+
}
|
|
607
695
|
};
|
|
608
|
-
|
|
609
|
-
|
|
696
|
+
/**
|
|
697
|
+
* hide: make a hidden element
|
|
698
|
+
* @param el string
|
|
699
|
+
* @returns void
|
|
700
|
+
*/
|
|
701
|
+
function _hide(el) {
|
|
610
702
|
// Possible classlist values
|
|
611
|
-
const list = ['block', 'inline-block', 'flex', 'inline-flex'];
|
|
703
|
+
const list = ['block', 'inline', 'inline-block', 'flex', 'inline-flex'];
|
|
612
704
|
// Element selection
|
|
613
705
|
const dom = select(el);
|
|
614
706
|
try {
|
|
@@ -634,17 +726,35 @@ let hide = (el) => {
|
|
|
634
726
|
console.error(display_ERR);
|
|
635
727
|
}
|
|
636
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
|
+
}
|
|
637
739
|
};
|
|
740
|
+
/** EventListener */
|
|
638
741
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
742
|
+
* on: envent listener
|
|
743
|
+
* @param event string
|
|
744
|
+
* @param listener Function
|
|
641
745
|
*/
|
|
642
|
-
// On: Events listner
|
|
643
746
|
let on = (event, listener) => {
|
|
644
747
|
event = event.trim();
|
|
645
|
-
document.addEventListener(event, listener);
|
|
748
|
+
document.addEventListener(event, listener());
|
|
646
749
|
};
|
|
647
|
-
|
|
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) => {
|
|
648
758
|
var dom = select(el);
|
|
649
759
|
// Add or remove class based on scroll position
|
|
650
760
|
if (window.scrollY > offset) {
|
|
@@ -664,26 +774,21 @@ let on_scroll = (el, add_list, rm_list = [], offset = 0) => {
|
|
|
664
774
|
});
|
|
665
775
|
}
|
|
666
776
|
};
|
|
777
|
+
/**
|
|
778
|
+
* scroll_to: scroll to element on page
|
|
779
|
+
* @param el string
|
|
780
|
+
*/
|
|
667
781
|
let scroll_to = (el) => {
|
|
668
782
|
// JavaScript to scroll to the target element
|
|
669
783
|
var dom = select_id(el);
|
|
670
784
|
dom.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
671
785
|
};
|
|
672
|
-
|
|
673
|
-
let onClick = (el, listener) => {
|
|
674
|
-
const d = select_id(el);
|
|
675
|
-
return d.onclick = listener;
|
|
676
|
-
};
|
|
677
|
-
// Ondlclick: Double click listner
|
|
678
|
-
let onDblClick = (el, listener) => {
|
|
679
|
-
const d = select_id(el);
|
|
680
|
-
return d.ondblclick = listener;
|
|
681
|
-
};
|
|
786
|
+
/** Validation */
|
|
682
787
|
/**
|
|
683
|
-
*
|
|
684
|
-
*
|
|
788
|
+
* isset: Return true for no-empty Object/var
|
|
789
|
+
* @param key string
|
|
790
|
+
* @returns boolean
|
|
685
791
|
*/
|
|
686
|
-
// Isset: Return true for no-empty Object/var
|
|
687
792
|
let isset = (key) => {
|
|
688
793
|
if (key != null && key != false && key != undefined) {
|
|
689
794
|
return true;
|
|
@@ -695,257 +800,281 @@ let isset = (key) => {
|
|
|
695
800
|
return false;
|
|
696
801
|
}
|
|
697
802
|
};
|
|
803
|
+
/** Mixin */
|
|
698
804
|
/**
|
|
699
|
-
*
|
|
700
|
-
* popUp: create advenced pup-up box style
|
|
701
|
-
* @param popUp
|
|
805
|
+
* pop: create advenced pop-up box style
|
|
702
806
|
*/
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
WINDOW.
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
else {
|
|
757
|
-
WINDOW.classList.add('border');
|
|
758
|
-
}
|
|
759
|
-
// #7. rounded: enable window rounded border (default: true)
|
|
760
|
-
if (window.rounded == true) {
|
|
761
|
-
WINDOW.classList.add('rounded');
|
|
762
|
-
}
|
|
763
|
-
else if (window.rounded == false) {
|
|
764
|
-
// do nothing ...
|
|
765
|
-
}
|
|
766
|
-
else {
|
|
767
|
-
WINDOW.classList.add('rounded');
|
|
768
|
-
}
|
|
769
|
-
// #8. shadow: enable window shadow (default: true)
|
|
770
|
-
if (window.shadow == true) {
|
|
771
|
-
WINDOW.classList.add('shadow-sm');
|
|
772
|
-
}
|
|
773
|
-
else if (window.shadow == false) {
|
|
774
|
-
// do nothing ...
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
777
|
-
WINDOW.classList.add('shadow-sm');
|
|
778
|
-
}
|
|
779
|
-
// #9. [top, right, bottom, left]: set window position
|
|
780
|
-
if (window.top || window.right || window.bottom || window.left) {
|
|
781
|
-
WINDOW.style.top = window.top;
|
|
782
|
-
WINDOW.style.right = window.right;
|
|
783
|
-
WINDOW.style.bottom = window.bottom;
|
|
784
|
-
WINDOW.style.left = window.left;
|
|
785
|
-
}
|
|
786
|
-
else {
|
|
787
|
-
WINDOW.style.top = '50%';
|
|
788
|
-
WINDOW.style.left = '50%';
|
|
789
|
-
WINDOW.classList.add('translate--50');
|
|
790
|
-
}
|
|
791
|
-
// #10. header/title bar
|
|
792
|
-
// #10.1 Create a title bar
|
|
793
|
-
const HEADER = create('div');
|
|
794
|
-
HEADER.classList.add('flex', 'items-center', 'justify-between', 'full-width');
|
|
795
|
-
HEADER.style.padding = '.2rem';
|
|
796
|
-
// #10.2 favicon: add an icon as window illustrator
|
|
797
|
-
const FAVICON = create('img');
|
|
798
|
-
if (window.favicon) {
|
|
799
|
-
FAVICON.src = window.favicon;
|
|
800
|
-
FAVICON.classList.add('size-32');
|
|
801
|
-
}
|
|
802
|
-
// #10.3 Window action bar
|
|
803
|
-
// * title: set the window title/id
|
|
804
|
-
const TITLE = create('span');
|
|
805
|
-
TITLE.classList.add('pl-1', 'line-clamp-1', 'sm:line-clamp-1');
|
|
806
|
-
TITLE.innerHTML = window.title;
|
|
807
|
-
// * add moving icon
|
|
808
|
-
const WIN_Move = create('button');
|
|
809
|
-
WIN_Move.classList.add('bg-none', 'cursor-default', 'fa-solid', 'fa-up-down-left-right', 'p-0', 'rounded-full', 'size-32', 'muted');
|
|
810
|
-
// * add closing button
|
|
811
|
-
const WIN_Close = create('button');
|
|
812
|
-
WIN_Close.classList.add('bg-none', 'fa-solid', 'fa-times', 'hover:bg-danger', 'p-0', 'rounded-full', 'size-32');
|
|
813
|
-
// #11. views: create adaptable content
|
|
814
|
-
var view = '';
|
|
815
|
-
if (window.content) {
|
|
816
|
-
view = 'p';
|
|
817
|
-
}
|
|
818
|
-
else if (window.html) {
|
|
819
|
-
view = 'div';
|
|
820
|
-
}
|
|
821
|
-
else if (window.href) {
|
|
822
|
-
view = 'iframe';
|
|
823
|
-
}
|
|
824
|
-
// - create main window view
|
|
825
|
-
const CONTENT = create(view);
|
|
826
|
-
if (window.content) {
|
|
827
|
-
CONTENT.classList.add('m-0', 'px-2', 'py-1', 'w-full');
|
|
828
|
-
CONTENT.innerHTML = window.content;
|
|
829
|
-
if (window.titlebar == true) {
|
|
830
|
-
CONTENT.classList.add('border', 'border-0', 'border-t-1');
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
else if (window.html) {
|
|
834
|
-
CONTENT.classList.add('max-height', 'border-0', 'border-t-1', 'border-white', 'px-2', 'py-1', 'w-full');
|
|
835
|
-
CONTENT.innerHTML = window.html;
|
|
836
|
-
}
|
|
837
|
-
else if (window.href) {
|
|
838
|
-
CONTENT.classList.add('no-border');
|
|
839
|
-
CONTENT.height = '100%';
|
|
840
|
-
CONTENT.width = '100%';
|
|
841
|
-
CONTENT.src = window.href;
|
|
842
|
-
if (window.titlebar == true) {
|
|
843
|
-
CONTENT.classList.add('border-0', 'border-t-1', 'border-white');
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
// #12. Actions
|
|
847
|
-
// #12.1 draging action (double-click)
|
|
848
|
-
WINDOW.ondblclick = () => {
|
|
849
|
-
let move = get_attrib('.js_focus', 'aria-grabbed');
|
|
850
|
-
WINDOW.classList.toggle('cursor-grabbing');
|
|
851
|
-
if (move == 'true') {
|
|
852
|
-
WINDOW.setAttribute('aria-grabbed', 'false');
|
|
853
|
-
WIN_Move.classList.add('muted');
|
|
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}`);
|
|
854
860
|
}
|
|
855
861
|
else {
|
|
856
|
-
WINDOW.
|
|
857
|
-
WIN_Move.classList.remove('muted');
|
|
862
|
+
WINDOW.classList.add('z-8');
|
|
858
863
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
let drag = get_attrib(`#${focus.id}`, 'aria-grabbed');
|
|
863
|
-
// ajust window option according to cursor position
|
|
864
|
-
if (focus && drag == 'true') {
|
|
865
|
-
let x = e.clientX;
|
|
866
|
-
let y = e.clientY;
|
|
867
|
-
WINDOW.style.left = `${x}px`;
|
|
868
|
-
WINDOW.style.top = `${y}px`;
|
|
864
|
+
// #5. style: choose apearence between dark/light (default: light)
|
|
865
|
+
if (`${this.style}` == 'dark') {
|
|
866
|
+
WINDOW.classList.add('bg-dark-900', 'fg-light');
|
|
869
867
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
WIN_Close.onclick = () => {
|
|
873
|
-
drop('.js_focus');
|
|
874
|
-
try {
|
|
875
|
-
// remove window overlay if enabled
|
|
876
|
-
drop('#window_overlay');
|
|
868
|
+
else if (`${this.style}` == 'light') {
|
|
869
|
+
WINDOW.classList.add('bg-light', 'fg-dark-900');
|
|
877
870
|
}
|
|
878
|
-
|
|
879
|
-
|
|
871
|
+
else if (`${this.style}` == 'none') {
|
|
872
|
+
WINDOW.style.color = 'inherit';
|
|
880
873
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
WINDOW.addEventListener('mouseover', () => {
|
|
884
|
-
WINDOW.classList.add('js_focus');
|
|
885
|
-
if (!window.index) {
|
|
886
|
-
WINDOW.onclick = () => {
|
|
887
|
-
let lostFocus = select('.z-8');
|
|
888
|
-
if (lostFocus) {
|
|
889
|
-
lostFocus.classList.add('z-7');
|
|
890
|
-
lostFocus.classList.remove('z-8');
|
|
891
|
-
}
|
|
892
|
-
WINDOW.classList.add('z-8');
|
|
893
|
-
};
|
|
874
|
+
else {
|
|
875
|
+
WINDOW.classList.add('bg-light', 'fg-dark-900');
|
|
894
876
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
if (window.timeout != 0 && window.timeout != null) {
|
|
902
|
-
let timeout = window.timeout;
|
|
903
|
-
setTimeout(() => {
|
|
904
|
-
WINDOW.classList.add('animate-fadeOut');
|
|
905
|
-
}, timeout);
|
|
906
|
-
WINDOW.remove();
|
|
907
|
-
}
|
|
908
|
-
// #13. final views
|
|
909
|
-
// # header sections
|
|
910
|
-
// - favicon & title block
|
|
911
|
-
let div_1 = create('div');
|
|
912
|
-
div_1.classList.add('flex', 'items-center');
|
|
913
|
-
if (window.favicon) {
|
|
914
|
-
div_1.appendChild(FAVICON);
|
|
915
|
-
}
|
|
916
|
-
div_1.appendChild(TITLE);
|
|
917
|
-
// - window actions block
|
|
918
|
-
let div_2 = create('div');
|
|
919
|
-
div_2.classList.add('flex', 'items-center', 'g-1');
|
|
920
|
-
div_2.appendChild(WIN_Move);
|
|
921
|
-
div_2.appendChild(WIN_Close);
|
|
922
|
-
HEADER.appendChild(div_1);
|
|
923
|
-
HEADER.appendChild(div_2);
|
|
924
|
-
// #14. Ready header view's
|
|
925
|
-
if (window.titlebar != false) {
|
|
926
|
-
WINDOW.appendChild(HEADER);
|
|
927
|
-
}
|
|
928
|
-
// #15. Ready content view's
|
|
929
|
-
WINDOW.appendChild(CONTENT);
|
|
930
|
-
// *** overlay options view ***
|
|
931
|
-
if (window.overlay == true) {
|
|
932
|
-
let overlay = create('div');
|
|
933
|
-
overlay.id = 'window_overlay';
|
|
934
|
-
overlay.classList.add('absolute', 'fullscreen', 'top-0', 'left-0', 'backdrop-blur-10', 'ease-in', 'animate-fadeIn', 'animated-500');
|
|
935
|
-
if (window.index) {
|
|
936
|
-
let i = window.index;
|
|
937
|
-
overlay.classList.add(`z-${i - 1}`);
|
|
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 ...
|
|
938
883
|
}
|
|
939
884
|
else {
|
|
940
|
-
|
|
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);
|
|
941
1075
|
}
|
|
942
|
-
document.body.appendChild(overlay);
|
|
943
|
-
document.body.appendChild(WINDOW);
|
|
944
|
-
}
|
|
945
|
-
else {
|
|
946
|
-
document.body.appendChild(WINDOW);
|
|
947
1076
|
}
|
|
948
|
-
}
|
|
1077
|
+
}
|
|
949
1078
|
/**
|
|
950
1079
|
* Cookies manage
|
|
951
1080
|
*/
|