nodality 1.0.0-beta.1
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/dist/animator.cjs.js +1 -0
- package/dist/animator.esm.js +1 -0
- package/dist/audionew.cjs.js +1 -0
- package/dist/audionew.esm.js +1 -0
- package/dist/base.cjs.js +1 -0
- package/dist/base.esm.js +1 -0
- package/dist/betaDesktopBar.esm.js +1 -0
- package/dist/betaMobileBar.esm.js +1 -0
- package/dist/bundle.umd.js +1 -0
- package/dist/button.cjs.js +1 -0
- package/dist/button.esm.js +1 -0
- package/dist/cardGetter.cjs.js +1 -0
- package/dist/cardGetter.esm.js +1 -0
- package/dist/center.cjs.js +1 -0
- package/dist/center.esm.js +1 -0
- package/dist/checkbox.cjs.js +1 -0
- package/dist/checkbox.esm.js +1 -0
- package/dist/code.cjs.js +1 -0
- package/dist/code.esm.js +1 -0
- package/dist/container.cjs.js +1 -0
- package/dist/container.esm.js +1 -0
- package/dist/datalist.cjs.js +1 -0
- package/dist/datalist.esm.js +1 -0
- package/dist/designer.cjs.js +1 -0
- package/dist/designer.esm.js +1 -0
- package/dist/dropdown.cjs.js +1 -0
- package/dist/dropdown.esm.js +1 -0
- package/dist/elementMapper.cjs.js +1 -0
- package/dist/elementMapper.esm.js +1 -0
- package/dist/finalresult.esm.js +1 -0
- package/dist/flexCard.cjs.js +1 -0
- package/dist/flexCard.esm.js +1 -0
- package/dist/flexGrid.cjs.js +1 -0
- package/dist/flexGrid.esm.js +1 -0
- package/dist/flexRow.cjs.js +1 -0
- package/dist/flexRow.esm.js +1 -0
- package/dist/floatingInput.cjs.js +1 -0
- package/dist/floatingInput.esm.js +1 -0
- package/dist/free.cjs.js +1 -0
- package/dist/free.esm.js +1 -0
- package/dist/horizontalScroller.esm.js +1 -0
- package/dist/image.cjs.js +1 -0
- package/dist/image.esm.js +1 -0
- package/dist/imagePicker.cjs.js +1 -0
- package/dist/imagePicker.esm.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/link.cjs.js +1 -0
- package/dist/link.esm.js +1 -0
- package/dist/linkGetter.cjs.js +1 -0
- package/dist/linkGetter.esm.js +1 -0
- package/dist/metaAdder.cjs.js +1 -0
- package/dist/metaAdder.esm.js +1 -0
- package/dist/modal2025.cjs.js +1 -0
- package/dist/modal2025.esm.js +1 -0
- package/dist/multiswitchers.esm.js +1 -0
- package/dist/newNavBar.cjs.js +1 -0
- package/dist/newNavBar.esm.js +1 -0
- package/dist/picker.cjs.js +1 -0
- package/dist/picker.esm.js +1 -0
- package/dist/progress.cjs.js +1 -0
- package/dist/progress.esm.js +1 -0
- package/dist/radio.cjs.js +1 -0
- package/dist/radio.esm.js +1 -0
- package/dist/range.cjs.js +1 -0
- package/dist/range.esm.js +1 -0
- package/dist/sideBar.cjs.js +1 -0
- package/dist/sideBar.esm.js +1 -0
- package/dist/sideNavBar.cjs.js +1 -0
- package/dist/sideNavBar.esm.js +1 -0
- package/dist/simpleBar.cjs.js +1 -0
- package/dist/simpleBar.esm.js +1 -0
- package/dist/stack.cjs.js +1 -0
- package/dist/stack.esm.js +1 -0
- package/dist/table.cjs.js +1 -0
- package/dist/table.esm.js +1 -0
- package/dist/text.cjs.js +1 -0
- package/dist/text.esm.js +1 -0
- package/dist/textField.cjs.js +1 -0
- package/dist/textField.esm.js +1 -0
- package/dist/wrap.cjs.js +1 -0
- package/dist/wrap.esm.js +1 -0
- package/dist/zoomCard.cjs.js +1 -0
- package/dist/zoomCard.esm.js +1 -0
- package/layout/<head> +59 -0
- package/layout/DEADJOE +49 -0
- package/layout/DEPRECATED-PARAGRAPH.js +103 -0
- package/layout/animator.js +1915 -0
- package/layout/audio.js +145 -0
- package/layout/audionew.js +70 -0
- package/layout/base-2.js +92 -0
- package/layout/base.js +161 -0
- package/layout/betaDesktopBar.js +126 -0
- package/layout/betaMobileBar.js +293 -0
- package/layout/box.js +29 -0
- package/layout/button.js +516 -0
- package/layout/cards.js +136 -0
- package/layout/center.js +143 -0
- package/layout/checkbox.js +183 -0
- package/layout/cleanRow.js +775 -0
- package/layout/code.js +60 -0
- package/layout/container.js +1005 -0
- package/layout/custom.js +289 -0
- package/layout/divImage.js +209 -0
- package/layout/dropdown.js +154 -0
- package/layout/dropdown2025.js +152 -0
- package/layout/edit.sh +39 -0
- package/layout/emptyElement.js +21 -0
- package/layout/externalStylesheet.js +19 -0
- package/layout/flexCard.js +220 -0
- package/layout/flexGrid.js +192 -0
- package/layout/flexrow.js +866 -0
- package/layout/footer.js +83 -0
- package/layout/formComponents/custom.js +0 -0
- package/layout/formComponents/dataList.js +183 -0
- package/layout/formComponents/edit.sh +39 -0
- package/layout/formComponents/floatingInput.js +163 -0
- package/layout/formComponents/form-all.js +161 -0
- package/layout/formComponents/form.js +76 -0
- package/layout/formComponents/imagePicker.js +266 -0
- package/layout/formComponents/picker.js +208 -0
- package/layout/formComponents/radio.js +231 -0
- package/layout/formComponents/radiogroup.js +231 -0
- package/layout/formComponents/range.js +158 -0
- package/layout/free.js +232 -0
- package/layout/grid-new.js +299 -0
- package/layout/grid.js +190 -0
- package/layout/gridSwitcher.js +188 -0
- package/layout/group.js +163 -0
- package/layout/header.js +175 -0
- package/layout/hello.html +126 -0
- package/layout/horizontalScroller.js +222 -0
- package/layout/image-old.js +487 -0
- package/layout/image.js +1039 -0
- package/layout/index.js +183 -0
- package/layout/label.js +50 -0
- package/layout/link.js +1085 -0
- package/layout/list-OLD.js +0 -0
- package/layout/list.js +127 -0
- package/layout/metaAdder.js +17 -0
- package/layout/modal2025.js +142 -0
- package/layout/modernwrap.js +92 -0
- package/layout/multiswitcher.js +224 -0
- package/layout/multiswitcherBeta.js +63 -0
- package/layout/navBar-OLD.js +261 -0
- package/layout/navBar.js +371 -0
- package/layout/navFactor/customDiv.js +60 -0
- package/layout/navFactor/edit.sh +39 -0
- package/layout/newFlatAdder.js +41 -0
- package/layout/newNavBar copy 2.js +915 -0
- package/layout/newNavBar copy.js +774 -0
- package/layout/newNavBar.js +925 -0
- package/layout/offsetContainer.js +395 -0
- package/layout/progress.js +111 -0
- package/layout/remWin.sh +20 -0
- package/layout/row.js +208 -0
- package/layout/savedNewNavBar.js +437 -0
- package/layout/scrollvideo.js +120 -0
- package/layout/sideBar.js +183 -0
- package/layout/sideNavBar.js +313 -0
- package/layout/simpleBar.js +25 -0
- package/layout/slider2025.js +198 -0
- package/layout/spacer.js +44 -0
- package/layout/stack.js +76 -0
- package/layout/styler.js +113 -0
- package/layout/switcher.js +102 -0
- package/layout/table.js +155 -0
- package/layout/text.js +1685 -0
- package/layout/textField.js +282 -0
- package/layout/ulist.js +147 -0
- package/layout/video.js +70 -0
- package/layout/withoutNew.js +60 -0
- package/layout/wrap.js +140 -0
- package/layout/zoomCard.js +219 -0
- package/lib/cardGetter.js +80 -0
- package/lib/designer.js +875 -0
- package/lib/elementMapper.js +1428 -0
- package/lib/linkGetter.js +202 -0
- package/package.json +33 -0
|
File without changes
|
package/layout/list.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
// 13:28 07/04/2020 - BEGIN NOTHING GONNA STOP US NOW Lets go!
|
|
4
|
+
class List {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.tasks = [];
|
|
7
|
+
this.setup();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
set tasks(tasks) {
|
|
11
|
+
this.items(tasks);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setup() {
|
|
15
|
+
this.wrapper = document.createElement("div");
|
|
16
|
+
this.wrapper.style.display = "flex";
|
|
17
|
+
this.wrapper.style.flexDirection = "column";
|
|
18
|
+
this.wrapper.style.padding = 0;
|
|
19
|
+
this.wrapper.style.margin = 0;
|
|
20
|
+
this.wrapCopy = this.wrapper;
|
|
21
|
+
this.tasks = {};
|
|
22
|
+
// var copy = this.tasks;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
padding(val) {
|
|
27
|
+
this.ele.style.padding = val;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
margin(val) {
|
|
32
|
+
this.ele.style.margin = val;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
border(w, color) {
|
|
37
|
+
this.ele.style.border = `${w}px solid ${color}`;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set itemso(itemsa) {
|
|
42
|
+
this.items(itemsa);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setItem(item){
|
|
46
|
+
this.item = item;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
items(tasks) {
|
|
51
|
+
if (this.wrapper) {
|
|
52
|
+
while (this.wrapper.firstChild) {
|
|
53
|
+
this.wrapper.removeChild(this.wrapper.lastChild);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (var i = 0; i < tasks.length; i++) {
|
|
58
|
+
let cell = this.item.render();
|
|
59
|
+
this.wrapper.appendChild(new Text(tasks[i]).render());
|
|
60
|
+
}
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
render(div) {
|
|
65
|
+
if (div) {
|
|
66
|
+
document.querySelector(div).appendChild(this.wrapper);
|
|
67
|
+
} else {
|
|
68
|
+
return this.wrapper;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Proxima(a) {
|
|
75
|
+
var me = this;
|
|
76
|
+
return new Proxy(a, {
|
|
77
|
+
get(target, property, receiver) { // GETTER FIRES THIS BEFORE WE GET DATA USING (this.items.push())
|
|
78
|
+
/*
|
|
79
|
+
me.itemso = a[property].map(t => String(t));
|
|
80
|
+
return a[property];*/
|
|
81
|
+
|
|
82
|
+
return a[property];
|
|
83
|
+
},
|
|
84
|
+
set(T, P, V, R) {
|
|
85
|
+
me.itemso = a[P].map(t => String(t));
|
|
86
|
+
return a[P];
|
|
87
|
+
},
|
|
88
|
+
has(t, p) {
|
|
89
|
+
return Reflect.has(t, p);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
observe(obj) {
|
|
95
|
+
return this.Proxima(obj);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class Cell {
|
|
102
|
+
constructor(){
|
|
103
|
+
this.res = null;
|
|
104
|
+
this.setup();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setup(){
|
|
108
|
+
let el = document.createElement("div");
|
|
109
|
+
el.style.border = "2px solid gray";
|
|
110
|
+
this.res = el;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
child(el){
|
|
115
|
+
this.res.appendChild(el.render());
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
render(){
|
|
120
|
+
return this.res;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
window.List
|
|
124
|
+
Cell = List
|
|
125
|
+
Cell;
|
|
126
|
+
export { List
|
|
127
|
+
Cell };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class MetaAdder{
|
|
4
|
+
constructor(){
|
|
5
|
+
this.res = document.createElement("meta");
|
|
6
|
+
this.res.setAttribute("name", "viewport");
|
|
7
|
+
this.res.setAttribute("content", "width=device-width, initial-scale=1");
|
|
8
|
+
this.charset = document.createElement("meta");
|
|
9
|
+
this.charset.setAttribute("charset", "UTF-8");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
add(){
|
|
13
|
+
document.head.appendChild(this.res);
|
|
14
|
+
document.head.appendChild(this.charset);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { MetaAdder };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Modal {
|
|
5
|
+
constructor(){
|
|
6
|
+
this.el = null;
|
|
7
|
+
this.obj = null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
set(obj){
|
|
12
|
+
let el = document.createElement("div");
|
|
13
|
+
el.style.width = "100vw";
|
|
14
|
+
el.style.height = "100vh";
|
|
15
|
+
el.style.backgroundColor = obj.background;//"rgba(70,157,115,0.8)";
|
|
16
|
+
// el.style.backgroundColor = "#3498db";
|
|
17
|
+
el.style.zIndex = "1";
|
|
18
|
+
//el.style.opacity = 0.90;
|
|
19
|
+
el.style.position = "absolute";
|
|
20
|
+
el.style.overflowY = "scroll";
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
this.obj = obj;
|
|
24
|
+
this.res = el;
|
|
25
|
+
obj.close && this.close();
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
close(){
|
|
33
|
+
this.res.style.display = "none";
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
show(){
|
|
38
|
+
this.res.style.display = "block";
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
add(els){
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
let el = document.createElement("div");
|
|
50
|
+
el.style.width = this.obj.width;
|
|
51
|
+
el.style.height = "auto";
|
|
52
|
+
el.style.marginLeft = "auto";
|
|
53
|
+
el.style.marginRight = "auto";
|
|
54
|
+
el.style.backgroundColor = "white";
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
let mq = window.matchMedia("(max-device-width: 415px)");
|
|
58
|
+
if (mq.matches){
|
|
59
|
+
el.style.marginTop = "200px";
|
|
60
|
+
el.style.width = "100%";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/* el.style.marginTop = "60px";
|
|
65
|
+
el.style.width = this.obj.width; //"60%";
|
|
66
|
+
el.style.height = "auto";
|
|
67
|
+
el.style.marginLeft = "auto";
|
|
68
|
+
el.style.marginRight = "auto";
|
|
69
|
+
el.style.backgroundColor = "white"; // "#3498db";
|
|
70
|
+
el.style.opacity = 1.0;
|
|
71
|
+
el.style.zIndex = "2";
|
|
72
|
+
el.style.borderRadius = "16px";
|
|
73
|
+
el.style.overflow = "hidden"; // User wrapper instead of this?
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
// el.style.padding = "2em";
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
/* let mq = window.matchMedia("(max-device-width: 415px)");
|
|
81
|
+
if (mq.matches){
|
|
82
|
+
el.style.marginTop = "200px";
|
|
83
|
+
el.style.width = "100%";
|
|
84
|
+
}*/
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
for (var i = 0; i < els.length; i++){
|
|
89
|
+
console.log(els[i]);
|
|
90
|
+
el.appendChild(els[i].render());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
this.res.appendChild(el);
|
|
97
|
+
|
|
98
|
+
/* let inner = new Text("WOW");
|
|
99
|
+
let ren = inner.render();
|
|
100
|
+
ren.style.zIndex = "2";
|
|
101
|
+
|
|
102
|
+
this.res.appendChild(ren);
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
render(el) {
|
|
114
|
+
if (el) {
|
|
115
|
+
document.querySelector("body").style.margin = 0;
|
|
116
|
+
document.querySelector("body").style.padding = 0;
|
|
117
|
+
document.querySelector(el).appendChild(this.res);
|
|
118
|
+
} else {
|
|
119
|
+
return this.res;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
// var firstLong = "Mount Everest is Earth's highest mountain above sea level, located in the Mahalangur Himal sub-range of the Himalayas. The China–Nepal border runs across its summit point. Its elevation (snow height) of 8,848.86 m (29,031.7 ft) was most recently established in 2020 by the Nepali and Chinese authorities. Mount Everest attracts many climbers, including highly experienced mountaineers. There are two main climbing routes, one approaching the summit from the southeast in Nepal (known as the standard route) and the other from the north in Tibet. While not posing substantial technical climbing challenges on the standard route, Everest presents dangers such as altitude sickness, weather, and wind, as well as significant hazards from avalanches and the Khumbu Icefall. As of 2019, over 300 people have died on Everest, many of whose bodies remain on the mountain.";
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
// var secondLong = "Mount Everest (Chinese: 珠穆朗玛 Zhūmùlǎngmǎ; Nepali: सगरमाथा, romanized: Sagarmāthā; Tibetan: Chomolungma ཇོ་མོ་གླང་མ) is Earth's highest mountain above sea level, located in the Mahalangur Himal sub-range of the Himalayas. The China–Nepal border runs across its summit point. Its elevation (snow height) of 8,848.86 m (29,031.7 ft) was most recently established in 2020 by the Nepali and Chinese authorities. Mount Everest attracts many climbers, including highly experienced mountaineers. There are two main climbing routes, one approaching the summit from the southeast in Nepal (known as the standard route) and the other from the north in Tibet. While not posing substantial technical climbing challenges on the standard route, Everest presents dangers such as altitude sickness, weather, and wind, as well as significant hazards from avalanches and the Khumbu Icefall. As of 2019, over 300 people have died on Everest, many of whose bodies remain on the mountain. The first recorded efforts to reach Everest's summit were made by British mountaineers. As Nepal did not allow foreigners to enter the country at the time, the British made several attempts on the north ridge route from the Tibetan side. After the first reconnaissance expedition by the British in 1921 reached 7,000 m (22,970 ft) on the North Col, the 1922 expedition pushed the north ridge route up to 8,320 m (27,300 ft), marking the first time a human had climbed above 8,000 m (26,247 ft). The 1924 expedition resulted in one of the greatest mysteries on Everest to this day: George Mallory and Andrew Irvine made a final summit attempt on 8 June but never returned, sparking debate as to whether or not they were the first to reach the top. Tenzing Norgay and Edmund Hillary made the first official ascent of Everest in 1953, using the southeast ridge route. Norgay had reached 8,595 m (28,199 ft) the previous year as a member of the 1952 Swiss expedition. The Chinese mountaineering team of Wang Fuzhou, Gonpo, and Qu Yinhua made the first reported ascent of the peak from the north ridge on 25 May 1960.";
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
export { Modal };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ModernWrap {
|
|
7
|
+
|
|
8
|
+
setup(options){
|
|
9
|
+
let gr = document.createElement("div");
|
|
10
|
+
gr.style.padding = 0;
|
|
11
|
+
gr.style.margin = 0;
|
|
12
|
+
this.res = gr;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
add(els){
|
|
18
|
+
for (var i = 0; i < els.length; i++){
|
|
19
|
+
this.res.appendChild(els[i].render().render());
|
|
20
|
+
console.log("NIONOIBOIBIO")
|
|
21
|
+
}
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/*width(w, shouldCenter){
|
|
28
|
+
this.res.style.width = w;
|
|
29
|
+
|
|
30
|
+
if (shouldCenter){
|
|
31
|
+
this.res.style.marginLeft = "auto";
|
|
32
|
+
this.res.style.marginRight = "auto";
|
|
33
|
+
}
|
|
34
|
+
return this;
|
|
35
|
+
}*/
|
|
36
|
+
|
|
37
|
+
padding(value){
|
|
38
|
+
this.res.style.padding = `${value}px`;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
size(w, h){
|
|
43
|
+
this.w = w;
|
|
44
|
+
this.h = h;
|
|
45
|
+
|
|
46
|
+
if (this.w){
|
|
47
|
+
this.res.style.width = this.w;
|
|
48
|
+
} else {
|
|
49
|
+
this.res.style.width = window.innerWidth;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (this.h){
|
|
53
|
+
this.res.style.height = this.h;
|
|
54
|
+
} else {
|
|
55
|
+
this.res.style.height = window.innerHeight;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/*items(els){
|
|
67
|
+
for (var i = 0; i < els.length; i++){
|
|
68
|
+
this.res.appendChild(els[i].render().render());
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}*/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
border(color, width){
|
|
76
|
+
this.res.style.border = `${width}px solid ${color}`;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
render(el){
|
|
81
|
+
if (el){
|
|
82
|
+
document.querySelector(el).appendChild(this.res);
|
|
83
|
+
} else {
|
|
84
|
+
return this.res;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
export { ModernWrap };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class /*Multi*/Switcher extends Animator {
|
|
4
|
+
constructor(/*it*/) {
|
|
5
|
+
super();
|
|
6
|
+
this.breakpoints = [];
|
|
7
|
+
this.container = null;
|
|
8
|
+
this.currentView = null;
|
|
9
|
+
this.internalDiv = null;
|
|
10
|
+
this.resizeListener = null;
|
|
11
|
+
// this.internalID = it;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
set({ breakpoints }) {
|
|
15
|
+
|
|
16
|
+
this.options = {breakpoints: breakpoints};
|
|
17
|
+
|
|
18
|
+
if (!Array.isArray(breakpoints)) {
|
|
19
|
+
throw new Error("Breakpoints should be an array of objects with 'at' and 'view' properties.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.breakpoints = breakpoints.map(bp => {
|
|
23
|
+
if (typeof bp.at !== "string" || !(bp.view.render() instanceof HTMLElement)) {
|
|
24
|
+
throw new Error("Each breakpoint must have 'at' as a string and 'view' as an HTMLElement.");
|
|
25
|
+
}
|
|
26
|
+
return { ...bp, at: parseInt(bp.at, 10) };
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.breakpoints.sort((a, b) => a.at - b.at);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
toCode() {
|
|
35
|
+
// return ["new Text('A').set({})"];
|
|
36
|
+
const objStringa = JSON.stringify(this.options.breakpoints.map(o => o.view.toCode()).flat(), null,4);
|
|
37
|
+
const objStringas = JSON.stringify(this.options.breakpoints.map(o => o.at), null,4);
|
|
38
|
+
|
|
39
|
+
const objString = JSON.stringify(this.options.breakpoints, null,4);
|
|
40
|
+
// console.log("OMHELLOA");
|
|
41
|
+
// console.log(this.options);
|
|
42
|
+
// console.log(objStringa);
|
|
43
|
+
// console.log(objStringas);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
let str = "";
|
|
47
|
+
for (var i = 0; i < this.options.breakpoints.length; i++){
|
|
48
|
+
str += `{ at: "${this.options.breakpoints[i].at}", view: ${this.options.breakpoints[i].view.toCode()} }, \n` }
|
|
49
|
+
|
|
50
|
+
// console.log(str);
|
|
51
|
+
|
|
52
|
+
return [`new Switcher().set({
|
|
53
|
+
breakpoints: [
|
|
54
|
+
${str}
|
|
55
|
+
]
|
|
56
|
+
})`];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
render(selector) {
|
|
61
|
+
alert(selector); // undefined
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
this.container = document.querySelector(selector);
|
|
65
|
+
|
|
66
|
+
// if (!this.container) { // Why does this condition fire???
|
|
67
|
+
// alert("APPLY MOUNt"); // undefined
|
|
68
|
+
this.container = document.querySelector(this.internalID "#mount");
|
|
69
|
+
// throw new Error(`No element found matching selector: ${selector}`);
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
// Create an internal div for switching content
|
|
73
|
+
this.internalDiv = document.createElement("div");
|
|
74
|
+
this.container.appendChild(this.internalDiv);
|
|
75
|
+
|
|
76
|
+
this.applyView();
|
|
77
|
+
|
|
78
|
+
this.resizeListener = this.applyView.bind(this);
|
|
79
|
+
window.addEventListener("resize", this.resizeListener);
|
|
80
|
+
|
|
81
|
+
return this.container;
|
|
82
|
+
}*/
|
|
83
|
+
|
|
84
|
+
render(val) {
|
|
85
|
+
//alert(val)
|
|
86
|
+
// Create an internal div for switching content
|
|
87
|
+
this.internalDiv = document.createElement("div");
|
|
88
|
+
|
|
89
|
+
// Apply the initial view
|
|
90
|
+
this.applyView();
|
|
91
|
+
|
|
92
|
+
// Set up the resize listener to update views dynamically
|
|
93
|
+
this.resizeListener = this.applyView.bind(this);
|
|
94
|
+
window.addEventListener("resize", this.resizeListener);
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if (val !== undefined){ // 18/01/2025 13:10:11 Yes!!!
|
|
98
|
+
document.querySelector(val).appendChild(this.internalDiv);
|
|
99
|
+
}
|
|
100
|
+
// Return the internal div so it can be mounted manually
|
|
101
|
+
return this.internalDiv;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
createRanges(array, max = 99999) {
|
|
106
|
+
let ranges = [];
|
|
107
|
+
for (let i = 0; i < array.length; i++) {
|
|
108
|
+
ranges.push({
|
|
109
|
+
from: array[i],
|
|
110
|
+
to: (i < array.length - 1 ? array[i + 1] - 1 : max)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return ranges;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
addRanges(objects, rangeStarts, max = 99999) {
|
|
117
|
+
return objects.map((obj, index) => {
|
|
118
|
+
const from = rangeStarts[index];
|
|
119
|
+
const to = index < rangeStarts.length - 1 ? rangeStarts[index + 1] - 1 : max;
|
|
120
|
+
return {
|
|
121
|
+
...obj,
|
|
122
|
+
range: { from, to }
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
applyView() {
|
|
128
|
+
|
|
129
|
+
// check if we are in range
|
|
130
|
+
console.log("MAKE RANGES"); // 23:45:30 Thanks GPT!!!!
|
|
131
|
+
|
|
132
|
+
const width = window.innerWidth;
|
|
133
|
+
console.log(this.breakpoints);
|
|
134
|
+
console.log(this.breakpoints.map(el => el.at));
|
|
135
|
+
|
|
136
|
+
let rstart = this.breakpoints.map(el => el.at);
|
|
137
|
+
|
|
138
|
+
let mapped = this.breakpoints.map(el => el.at);
|
|
139
|
+
let transformed = this.createRanges(mapped);
|
|
140
|
+
let added = this.addRanges(this.breakpoints, rstart);
|
|
141
|
+
console.log(added);
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
added.forEach(r => {
|
|
145
|
+
const query = `(min-width: ${r.range.from}px) and (max-width: ${r.range.to}px)`;
|
|
146
|
+
const mediaQuery = window.matchMedia(query);
|
|
147
|
+
|
|
148
|
+
console.warn(query);
|
|
149
|
+
if (mediaQuery.matches) {
|
|
150
|
+
console.log(`Viewport width is within the range: ${r.range.from}px to ${r.range.to}px`);
|
|
151
|
+
// Add your logic for this range
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if (this.currentView !== r.view.render()) {
|
|
156
|
+
this.internalDiv.innerHTML = "";
|
|
157
|
+
this.internalDiv.appendChild(r.view.render());
|
|
158
|
+
this.currentView = r.view.render();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// if (window.matchMedia("(max-width"))
|
|
168
|
+
|
|
169
|
+
/* const matchingBreakpoint = this.breakpoints.reduce((prev, current) => {
|
|
170
|
+
return width >= current.at ? current : prev;
|
|
171
|
+
}, this.breakpoints[0]);*/
|
|
172
|
+
|
|
173
|
+
// console.log("MB");
|
|
174
|
+
// console.log(matchingBreakpoint);
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
//const width = window.innerWidth || document.documentElement.clientWidth;
|
|
178
|
+
console.log("MBO");
|
|
179
|
+
// Ensure `breakpoints` array is structured correctly
|
|
180
|
+
/*this.breakpoints = [
|
|
181
|
+
{ at: 0, view: "mobileView" },
|
|
182
|
+
{ at: 1200, view: "desktopView" }
|
|
183
|
+
];*/
|
|
184
|
+
|
|
185
|
+
// Find the matching breakpoint
|
|
186
|
+
/*const matchingBreakpoint = this.breakpoints.reduce((prev, current) => {
|
|
187
|
+
return width >= current.at ? current : prev;
|
|
188
|
+
}, this.breakpoints[0]);
|
|
189
|
+
*/
|
|
190
|
+
//console.log(matchingBreakpoint);
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
destroy() {
|
|
199
|
+
if (this.resizeListener) {
|
|
200
|
+
window.removeEventListener("resize", this.resizeListener);
|
|
201
|
+
this.resizeListener = null;
|
|
202
|
+
}
|
|
203
|
+
if (this.internalDiv && this.container) {
|
|
204
|
+
this.container.removeChild(this.internalDiv);
|
|
205
|
+
}
|
|
206
|
+
this.container = null;
|
|
207
|
+
this.currentView = null;
|
|
208
|
+
this.internalDiv = null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/*
|
|
213
|
+
// Example usage:
|
|
214
|
+
const switcher = new MultiSwitcher()
|
|
215
|
+
.set({
|
|
216
|
+
breakpoints: [
|
|
217
|
+
{ at: "0px", view: Object.assign(document.createElement("h1"), { textContent: "Small View" }) },
|
|
218
|
+
{ at: "700px", view: Object.assign(document.createElement("h1"), { textContent: "Medium View" }) },
|
|
219
|
+
{ at: "800px", view: Object.assign(document.createElement("h1"), { textContent: "Large View" }) },
|
|
220
|
+
],
|
|
221
|
+
})
|
|
222
|
+
.render("#myDiv");
|
|
223
|
+
*/
|
|
224
|
+
export { /*Multi*/Switcher };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class MultiSwitcherBeta {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.views = [];
|
|
6
|
+
this.container = null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
switchViews(views) {
|
|
10
|
+
this.views = views;
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render(selector) {
|
|
15
|
+
this.container = selector ? document.querySelector(selector) : document.createElement("div");
|
|
16
|
+
|
|
17
|
+
if (!this.container) {
|
|
18
|
+
console.error(`Container ${selector} not found`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Sort views by window width
|
|
23
|
+
this.views.sort((a, b) => parseInt(a.at) - parseInt(b.at));
|
|
24
|
+
|
|
25
|
+
// Add resize event listener
|
|
26
|
+
window.addEventListener('resize', this.updateView.bind(this));
|
|
27
|
+
|
|
28
|
+
// Initial render
|
|
29
|
+
this.updateView();
|
|
30
|
+
|
|
31
|
+
return this.container;
|
|
32
|
+
}
|
|
33
|
+
/*
|
|
34
|
+
updateView() {
|
|
35
|
+
const windowWidth = window.innerWidth;
|
|
36
|
+
|
|
37
|
+
for (let i = this.views.length - 1; i >= 0; i--) {
|
|
38
|
+
if (windowWidth >= parseInt(this.views[i].at)) {
|
|
39
|
+
// this.container.innerHTML = ''; // Clear current view
|
|
40
|
+
this.container.appendChild(this.views[i].view); // Set new view
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}*/
|
|
45
|
+
|
|
46
|
+
updateView() { // GPT 4o
|
|
47
|
+
const windowWidth = window.innerWidth;
|
|
48
|
+
|
|
49
|
+
for (let i = this.views.length - 1; i >= 0; i--) {
|
|
50
|
+
if (windowWidth >= parseInt(this.views[i].at)) {
|
|
51
|
+
if (this.container.firstChild !== this.views[i].view) {
|
|
52
|
+
if (this.container.firstChild) {
|
|
53
|
+
this.container.replaceChild(this.views[i].view, this.container.firstChild);
|
|
54
|
+
} else {
|
|
55
|
+
this.container.appendChild(this.views[i].view);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export { MultiSwitcherBeta };
|