Skip to content

Commit 4dc567b

Browse files
committed
refactor: updating scripts initialization and updating future update to turn into classes instead of functions.
1 parent 619e154 commit 4dc567b

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

Dist/Functional/FormCheck.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,17 @@ class FormCheck {
112112
}
113113
}
114114

115-
document.addEventListener('DOMContentLoaded', () => {
115+
const initializeFormCheck = () => {
116+
window.trickeries = window.trickeries || [];
116117
const forms = document.querySelectorAll('[wt-formcheck-element="form"]');
117-
forms.forEach(form => new FormCheck(form));
118-
});
118+
forms.forEach(form => {
119+
let instance = new FormCheck(form);
120+
window.trickeries.push({'formCheck': instance});
121+
});
122+
}
123+
124+
if (/complete|interactive|loaded/.test(document.readyState)) {
125+
initializeFormCheck();
126+
} else {
127+
window.addEventListener('DOMContentLoaded', initializeFormCheck)
128+
}

Dist/Functional/FormatNumbers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,8 @@ const InitializeFormatNumbers = () => {
6868
}
6969
}
7070

71-
window.addEventListener('DOMContentLoaded', InitializeFormatNumbers());
71+
if (/complete|interactive|loaded/.test(document.readyState)) {
72+
InitializeFormatNumbers();
73+
} else {
74+
window.addEventListener('DOMContentLoaded', InitializeFormatNumbers)
75+
}

Dist/Functional/LimitText.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ const LimitText = () => {
1616
}
1717
}
1818

19-
window.addEventListener('DOMContentLoaded', LimitText());
19+
if (/complete|interactive|loaded/.test(document.readyState)) {
20+
LimitText();
21+
} else {
22+
window.addEventListener('DOMContentLoaded', LimitText)
23+
}

0 commit comments

Comments
 (0)