Skip to content

Commit 0d61df4

Browse files
committed
[Update] Addomg CMS functions and separating WF from non WF specific scripts
Added Functions: - Count Up - CMS Select Relocated Functions: - Hide Container - Tabs Slider Non specific change to CopyToClipboard, removed a space.
1 parent a5254d0 commit 0d61df4

5 files changed

Lines changed: 58 additions & 1 deletion

File tree

Dist/Functional/CopyToClipboard.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const UpdateTriggerDisplay = (_txt, _target, _trigger, _class ) => {
55
if(_target) _target.innerText = _txt;
66
else _trigger.innerHTML = _txt;
77
}
8-
98
if (_class) _trigger.classList.toggle(_class);
109
}
1110

Dist/Functional/CountUp.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict'
2+
3+
const InitializeCountUp = () => {
4+
let counters = document.querySelectorAll("[wt-countup-element='counter']");
5+
6+
if(!counters || counters.length === 0) return;
7+
8+
for(let c of counters) {
9+
let target = c.getAttribute("wt-countup-target") || 0;
10+
if (!target) return;
11+
let prefix = c.getAttribute("wt-countup-prefix") || "";
12+
let suffix = c.getAttribute("wt-countup-suffix") || "";
13+
let step = +c.getAttribute("wt-countup-step");
14+
let speed = +c.getAttribute("wt-countup-speed") || 10;
15+
let v = 0;
16+
17+
let counterUp = () => {
18+
c.innerHTML = `${prefix}${v}${suffix}`;
19+
if (step) v += step;
20+
else v++;
21+
if (v > target) clearInterval(stop);
22+
}
23+
24+
let stop = setInterval(() => {
25+
try {
26+
counterUp();
27+
} catch (err) {
28+
clearInterval(stop);
29+
}
30+
}, speed);
31+
}
32+
};
33+
34+
window.addEventListener("DOMContentLoaded", InitializeCountUp());

Dist/WebflowOnly/CMSSelect.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict'
2+
3+
const InitializeCMSSelect = () => {
4+
5+
const selectElements = document.querySelectorAll('[wt-cmsselect-element^="select-"], [wt-cmsselect-element="select"]');
6+
7+
if(!selectElements || selectElements.length === 0) return;
8+
9+
for(let select of selectElements){
10+
const _sel = select.getAttribute('wt-cmsselect-element');
11+
let index = _sel.replace('select','');
12+
let _opts = document.querySelectorAll(`[wt-cmsselect-element="target${index}"]`);
13+
14+
for(let opt of _opts) {
15+
let val = opt.getAttribute('wt-cmsselect-value');
16+
let text = opt.innerText;
17+
18+
if(text && text !== "")
19+
select.add( new Option(text, (val ? val : text)))
20+
}
21+
}
22+
}
23+
24+
window.addEventListener('DOMContentLoaded', InitializeCMSSelect());

0 commit comments

Comments
 (0)