@commversion/libs 0.16.3 → 0.16.4
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/README.md
CHANGED
|
@@ -9,7 +9,7 @@ The library is distributed as a public facing npm package.
|
|
|
9
9
|
The recommended way to install this on a website is through JsDelivr.com.
|
|
10
10
|
|
|
11
11
|
```html
|
|
12
|
-
<script src="https://
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/npm/@commversion/libs@version/dist/schedule-event.js"></script>
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
### Configuration
|
|
@@ -28,6 +28,9 @@ Configuration takes place by global `window.commversion` object, make sure to no
|
|
|
28
28
|
All scripts are available under the `scripts/` directory.
|
|
29
29
|
|
|
30
30
|
- schedule-event
|
|
31
|
+
- lc-open-on-button-click
|
|
32
|
+
- lc-cookie-banner-update-position
|
|
33
|
+
- lc-show-by-selector
|
|
31
34
|
- lc-exit-intent-debounced
|
|
32
35
|
- lc-pause-on-url
|
|
33
36
|
- lc-kill-chat-persist
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function r(e){const t=document.querySelector(e.chatWidgetSelector),o=document.querySelector(e.bannerSelector);if(t){const i=o&&(e.bannerHiddenClass?!o.classList.contains(e.bannerHiddenClass):o.offsetParent!==null),c=i?e.bottomOffset:"0px";let n=document.getElementById("chat-widget-style");n||(n=document.createElement("style"),n.id="chat-widget-style",document.head.appendChild(n)),n.innerHTML=`${e.chatWidgetSelector} { bottom: ${c} !important; transition: bottom 0.5s ease-in-out; }`,console.log(`Chat widget realigned: ${i?"Above banner":"Bottom"}`)}else console.warn("Chat widget not found.")}function s(e,t=0){const o=document.querySelector(e.chatWidgetSelector),i=document.querySelector(e.bannerSelector),c=e.cookieBannerMaxRetries;o&&i?(console.log("Cookie banner detected. Aligning chat widget..."),r(e),e.buttonSelectors.forEach((n,l)=>{const a=document.querySelector(n);a&&!a.__listenerAdded&&(console.log(`Adding event listener to button ${l+1} (${n})...`),a.addEventListener("click",()=>{console.log(`Button clicked: ${n}`),setTimeout(()=>r(e),500)}),a.__listenerAdded=!0)})):t<c?(console.log(`Retrying to find cookie banner... Attempt ${t+1}`),setTimeout(()=>s(e,t+1),250)):console.warn("Max retries reached. Cookie banner not found.")}function d(e={}){const t=e.cookieBannerConfig||{},o={chatWidgetSelector:t.chatWidgetSelector||"#chat-widget-container",bannerSelector:t.bannerSelector||".cookie-banner",bannerHiddenClass:t.bannerHiddenClass||null,bottomOffset:t.bottomOffset||"80px",buttonSelectors:t.buttonSelectors||[],cookieBannerMaxRetries:typeof t.cookieBannerMaxRetries=="number"?t.cookieBannerMaxRetries:5};console.log("LiveChatWidget is ready. Initializing chat widget alignment..."),s(o)}window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",d(window.commversion))})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const d=u=>{const{exitIntentDebounceMs:l=
|
|
1
|
+
(function(){"use strict";const d=u=>{const{exitIntentDebounceMs:l=1500,exitIntentMargin:n=0}=u,{LiveChatWidget:s}=window;let i=!0,e=null;function r(t,c){const o=window.innerWidth,a=window.innerHeight;return t>=n&&t<=o-n&&c>=n&&c<=a-n}document.addEventListener("mousemove",t=>{r(t.clientX,t.clientY)?(i||(i=!0,console.log("[lc-exit-intent-debounced] Mouse re-entered inner screen, resetting exit_intent to false"),s.call("update_session_variables",{exit_intent:"false"})),e&&(console.log("[lc-exit-intent-debounced] Mouse re-entered before debounce, clearing exit intent timer"),clearTimeout(e),e=null)):i&&(i=!1,console.log(`[lc-exit-intent-debounced] Mouse left inner screen, starting debounce timer (${l}ms)`),e=setTimeout(()=>{const{status:o}=s.get("customer_data");o==="browsing"?(console.log("[lc-exit-intent-debounced] Debounce elapsed, setting exit_intent to true"),s.call("update_session_variables",{exit_intent:"true"})):console.log(`[lc-exit-intent-debounced] Debounce elapsed, but status is not 'browsing' (status: ${o}), not setting exit_intent`),e=null},l))})};window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",d(window.commversion))})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function a(t){t.openOnIds.forEach(e=>{const n=document.getElementById(e);n&&!n.__liveChatListenerAdded&&(console.log(`Adding LiveChat click listener to element with ID: ${e}`),n.addEventListener("click",i=>{console.log(`Button clicked (ID: ${e}), opening LiveChat...`),l()}),n.__liveChatListenerAdded=!0)}),t.openOnClasses.forEach(e=>{const n=document.getElementsByClassName(e);Array.from(n).forEach((i,o)=>{i.__liveChatListenerAdded||(console.log(`Adding LiveChat click listener to element ${o+1} with class: ${e}`),i.addEventListener("click",s=>{console.log(`Button clicked (class: ${e}), opening LiveChat...`),l()}),i.__liveChatListenerAdded=!0)})})}function l(){window.LiveChatWidget?(window.LiveChatWidget.call("maximize"),console.log("LiveChat widget opened/maximized")):console.warn("LiveChat widget not available")}function c(t,e=0){const n=[],i=t.openOnButtonMaxRetries;t.openOnIds.forEach(o=>{document.getElementById(o)&&n.push(`#${o}`)}),t.openOnClasses.forEach(o=>{const s=document.getElementsByClassName(o);s.length>0&&n.push(`.${o} (${s.length} elements)`)}),n.length>0?(console.log(`Elements found for LiveChat triggers: ${n.join(", ")}`),a(t)):e<i?(console.log(`Retrying to find trigger elements... Attempt ${e+1}`),setTimeout(()=>c(t,e+1),250)):console.warn("Max retries reached. No trigger elements found for LiveChat.")}function d(t={}){const e=t.openOnButtonConfig||{},n={openOnIds:e.openOnIds||[],openOnClasses:e.openOnClasses||[],openOnButtonMaxRetries:typeof e.openOnButtonMaxRetries=="number"?e.openOnButtonMaxRetries:0};if(n.openOnIds.length===0&&n.openOnClasses.length===0){console.warn("No IDs or classes configured for LiveChat open-on-button-click functionality");return}console.log("LiveChatWidget is ready. Initializing open-on-button-click functionality..."),c(n)}window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",()=>d(window.commversion))})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function l(o){try{const{LiveChatWidget:e}=window;var c=e.get("customer_data");if(c&&c.status==="chatting"){console.info("Customer is already chatting.");return}const{showOnIds:i=[],showOnClasses:a=[]}=o;if(Array.isArray(i))for(var n=0;n<i.length;n++){var t=i[n];if(t&&document.getElementById(t)){console.info("Element with showOnId found:",t);return}}if(Array.isArray(a))for(var r=0;r<a.length;r++){var s=a[r];if(s&&document.getElementsByClassName(s).length>0){console.info("Element with showOnClass found:",s);return}}console.info("Destroying LiveChat because no showOnId or showOnClass elements found."),e.call("destroy")}catch(e){LiveChatWidget.call("destroy"),console.error("Destroying LiveChat because we got an error.",e)}}const d=o=>()=>{l(o)};window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",d(window.commversion))})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commversion/libs",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"author": "Marios Antonoudiou <mariosant@sent.com>",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"test": "wtr ./scripts/**/*.test.js --node-resolve",
|
|
10
10
|
"prepack": "concurrently npm:build:*",
|
|
11
11
|
"release": "release-it",
|
|
12
|
+
"dev:lc-open-on-button-click": "vite serve scripts/lc-open-on-button-click/src/",
|
|
13
|
+
"build:lc-open-on-button-click": "vite build -c scripts/lc-open-on-button-click/vite.config.js",
|
|
14
|
+
"dev:lc-cookie-banner-update-position": "vite serve scripts/lc-cookie-banner-update-position/src/",
|
|
15
|
+
"build:lc-cookie-banner-update-position": "vite build -c scripts/lc-cookie-banner-update-position/vite.config.js",
|
|
16
|
+
"dev:lc-show-by-selector": "vite serve scripts/lc-show-by-selector/src/",
|
|
17
|
+
"build:lc-show-by-selector": "vite build -c scripts/lc-show-by-selector/vite.config.js",
|
|
12
18
|
"dev:lc-exit-intent-debounced": "vite serve scripts/lc-exit-intent-debounced/src/",
|
|
13
19
|
"build:lc-exit-intent-debounced": "vite build -c scripts/lc-exit-intent-debounced/vite.config.js",
|
|
14
20
|
"dev:lc-pause-on-url": "vite serve scripts/lc-pause-on-url/src/",
|