Skip to content

Commit 001a2af

Browse files
authored
Merge pull request #1 from TheCodeRaccoons/main
[Update] added the features to Develop for a pre-release
2 parents 037752f + 7d6a091 commit 001a2af

7 files changed

Lines changed: 133 additions & 25 deletions

File tree

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
ko_fi: thecoderaccon

Dist/Functional/CopyToClipboard.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
/*
2-
* Trigger element = wt-copycb-element="trigger"
3-
* Target element = wt-copycb-element="target"
4-
* textTarget = wt-copycb-element="textTarget"
5-
* copiedMsg = wt-copycb-copiedMsg
6-
* activeClass = wt-copycb-activeClass
7-
*/
8-
91
'use strict'
102

113
const UpdateTriggerDisplay = (_txt, _target, _trigger, _class ) => {
124
if (_txt){
135
if(_target) _target.innerText = _txt;
146
else _trigger.innerHTML = _txt;
157
}
16-
178
if (_class) _trigger.classList.toggle(_class);
189
}
1910

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/Functional/FormatNumbers.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Number formating using Intl.NumberFormat.
3+
* Requirements:
4+
* Element with custom attribute fn-formatnumber="true"
5+
* A Style in the same element to format choosing between "Currency", "decimal", "percent", "unit"
6+
* In case of the element being "Currency" or "Unit" the sent "fn-formatnumber-currency" or "fn-formatnumber-unit" option
7+
* Optional: set locales for the formatting
8+
* list of units can be found here for now: https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier
9+
* currency uses regular notation for them.
10+
*/
11+
12+
13+
let FormatNo = (element, locales, number, options) => {
14+
let final = Intl.NumberFormat(locales, options).format(number);
15+
if (!final) return;
16+
element.innerHTML = final;
17+
}
18+
const InitializeFormatNumbers = () => {
19+
let numbersToFormat = document.querySelectorAll('[wt-formatnumber-element="number"]');
20+
21+
if(!numbersToFormat || numbersToFormat.length === 0) return;
22+
23+
for(let numberContainer of numbersToFormat) {
24+
let locales = numberContainer.getAttribute("wt-formatnumber-locales");
25+
let style = numberContainer.getAttribute("wt-formatnumber-style");
26+
let currency = numberContainer.getAttribute("wt-formatnumber-currency");
27+
let unit = numberContainer.getAttribute("wt-formatnumber-unit");
28+
let options = null;
29+
30+
if (style) {
31+
switch (style) {
32+
case 'currency':
33+
if (!currency) return;
34+
options = {
35+
style: style,
36+
currency: currency
37+
}
38+
break;
39+
case 'decimal':
40+
options = {
41+
style: style
42+
};
43+
break;
44+
case 'percent':
45+
options = {
46+
style: style
47+
};
48+
break;
49+
case 'unit':
50+
options = {
51+
style: style,
52+
unit: unit
53+
};
54+
break;
55+
default:
56+
console.log(`undefined`);
57+
}
58+
}
59+
60+
let value = numberContainer.textContent
61+
if (!value) return;
62+
63+
try {
64+
FormatNo(numberContainer, locales, value, options);
65+
} catch (error) {
66+
numberContainer.innerHTML = `there was an error processing the format, ${error}`;
67+
}
68+
}
69+
}
70+
71+
window.addEventListener('DOMContentLoaded', InitializeFormatNumbers())

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());
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
/*!
2-
* Webflow Utilities v1.2.0
3-
* Have you ever tried fixing the same small thing over and over again on your webflow projects?
4-
* Well I have so I made a small compillation of the different fixes, utilities and tricks that will
5-
* not only make my life easier in the future but hopefuly yours as well.
6-
* (c) 2023 Jorge Cortez
7-
* MIT License
8-
* https://github.com/JorchCortez/Weblfow-Trickery
9-
*
10-
* This code is a sligtly modified version of the Auto Rotate Webflow Tabs by Flowbase.co (v1.4 Updated 10/04/2023)
11-
* fixed for reusability in any project using attributes instead of classes, feel free to check it out and if needs any update
12-
* you can open an issue in github.
13-
*
14-
* Webflow only function
15-
*
16-
*/
1+
'use strict'
172

183
var Webflow = Webflow || [];
194
Webflow.push(function () {

0 commit comments

Comments
 (0)