@pernod-ricard-global-cms/jsutils 3.2.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jsutils.mjs +6 -20
- package/package.json +2 -3
package/jsutils.mjs
CHANGED
|
@@ -242,19 +242,6 @@ export function footerIntersection(entries, element) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
/**
|
|
246
|
-
* Dynamically retrieves the swiper css and js and returns a resolved promise when they have both been successfully fetched.
|
|
247
|
-
* @returns {promise}
|
|
248
|
-
*/
|
|
249
|
-
export function getSwiperAssetsV2(options = { css: "bundle" }) {
|
|
250
|
-
const getSwiperJs = () => import(/* webpackChunkName: 'swiper' */ "swiper");
|
|
251
|
-
|
|
252
|
-
const promisedJs = Promise.all([getSwiperJs()]).then((values) => {
|
|
253
|
-
return values;
|
|
254
|
-
});
|
|
255
|
-
return promisedJs;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
245
|
/**
|
|
259
246
|
* Dynamically retrieves the jQuery and returns a resolved promise when it has been successfully fetched.
|
|
260
247
|
* @returns {promise}
|
|
@@ -632,7 +619,10 @@ async function loadScript(src) {
|
|
|
632
619
|
* @param {object} event The click event object
|
|
633
620
|
*/
|
|
634
621
|
async function handleCTBClick(event) {
|
|
635
|
-
|
|
622
|
+
|
|
623
|
+
event.preventDefault();
|
|
624
|
+
|
|
625
|
+
if (!window.isCTBLoaded) {
|
|
636
626
|
const domain = window.location.hostname;
|
|
637
627
|
// Assuming PR-CLICKTOBUY plugin is enabled to make the script load
|
|
638
628
|
await loadScript(`/wp-content/plugins/pr-clicktobuy/public/js/pr-clicktobuy-public.js`);
|
|
@@ -640,12 +630,9 @@ async function handleCTBClick(event) {
|
|
|
640
630
|
|
|
641
631
|
// This is important!! Never remove this code
|
|
642
632
|
const clonedEvent = new event.constructor(event.type, event);
|
|
643
|
-
|
|
633
|
+
setTimeout(() => {
|
|
644
634
|
event.target.dispatchEvent(clonedEvent);
|
|
645
|
-
|
|
646
|
-
clearInterval(repeatEventInterval);
|
|
647
|
-
}
|
|
648
|
-
}, 100)
|
|
635
|
+
}, 500);
|
|
649
636
|
}
|
|
650
637
|
}
|
|
651
638
|
|
|
@@ -681,7 +668,6 @@ const api = {
|
|
|
681
668
|
getPosition,
|
|
682
669
|
getGsap,
|
|
683
670
|
getJquery,
|
|
684
|
-
getSwiperAssetsV2,
|
|
685
671
|
inCriticalCssConfig,
|
|
686
672
|
injectYouTubeIframeScript,
|
|
687
673
|
isEmailValid,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pernod-ricard-global-cms/jsutils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Handy collection of Javascript utility functions",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "jsutils.mjs",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"gsap": "^3.10.4",
|
|
22
22
|
"jquery": "^3.6.0",
|
|
23
|
-
"prettier": "^2.5.1"
|
|
24
|
-
"swiper": "^8.1.4"
|
|
23
|
+
"prettier": "^2.5.1"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
26
|
"cypress": "^10.5.0",
|