Skip to content

Commit bd62e46

Browse files
committed
[Fix] Updates to Hide container and limit text
1 parent 0e73034 commit bd62e46

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

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)