@commversion/libs 0.17.8 → 0.17.10
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/dist/lc-show-hide.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const s=e=>({rule:o,value:n})=>{const{href:t}=e.location;if(o==="contains")return t.includes(n);if(o==="equals")return t===n;throw new Error(`Wrong rule: ${o}: ${n}`)},
|
|
1
|
+
(function(){"use strict";const s=e=>({rule:o,value:n})=>{const{href:t}=e.location;if(o==="contains")return t.includes(n);if(o==="equals")return t===n;throw new Error(`Wrong rule: ${o}: ${n}`)},d=(e,o)=>!e.some(s(o)),c=(e,o)=>e.some(s(o)),h=e=>{const o=new RegExp(e),{pathname:n}=window.location;return!o.test(n)},l=(e,o)=>{const n=new RegExp(e),{pathname:t}=o.location;return n.test(t)},u=["browsing"],a=e=>e.show&&e.hide?{predicateFn:()=>console.error("Cannot set both show and hide configuration. Please choose one.")}:typeof e.show=="string"?{predicateFn:h,pluginConfiguration:e.show}:typeof e.show=="object"?{predicateFn:d,pluginConfiguration:e.show}:typeof e.hide=="string"?{predicateFn:l,pluginConfiguration:e.hide}:typeof e.hide=="object"?{predicateFn:c,pluginConfiguration:e.hide}:{predicateFn:()=>console.error("No configuration for show/hide script.")},w=e=>({customerData:o})=>{const{LiveChatWidget:n}=window,{predicateFn:t,pluginConfiguration:i}=a(e);if(t(i,window)&&u.includes(o.status)){n.call("hide");const r=document.getElementById("chat-overlay-container");r&&(r.style.display="none")}};window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",w(window.commversion))})();
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
(function(){"use strict";const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
bottom: 1rem;
|
|
1
|
+
(function(){"use strict";const x="screen and (max-width: 992px) and (pointer: coarse)",S=()=>window.matchMedia(x).matches?"mobile":"desktop",u="#chat-overlay-container",y="#chat-overlay-button";function m(){if(document.getElementById("lc-whatsapp-style"))return;const t=document.createElement("style");t.id="lc-whatsapp-style",t.textContent=`
|
|
2
|
+
/* WA circle \u2014 shared base styles */
|
|
3
|
+
.lc-whatsapp-wrapper {
|
|
5
4
|
z-index: 2147483640;
|
|
6
5
|
cursor: pointer;
|
|
7
6
|
pointer-events: auto;
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
position: absolute;
|
|
8
|
+
width: 40px;
|
|
9
|
+
height: 40px;
|
|
10
10
|
background: #25D366;
|
|
11
11
|
display: flex;
|
|
12
12
|
justify-content: center;
|
|
13
13
|
align-items: center;
|
|
14
14
|
border-radius: 50%;
|
|
15
|
+
/* Hidden until JS sets the correct size \u2014 avoids a one-frame wrong-size paint */
|
|
16
|
+
visibility: hidden;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.lc-whatsapp-wrapper.lc-wa-ready {
|
|
21
|
+
visibility: visible;
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
.lc-whatsapp-icon {
|
|
18
25
|
display: block;
|
|
26
|
+
width: 50%;
|
|
27
|
+
height: 50%;
|
|
28
|
+
object-fit: contain;
|
|
19
29
|
}
|
|
20
|
-
`,document.head.appendChild(t)}function
|
|
30
|
+
`,document.head.appendChild(t)}function f(t){if(t.style.right&&t.style.right!=="auto")return"right";if(t.style.left&&t.style.left!=="auto")return"left";const s=window.getComputedStyle(t);return s.right!=="auto"?"right":s.left!=="auto"?"left":"right"}function w(t,s){const e=document.createElement("img");e.className="lc-whatsapp-icon",e.alt="WhatsApp",e.src="data:image/svg+xml;utf8,"+encodeURIComponent('<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 509 511.514"><path fill="#fff" d="M434.762 74.334C387.553 26.81 323.245 0 256.236 0h-.768C115.795.001 2.121 113.696 2.121 253.456l.001.015a253.516 253.516 0 0033.942 126.671L0 511.514l134.373-35.269a253.416 253.416 0 00121.052 30.9h.003.053C395.472 507.145 509 393.616 509 253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555 464.453c-37.753 0-74.861-10.22-107.293-29.479l-7.72-4.602-79.741 20.889 21.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308 0-116.371 94.372-210.743 210.741-210.743 56.011 0 109.758 22.307 149.277 61.98a210.93 210.93 0 0161.744 149.095c0 116.44-94.403 210.869-210.844 210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315 3.203-4.305 6.404-16.373 20.593-20.063 24.855-3.69 4.263-7.401 4.815-13.679 1.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748 192.748 0 01-35.411-43.867c-3.712-6.363-.404-9.777 2.82-12.873 3.224-3.096 6.363-7.381 9.48-11.092a41.58 41.58 0 006.357-10.597 11.678 11.678 0 00-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322 23.322 0 00-16.964 7.911c-5.707 6.298-22.1 21.673-22.1 52.849s22.671 61.249 25.852 65.532c3.182 4.284 44.663 68.227 108.288 95.649 15.099 6.489 26.891 10.392 36.053 13.403a87.504 87.504 0 0025.216 3.718c4.905 0 9.82-.416 14.65-1.237 12.174-1.782 37.453-15.291 42.776-30.073s5.303-27.57 3.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z"/></svg>');const o=document.createElement("div");return o.className="lc-whatsapp-wrapper",o.onclick=function(){const n=s==="mobile"?`https://wa.me/${t}`:`https://web.whatsapp.com/send?phone=${t}`;window.open(n,"_blank","noopener,noreferrer")},o.appendChild(e),{waDiv:o}}function g(t){const s=document.querySelector(u);if(!s)return!1;if(s.querySelector(".lc-whatsapp-wrapper"))return!0;m();const{waDiv:e}=w(t.number,t.deviceType);e.style.position="absolute";const o=f(s);t.deviceType==="mobile"?(e.style.top="100%",e.style.marginTop="-10px",o==="left"?(e.style.left="10px",e.style.right="auto"):(e.style.right="10px",e.style.left="auto")):(e.style.top="50%",e.style.transform="translateY(-50%)",o==="left"?(e.style.left="100%",e.style.marginLeft="8px",e.style.right="auto"):(e.style.right="100%",e.style.marginRight="8px",e.style.left="auto"));const n=l=>{const c=new ResizeObserver(()=>{const d=Math.round(l.getBoundingClientRect().height);if(d===0)return;const r=Math.min(Math.max(d,40),64);e.style.width=r+"px",e.style.height=r+"px",e.classList.add("lc-wa-ready"),c.disconnect()});c.observe(l)};s.appendChild(e);const i=document.querySelector(y);return i?n(i):a(y,l=>n(l),{interval:300,maxRetries:130}),!0}function v(t){const{deviceType:s}=t,e=document.querySelector(t.chatWidgetSelector);if(!e||(e.style.overflow="unset",m(),e.querySelector(".lc-whatsapp-wrapper")))return;const n=f(e)==="left",{waDiv:i}=w(t.number,s);e.appendChild(i);const l="#chat-widget-minimized",c=e.querySelector(l)||document.querySelector(l),d=r=>{if(!r)return;new ResizeObserver(()=>{const h=Math.round(r.getBoundingClientRect().width);if(h===0){s==="mobile"?i.style.display="none":(i.style.width="40px",i.style.height="40px",i.classList.add("lc-wa-ready"));return}i.style.display="flex";let p=20;h===84?p=30:h>100&&(p=20),s==="mobile"&&(i.style.bottom=p===30?"-50px":"-25px"),i.style.width=`${p*2}px`,i.style.height=`${p*2}px`,i.classList.add("lc-wa-ready")}).observe(r)};c?d(c):a(l,r=>d(r),{interval:300,maxRetries:130}),t.deviceType==="mobile"?n?(i.style.left=t.mobile.left,i.style.right="auto"):(i.style.right=t.mobile.right,i.style.left="auto"):(i.style.bottom=t.desktop.bottom,n?(i.style.right=t.desktop.right,i.style.left="auto"):(i.style.left=t.desktop.left,i.style.right="auto"))}function a(t,s,{interval:e=300,maxRetries:o=100}={}){let n=0;const i=setInterval(()=>{const l=document.querySelector(t);if(l){clearInterval(i),s(l);return}++n>=o&&clearInterval(i)},e)}let b=!1;function C(t={}){const s=t.whatsappConfig||{},e={enabled:!1,left:"8px",right:"8px"},o={enabled:!1,bottom:"-100px",left:"-43px",right:"-43px"},n={chatWidgetSelector:s.chatWidgetSelector||"#chat-widget-container",number:s.number||"",mobile:Object.assign({},e,s.mobile),desktop:Object.assign({},o,s.desktop)},i=S(),l=n[i];n.deviceType=i,l!=null&&l.enabled&&(a(u,()=>g(n)),a(n.chatWidgetSelector,()=>v(n)),b||(b=!0,document.addEventListener("turbolinks:load",()=>{a(u,()=>g(n)),a(n.chatWidgetSelector,()=>v(n))})))}window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",C(window.commversion))})();
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
(function(){"use strict";const
|
|
1
|
+
(function(){"use strict";const w="screen and (max-width: 992px) and (pointer: coarse)",s=()=>window.matchMedia(w).matches?"mobile":"desktop";function u(i){var d,l,p,m;if(document.getElementById("wa-widget-style"))return;const e=i.position,n=e.position==="left"?"left":"right",t=(d=e[n])!=null?d:0,o=(l=i.size)!=null?l:48,c=document.createElement("style");c.id="wa-widget-style",c.textContent=`
|
|
2
2
|
.wa-widget-wrapper {
|
|
3
3
|
position: fixed;
|
|
4
|
-
bottom: ${(
|
|
4
|
+
bottom: ${(p=e.bottom)!=null?p:0}px;
|
|
5
5
|
${n}: ${t}px;
|
|
6
6
|
${n==="left"?"right: auto;":"left: auto;"}
|
|
7
|
-
z-index: ${(
|
|
7
|
+
z-index: ${(m=e.zIndex)!=null?m:9999};
|
|
8
8
|
|
|
9
|
-
width: ${
|
|
10
|
-
height: ${
|
|
9
|
+
width: ${o}px;
|
|
10
|
+
height: ${o}px;
|
|
11
11
|
border-radius: 50%;
|
|
12
|
-
|
|
12
|
+
background: #25D366;
|
|
13
|
+
|
|
13
14
|
display: flex;
|
|
14
15
|
align-items: center;
|
|
15
16
|
justify-content: center;
|
|
@@ -18,6 +19,9 @@
|
|
|
18
19
|
|
|
19
20
|
.wa-widget-icon {
|
|
20
21
|
pointer-events: none;
|
|
22
|
+
display: block;
|
|
23
|
+
width: 50%;
|
|
24
|
+
height: 50%;
|
|
25
|
+
object-fit: contain;
|
|
21
26
|
}
|
|
22
|
-
`,document.head.appendChild(
|
|
23
|
-
<svg fill="#05e896" width="800px" height="800px" viewBox="0 0 24 24" id="whatsapp" data-name="Flat Color" xmlns="http://www.w3.org/2000/svg" class="icon flat-color"><path id="primary" d="M19.07,4.93A10,10,0,0,0,3,16.26L2,20.8a1,1,0,0,0,.27.91A1,1,0,0,0,3.2,22L7.74,21A9.89,9.89,0,0,0,12,22a10.61,10.61,0,0,0,1.85-.17,10,10,0,0,0,5.22-16.9Z" style="fill: #05e896;"></path><path id="secondary" d="M15.68,17a7,7,0,0,1-3-.74l-.16-.08a10.69,10.69,0,0,1-2.71-2,10.52,10.52,0,0,1-2-2.71l-.08-.16A6.36,6.36,0,0,1,7,7.84,1,1,0,0,1,8,7H9.81a1,1,0,0,1,1,.72l.4,1.4a1,1,0,0,1-.25,1l-1,1a9.8,9.8,0,0,0,1.32,1.65,9.42,9.42,0,0,0,1.65,1.32l1-1a1,1,0,0,1,1-.25l1.4.4a1,1,0,0,1,.72,1V16a1,1,0,0,1-.84,1A4.2,4.2,0,0,1,15.68,17Z" style="fill: #fff;"></path></svg>`),n.appendChild(t),document.body.appendChild(n)}function h(o={}){const e=o.whatsapp;if(!(e!=null&&e.phone_number))return;const n=s(),t=e[n];!(t!=null&&t.enabled)||!t.position||w(e.phone_number,t)}window.commversion=window.commversion||{},h(window.commversion)})();
|
|
27
|
+
`,document.head.appendChild(c)}function r(i,e){if(document.querySelector(".wa-widget-wrapper"))return;const n=document.getElementById("wa-widget-style");n&&n.remove(),u(e);const t=document.createElement("div");t.className="wa-widget-wrapper",t.onclick=()=>{const c=s()==="mobile"?`https://wa.me/${i}`:`https://web.whatsapp.com/send?phone=${i}`;window.open(c,"_blank","noopener,noreferrer")};const o=document.createElement("img");o.className="wa-widget-icon",o.alt="WhatsApp",o.src="data:image/svg+xml;utf8,"+encodeURIComponent('<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 509 511.514"><path fill="#fff" d="M434.762 74.334C387.553 26.81 323.245 0 256.236 0h-.768C115.795.001 2.121 113.696 2.121 253.456l.001.015a253.516 253.516 0 0033.942 126.671L0 511.514l134.373-35.269a253.416 253.416 0 00121.052 30.9h.003.053C395.472 507.145 509 393.616 509 253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555 464.453c-37.753 0-74.861-10.22-107.293-29.479l-7.72-4.602-79.741 20.889 21.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308 0-116.371 94.372-210.743 210.741-210.743 56.011 0 109.758 22.307 149.277 61.98a210.93 210.93 0 0161.744 149.095c0 116.44-94.403 210.869-210.844 210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315 3.203-4.305 6.404-16.373 20.593-20.063 24.855-3.69 4.263-7.401 4.815-13.679 1.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748 192.748 0 01-35.411-43.867c-3.712-6.363-.404-9.777 2.82-12.873 3.224-3.096 6.363-7.381 9.48-11.092a41.58 41.58 0 006.357-10.597 11.678 11.678 0 00-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322 23.322 0 00-16.964 7.911c-5.707 6.298-22.1 21.673-22.1 52.849s22.671 61.249 25.852 65.532c3.182 4.284 44.663 68.227 108.288 95.649 15.099 6.489 26.891 10.392 36.053 13.403a87.504 87.504 0 0025.216 3.718c4.905 0 9.82-.416 14.65-1.237 12.174-1.782 37.453-15.291 42.776-30.073s5.303-27.57 3.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z"/></svg>'),t.appendChild(o),document.body.appendChild(t)}let a=!1;function g(i={}){const e=i.whatsapp;if(!(e!=null&&e.phone_number))return;const n=s(),t=e[n];!(t!=null&&t.enabled)||!t.position||(r(e.phone_number,t),a||(a=!0,document.addEventListener("turbolinks:load",()=>{r(e.phone_number,t)})))}window.commversion=window.commversion||{},g(window.commversion)})();
|