Skip to content

Commit d14564d

Browse files
authored
Merge pull request #10 from TheCodeRaccoons/New-Feature--Added-Scripts
New feature added scripts
2 parents f98e1ae + bd62e46 commit d14564d

4 files changed

Lines changed: 17 additions & 31 deletions

File tree

Dist/Functional/CountUp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const InitializeCountUp = () => {
1010
if (!target) return;
1111
let prefix = c.getAttribute("wt-countup-prefix") || "";
1212
let suffix = c.getAttribute("wt-countup-suffix") || "";
13-
let step = +c.getAttribute("wt-countup-step");
13+
let step = +c.getAttribute("wt-countup-step") || 1 ;
1414
let speed = +c.getAttribute("wt-countup-speed") || 10;
1515
let v = 0;
1616

Dist/Functional/DateCountDown.js renamed to Dist/Functional/Experimental/DateCountDown.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const InitializeDateCountDown = () => {
1414

1515
if (!isDateValid(countDownDate)) return;
1616

17-
// Update the count down every 1 second
1817
var x = setInterval(function () {
1918

2019
// Get today's date and time
@@ -29,17 +28,18 @@ const InitializeDateCountDown = () => {
2928
document.getElementById("demo").innerHTML = "EXPIRED";
3029
}
3130

32-
const _targetYear = document.querySelector('[wt-datecount-element="target-year"]');
33-
const _targetMonth = document.querySelector('[wt-datecount-element="target-month"]');
34-
const _targetDay = document.querySelector('[wt-datecount-element="target-day"]');
35-
const _targetHour = document.querySelector('[wt-datecount-element="target-hour"]');
36-
const _targetMin = document.querySelector('[wt-datecount-element="target-minute"]');
37-
const _targetSec = document.querySelector('[wt-datecount-element="target-second"]');
31+
const _targetYear = document.querySelector('[wt-datecount-element="target-year"]');
32+
const _targetMonth = document.querySelector('[wt-datecount-element="target-month"]');
33+
const _targetDay = document.querySelector('[wt-datecount-element="target-day"]');
34+
const _targetHour = document.querySelector('[wt-datecount-element="target-hour"]');
35+
const _targetMin = document.querySelector('[wt-datecount-element="target-minute"]');
36+
const _targetSec = document.querySelector('[wt-datecount-element="target-second"]');
3837

3938
// Time calculations for days, hours, minutes and seconds
4039
var year = Math.floor(distance / (1000 * 60 * 60 * 24));
4140
var month = Math.floor(distance / (1000 * 60 * 60 * 24));
4241
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
42+
4343
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
4444
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
4545
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
@@ -53,3 +53,5 @@ const InitializeDateCountDown = () => {
5353

5454
}, 1000);
5555
}
56+
57+
window.addEventListener('DOMContentLoaded', InitializeDateCountDown());

Dist/Functional/LimitText.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
'use strict'
22

33
const LimitText = () => {
4-
let _fullText = document.querySelectorAll('[wt-limittext-element="text"]');
4+
let _fullText = document.querySelectorAll('[wt-limittext-element^="text-"], [wt-limittext-element="text"]');
55

66
if(!_fullText || _fullText.length === 0) return;
77

88
for (text of _fullText) {
99
let suffix = text.getAttribute("wt-limittext-suffix") || null;
10-
let textLength = text.getAttribute("wt-limittext-length") || 300 ;
11-
let description = text.innerText;
12-
if (description.length > textLength) {
13-
var _substr = `${description.substring(0, textLength)} ${ suffix ? suffix : "..."}`;
10+
let textLength = +text.getAttribute("wt-limittext-length") || 300 ;
11+
let txtContent = text.innerText;
12+
if (txtContent.length > textLength) {
13+
var _substr = `${txtContent.substring(0, textLength)} ${ suffix ? suffix : "..."}`;
1414
text.innerText = _substr;
1515
}
1616
}

Dist/WebflowOnly/HideContainer.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
'use strict'
22

33
const SetHideContainers = () => {
4-
let containers = document.querySelectorAll('[wt-hidecontainer-element^="container-"], [wt-hidecontainer-element="container"]');
5-
let err = [];
6-
let valid = true;
4+
let containers = document.querySelectorAll('[wt-hidecontainer-element="container"], [wt-hidecontainer-element^="container-"]');
75

8-
if(!containers || containers.length === 0) {
9-
err.push(`%cThere are no containers in this page.`);
10-
valid = false;
11-
}
12-
13-
if (!valid) {
14-
console.log("%cThanks for using Webflow Trickery","color: blue; font-size: 18px; padding: 8px; font-weight:500");
15-
console.log("%cIt seems like you're missing an element that is required for the integration.","color: red; font-size: 12px; padding: 8px; font-weight:500");
16-
for(let e of err){
17-
console.log(e,"color: red; font-size: 12px; padding: 8px; font-weight:500")
18-
}
19-
return;
20-
}
6+
if(!containers || containers.length === 0) return;
217

228
for(let _container of containers) {
239
let _cmsList = _container.querySelector('[wt-hidecontainer-element="list"]');
@@ -33,5 +19,3 @@ const SetHideContainers = () => {
3319
}
3420
}
3521
}
36-
37-
window.addEventListener('DOMContentLoaded', SetHideContainers());

0 commit comments

Comments
 (0)