zz-shopify-components 0.35.1-beta.0 → 0.35.1-beta.2
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/package.json +1 -1
- package/sections/zz-live-chat.liquid +51 -8
package/package.json
CHANGED
|
@@ -85,15 +85,20 @@
|
|
|
85
85
|
const closeButton = section.querySelector('[data-live-chat-close]');
|
|
86
86
|
const chatNowButton = section.querySelector('[data-live-chat-open]');
|
|
87
87
|
const emailLink = section.querySelector('[data-live-chat-email]');
|
|
88
|
-
const isDesktop = window.matchMedia('(min-width:
|
|
88
|
+
const isDesktop = window.matchMedia('(min-width: 1025px)');
|
|
89
89
|
|
|
90
90
|
if (!wrapper || !floatingButton || !promptPanel) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
const desktopAutoPromptDelay = 10000;
|
|
95
|
+
const mobileAutoPromptDelay = 30000;
|
|
96
|
+
|
|
94
97
|
let scrollTimeout;
|
|
95
98
|
let hasInsertedStyle = false;
|
|
96
99
|
let isLogin = false;
|
|
100
|
+
let loginCheckInterval = null;
|
|
101
|
+
let loginCheckCount = 0;
|
|
97
102
|
let promptTimer = null;
|
|
98
103
|
let autoTriggerTimer = null;
|
|
99
104
|
let promptVisible = false;
|
|
@@ -293,7 +298,7 @@
|
|
|
293
298
|
|
|
294
299
|
hasAutoPrompted = true;
|
|
295
300
|
showPrompt('auto');
|
|
296
|
-
},
|
|
301
|
+
}, isDesktop.matches ? desktopAutoPromptDelay : mobileAutoPromptDelay);
|
|
297
302
|
}
|
|
298
303
|
|
|
299
304
|
function handleFloatingButtonClick(event) {
|
|
@@ -343,6 +348,7 @@
|
|
|
343
348
|
|
|
344
349
|
function checkLogin() {
|
|
345
350
|
if (isLogin) {
|
|
351
|
+
stopCheckLoginPolling();
|
|
346
352
|
return;
|
|
347
353
|
}
|
|
348
354
|
|
|
@@ -371,6 +377,42 @@
|
|
|
371
377
|
}
|
|
372
378
|
}
|
|
373
379
|
|
|
380
|
+
function stopCheckLoginPolling() {
|
|
381
|
+
if (!loginCheckInterval) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
clearInterval(loginCheckInterval);
|
|
386
|
+
loginCheckInterval = null;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function startCheckLoginPolling() {
|
|
390
|
+
stopCheckLoginPolling();
|
|
391
|
+
loginCheckCount = 0;
|
|
392
|
+
|
|
393
|
+
checkLogin();
|
|
394
|
+
loginCheckCount += 1;
|
|
395
|
+
|
|
396
|
+
if (isLogin || loginCheckCount >= 5) {
|
|
397
|
+
stopCheckLoginPolling();
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
loginCheckInterval = window.setInterval(function() {
|
|
402
|
+
if (isLogin || loginCheckCount >= 5) {
|
|
403
|
+
stopCheckLoginPolling();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
checkLogin();
|
|
408
|
+
loginCheckCount += 1;
|
|
409
|
+
|
|
410
|
+
if (isLogin || loginCheckCount >= 5) {
|
|
411
|
+
stopCheckLoginPolling();
|
|
412
|
+
}
|
|
413
|
+
}, 1500);
|
|
414
|
+
}
|
|
415
|
+
|
|
374
416
|
function handleLogin(params) {
|
|
375
417
|
const { email_verified } = params;
|
|
376
418
|
isLogin = true;
|
|
@@ -441,11 +483,12 @@
|
|
|
441
483
|
isDesktop.addEventListener('change', handleViewportChange);
|
|
442
484
|
}
|
|
443
485
|
|
|
444
|
-
|
|
486
|
+
if (closeButton) {
|
|
487
|
+
closeButton.addEventListener('click', function(event) {
|
|
445
488
|
event.preventDefault();
|
|
446
|
-
console.log('closeButton click');
|
|
447
489
|
closePrompt();
|
|
448
|
-
|
|
490
|
+
});
|
|
491
|
+
}
|
|
449
492
|
|
|
450
493
|
if (chatNowButton) {
|
|
451
494
|
chatNowButton.addEventListener('click', function(event) {
|
|
@@ -465,7 +508,7 @@
|
|
|
465
508
|
}
|
|
466
509
|
|
|
467
510
|
bindMessengerEvents();
|
|
468
|
-
|
|
511
|
+
startCheckLoginPolling();
|
|
469
512
|
scheduleAutoPrompt();
|
|
470
513
|
});
|
|
471
514
|
</script>
|
|
@@ -720,7 +763,7 @@
|
|
|
720
763
|
pointer-events: none;
|
|
721
764
|
}
|
|
722
765
|
|
|
723
|
-
@media (min-width:
|
|
766
|
+
@media (min-width: 1025px) {
|
|
724
767
|
#shopify-section-{{ section.id }} .live-chat-entry {
|
|
725
768
|
bottom: {{ section.settings.pc_bottom }}px;
|
|
726
769
|
}
|
|
@@ -731,7 +774,7 @@
|
|
|
731
774
|
|
|
732
775
|
}
|
|
733
776
|
|
|
734
|
-
@media (max-width:
|
|
777
|
+
@media (max-width: 1024px) {
|
|
735
778
|
#shopify-section-{{ section.id }} .live-chat-entry {
|
|
736
779
|
right: 16px;
|
|
737
780
|
align-items: flex-end;
|