yelda-webchat 1.1.3 → 1.1.8
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 +3 -1
- package/dist/css/yeldaWebchatInjector.css +60 -0
- package/dist/css/yeldaWebchatInjector.min.css +7 -0
- package/dist/css/yeldaWebchatInjector.min.css.map +1 -1
- package/dist/js/yeldaWebchatInjector.js +270 -57
- package/dist/js/yeldaWebchatInjector.js.map +1 -1
- package/dist/js/yeldaWebchatInjector.min.js +1 -1
- package/package.json +2 -2
- package/src/config/index.js +20 -0
- package/src/css/yeldaWebchatInjector.css +60 -0
- package/src/js/yeldaWebchatInjector.js +212 -44
- package/uploadBuildToS3.js +11 -4
|
@@ -776,7 +776,7 @@ var YeldaChat = function () {
|
|
|
776
776
|
* get Specific parameter from the url
|
|
777
777
|
* @param {*} parameter
|
|
778
778
|
* @param {*} defaultValue, default empty string
|
|
779
|
-
* @return {String}
|
|
779
|
+
* @return {String} urlParameter
|
|
780
780
|
*/
|
|
781
781
|
|
|
782
782
|
}, {
|
|
@@ -823,27 +823,65 @@ var YeldaChat = function () {
|
|
|
823
823
|
|
|
824
824
|
/**
|
|
825
825
|
* Create an assistantBubbleText component and add it to webChatContainer element
|
|
826
|
+
* @param {String} text - default null
|
|
826
827
|
*/
|
|
827
828
|
|
|
828
829
|
}, {
|
|
829
830
|
key: 'addAssistantBubbleText',
|
|
830
831
|
value: function addAssistantBubbleText() {
|
|
831
|
-
|
|
832
|
+
var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
833
|
+
|
|
834
|
+
text = text || this.webchatSettings && this.webchatSettings.bubbleText;
|
|
835
|
+
if (!this.webChatContainer || !text) {
|
|
832
836
|
return;
|
|
833
837
|
}
|
|
834
838
|
|
|
839
|
+
// Remove the assistant bubble text element before adding a new one
|
|
840
|
+
this.removeElement('yelda_assistant_bubble_text');
|
|
835
841
|
// create assistantBubbleText element and set the text
|
|
836
842
|
this.assistantBubbleText = document.createElement('span');
|
|
837
843
|
this.assistantBubbleText.setAttribute('id', 'yelda_assistant_bubble_text');
|
|
838
|
-
this.assistantBubbleText.innerText =
|
|
844
|
+
this.assistantBubbleText.innerText = text;
|
|
845
|
+
this.addCloseButtonForBubbleText();
|
|
839
846
|
|
|
840
847
|
// Add click event to assistant text
|
|
841
|
-
this.assistantBubbleText.addEventListener('click', this.openChat);
|
|
848
|
+
this.assistantBubbleText.addEventListener('click', this.openChat.bind(this));
|
|
842
849
|
|
|
843
850
|
// add assistant text to webChatContainer using the webchatSettings
|
|
844
851
|
this.webChatContainer.appendChild(this.assistantBubbleText);
|
|
845
852
|
}
|
|
846
853
|
|
|
854
|
+
/**
|
|
855
|
+
* Add close button for bubble text
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
}, {
|
|
859
|
+
key: 'addCloseButtonForBubbleText',
|
|
860
|
+
value: function addCloseButtonForBubbleText() {
|
|
861
|
+
// Create close button and add it to the bubble text container
|
|
862
|
+
var closeButton = document.createElement('a');
|
|
863
|
+
closeButton.setAttribute('class', 'bubbleCloseButton');
|
|
864
|
+
closeButton.setAttribute('id', 'yelda_assistant_bubble_text_close');
|
|
865
|
+
closeButton.setAttribute('href', '#');
|
|
866
|
+
closeButton.innerHTML = '×';
|
|
867
|
+
closeButton.onclick = this.closeBubbleText.bind(this);
|
|
868
|
+
this.assistantBubbleText.prepend(closeButton);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Callback function for bubble text close button
|
|
873
|
+
* @param {Event} event
|
|
874
|
+
*/
|
|
875
|
+
|
|
876
|
+
}, {
|
|
877
|
+
key: 'closeBubbleText',
|
|
878
|
+
value: function closeBubbleText(event) {
|
|
879
|
+
event.preventDefault();
|
|
880
|
+
event.stopPropagation();
|
|
881
|
+
this.removeElement('yelda_assistant_bubble_text');
|
|
882
|
+
this.assistantBubbleText = null;
|
|
883
|
+
}
|
|
884
|
+
|
|
847
885
|
/**
|
|
848
886
|
* Create assistantImage element and add it to webChatContainer element
|
|
849
887
|
*/
|
|
@@ -878,7 +916,7 @@ var YeldaChat = function () {
|
|
|
878
916
|
this.assistantImage.innerHTML = '<i class="fas fa-comment"></i>';
|
|
879
917
|
|
|
880
918
|
// Add click event to assistant image
|
|
881
|
-
this.assistantImage.addEventListener('click', this.openChat);
|
|
919
|
+
this.assistantImage.addEventListener('click', this.openChat.bind(this));
|
|
882
920
|
|
|
883
921
|
// add assistantImage to webChatContainer using the webchatSettings
|
|
884
922
|
this.updateAssistantImageWithAssistantSettings();
|
|
@@ -1031,7 +1069,7 @@ var YeldaChat = function () {
|
|
|
1031
1069
|
/**
|
|
1032
1070
|
* add CSS class which controls the opacity of the frame container if the iframe:
|
|
1033
1071
|
* - should be opened on load OR has a start button
|
|
1034
|
-
* - cannot be closed (canBeClosed
|
|
1072
|
+
* - cannot be closed (canBeClosed explicitly set to false)
|
|
1035
1073
|
*
|
|
1036
1074
|
* If we are sure that the webchat should be opened and displayed all the time, we can add the y_active class right away
|
|
1037
1075
|
* Otherwise,
|
|
@@ -1126,7 +1164,7 @@ var YeldaChat = function () {
|
|
|
1126
1164
|
}
|
|
1127
1165
|
|
|
1128
1166
|
/**
|
|
1129
|
-
* Handles
|
|
1167
|
+
* Handles communication between parent window and iframe, mainly for open and closing the chat
|
|
1130
1168
|
* handles also the chat bubble style
|
|
1131
1169
|
* @param {event} event
|
|
1132
1170
|
*/
|
|
@@ -1134,36 +1172,78 @@ var YeldaChat = function () {
|
|
|
1134
1172
|
}, {
|
|
1135
1173
|
key: 'messageListener',
|
|
1136
1174
|
value: function messageListener(event) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1175
|
+
// event.message is only there to support IE11.
|
|
1176
|
+
var eventData = event.data || event.message;
|
|
1177
|
+
if (!eventData) {
|
|
1139
1178
|
return;
|
|
1140
1179
|
}
|
|
1141
1180
|
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1181
|
+
/*
|
|
1182
|
+
* Simple event management parent.postMessage('string message')
|
|
1183
|
+
*/
|
|
1184
|
+
if (!eventData.event) {
|
|
1185
|
+
switch (eventData) {
|
|
1186
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.OPEN_CHAT:
|
|
1187
|
+
// 'openChat' event triggered from webchat
|
|
1188
|
+
this.openChat();
|
|
1189
|
+
break;
|
|
1190
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.CLOSE_CHAT:
|
|
1191
|
+
// 'closeChat' event triggered from webchat
|
|
1192
|
+
this.closeChat();
|
|
1193
|
+
break;
|
|
1194
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.ABSTAIN_LEAVE_VIEWPORT:
|
|
1195
|
+
// 'abstainLeaveViewport' event triggered from webchat to stop listening to the leave viewport event
|
|
1196
|
+
this.listenLeaveViewport(true);
|
|
1197
|
+
break;
|
|
1198
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.LISTEN_LEAVE_VIEWPORT:
|
|
1199
|
+
// Triggered from webchat to listen leave viewport event
|
|
1200
|
+
this.listenLeaveViewport();
|
|
1201
|
+
break;
|
|
1202
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.LISTEN_URL_UPDATE:
|
|
1203
|
+
// Triggered from webchat to listen for url update
|
|
1204
|
+
this.listenUrlUpdate();
|
|
1205
|
+
break;
|
|
1206
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.ABSTAIN_URL_UPDATE:
|
|
1207
|
+
// Triggered form webchat to stop listening for url update
|
|
1208
|
+
this.listenUrlUpdate(true);
|
|
1209
|
+
break;
|
|
1210
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.ADD_BUBBLE_TEXT:
|
|
1211
|
+
// Triggered from webchat to add assistant bubble text if possible
|
|
1212
|
+
if (!this.configurationData.hasOwnProperty('canBeClosed') || this.configurationData.canBeClosed) {
|
|
1213
|
+
this.addAssistantBubbleText();
|
|
1214
|
+
}
|
|
1215
|
+
break;
|
|
1150
1216
|
}
|
|
1151
|
-
|
|
1152
|
-
this.handleLightGallery(event.data);
|
|
1153
1217
|
return;
|
|
1154
1218
|
}
|
|
1155
1219
|
|
|
1156
|
-
|
|
1157
|
-
*
|
|
1158
|
-
* If isSendingMessage data is true, it means that a user message has already been sent to the webchat and
|
|
1159
|
-
* is still waiting for an answer
|
|
1160
|
-
* If isSendingMessage data is false, the webchat is ready to receive new user messages
|
|
1220
|
+
/*
|
|
1221
|
+
* Complex event management parent.postMessage({ event: 'xxxx', data: yyyy })
|
|
1161
1222
|
*/
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1223
|
+
switch (eventData.event) {
|
|
1224
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.OPEN_LIGHT_GALLERY:
|
|
1225
|
+
if (!eventData.mediaSources || !eventData.mediaSources.length) {
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
this.handleLightGallery(eventData);
|
|
1230
|
+
break;
|
|
1231
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.IS_SENDING_MESSAGE:
|
|
1232
|
+
/**
|
|
1233
|
+
* Custom event to send to Yelda to keep track of the webchat ability to receive a new message
|
|
1234
|
+
* If isSendingMessage data is true, it means that a user message has already been sent to the webchat and
|
|
1235
|
+
* is still waiting for an answer
|
|
1236
|
+
* If isSendingMessage data is false, the webchat is ready to receive new user messages
|
|
1237
|
+
*/
|
|
1238
|
+
if (eventData.hasOwnProperty('data')) {
|
|
1239
|
+
window.dispatchEvent(new CustomEvent('isSendingMessage', { detail: eventData.data }));
|
|
1240
|
+
}
|
|
1241
|
+
break;
|
|
1242
|
+
case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.ADD_MINIMAL_NOTIFICATION_TEXT:
|
|
1243
|
+
if (!this.configurationData.hasOwnProperty('canBeClosed') || this.configurationData.canBeClosed) {
|
|
1244
|
+
this.addAssistantBubbleText(eventData.text);
|
|
1245
|
+
}
|
|
1246
|
+
break;
|
|
1167
1247
|
}
|
|
1168
1248
|
}
|
|
1169
1249
|
|
|
@@ -1257,8 +1337,16 @@ var YeldaChat = function () {
|
|
|
1257
1337
|
yeldaIframeContainerElement.classList.add('y_active');
|
|
1258
1338
|
}
|
|
1259
1339
|
|
|
1340
|
+
// hide the assistant bubble text while opening the webchat window
|
|
1341
|
+
if (this.assistantBubbleText) {
|
|
1342
|
+
this.assistantBubbleText = null;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// Remove assistant bubble text while opening the webchat window
|
|
1346
|
+
this.removeElement('yelda_assistant_bubble_text');
|
|
1347
|
+
|
|
1260
1348
|
// Propagate the event to the webchat
|
|
1261
|
-
document.getElementById('web_chat_frame').contentWindow.postMessage(
|
|
1349
|
+
document.getElementById('web_chat_frame').contentWindow.postMessage(_config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.SENT.OPEN_CHAT, '*');
|
|
1262
1350
|
}
|
|
1263
1351
|
|
|
1264
1352
|
/**
|
|
@@ -1288,7 +1376,7 @@ var YeldaChat = function () {
|
|
|
1288
1376
|
}
|
|
1289
1377
|
|
|
1290
1378
|
/**
|
|
1291
|
-
* Load CSS
|
|
1379
|
+
* Load CSS asynchronously
|
|
1292
1380
|
*/
|
|
1293
1381
|
|
|
1294
1382
|
}, {
|
|
@@ -1305,7 +1393,7 @@ var YeldaChat = function () {
|
|
|
1305
1393
|
}
|
|
1306
1394
|
|
|
1307
1395
|
/**
|
|
1308
|
-
*
|
|
1396
|
+
* Generate webchatURL and create webchatIframe
|
|
1309
1397
|
* @param {Object} data { chatUrl, assistantId, assistantSlug, shouldBeOpened, isStartBtn, canBeClosed }
|
|
1310
1398
|
*/
|
|
1311
1399
|
|
|
@@ -1355,7 +1443,7 @@ var YeldaChat = function () {
|
|
|
1355
1443
|
}, _callee, _this2);
|
|
1356
1444
|
}));
|
|
1357
1445
|
|
|
1358
|
-
return function (
|
|
1446
|
+
return function (_x5) {
|
|
1359
1447
|
return _ref.apply(this, arguments);
|
|
1360
1448
|
};
|
|
1361
1449
|
}());
|
|
@@ -1498,10 +1586,10 @@ var YeldaChat = function () {
|
|
|
1498
1586
|
}
|
|
1499
1587
|
|
|
1500
1588
|
/**
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1589
|
+
* return getAssistantSettings endpoint URL from data
|
|
1590
|
+
* @param {Object} data { assistantUrl, assistantId, settingId }
|
|
1591
|
+
* @return {String} url
|
|
1592
|
+
*/
|
|
1505
1593
|
|
|
1506
1594
|
}, {
|
|
1507
1595
|
key: 'getAssistantSettingsUrl',
|
|
@@ -1616,10 +1704,16 @@ var YeldaChat = function () {
|
|
|
1616
1704
|
|
|
1617
1705
|
case 22:
|
|
1618
1706
|
|
|
1707
|
+
// Remove event listeners when switching bots
|
|
1708
|
+
_this4.listenLeaveViewport(true);
|
|
1709
|
+
_this4.listenUrlUpdate(true);
|
|
1710
|
+
|
|
1619
1711
|
_this4.loadChat(data);
|
|
1712
|
+
|
|
1713
|
+
_this4.configurationData = data;
|
|
1620
1714
|
return _context2.abrupt('return', resolve());
|
|
1621
1715
|
|
|
1622
|
-
case
|
|
1716
|
+
case 27:
|
|
1623
1717
|
case 'end':
|
|
1624
1718
|
return _context2.stop();
|
|
1625
1719
|
}
|
|
@@ -1627,7 +1721,7 @@ var YeldaChat = function () {
|
|
|
1627
1721
|
}, _callee2, _this4, [[12, 19]]);
|
|
1628
1722
|
}));
|
|
1629
1723
|
|
|
1630
|
-
return function (
|
|
1724
|
+
return function (_x6) {
|
|
1631
1725
|
return _ref2.apply(this, arguments);
|
|
1632
1726
|
};
|
|
1633
1727
|
}());
|
|
@@ -1672,17 +1766,17 @@ var YeldaChat = function () {
|
|
|
1672
1766
|
|
|
1673
1767
|
/**
|
|
1674
1768
|
* Return if the webchat loadChat settings are different from the yeldaChat global assistant settings
|
|
1675
|
-
*
|
|
1676
|
-
* - yeldaChat can be init (and reset) either with the settingId parameter or the pair (assistantId, locale) that we store globally
|
|
1677
|
-
* - Each new webchat loading request implies a "getAssistantSettings" async API call,
|
|
1678
|
-
* => If multiple new webchat loading requests are done in a short amount of time,
|
|
1679
|
-
* "getAssistantSettings" response can be subject to a race condition issue:
|
|
1769
|
+
*
|
|
1770
|
+
* - yeldaChat can be init (and reset) either with the settingId parameter or the pair (assistantId, locale) that we store globally
|
|
1771
|
+
* - Each new webchat loading request implies a "getAssistantSettings" async API call,
|
|
1772
|
+
* => If multiple new webchat loading requests are done in a short amount of time,
|
|
1773
|
+
* "getAssistantSettings" response can be subject to a race condition issue:
|
|
1680
1774
|
* The latest requested answer received might not be the latest API call answer.
|
|
1681
|
-
*
|
|
1775
|
+
*
|
|
1682
1776
|
* isDataOutdated checks if one of the global parameter is different the ones from the webchat settings we got from the "getAssistantSettings" API call
|
|
1683
1777
|
* so the "loadChat" function can be informed that the latest request is not the one currently handled
|
|
1684
1778
|
* And can stop the current process to let the chat load with the global latest requested settings
|
|
1685
|
-
*
|
|
1779
|
+
*
|
|
1686
1780
|
* @param {Object} webchatSettings - current settings from the reset or init yeldaChat request
|
|
1687
1781
|
* @param {String} webchatSettings.settingId
|
|
1688
1782
|
* @param {String} webchatSettings.assistantId
|
|
@@ -1748,7 +1842,6 @@ var YeldaChat = function () {
|
|
|
1748
1842
|
// because the assistant image containing the openChat event wouldn't have been created
|
|
1749
1843
|
if (!data.hasOwnProperty('canBeClosed') || data.canBeClosed) {
|
|
1750
1844
|
this.addAssistantImage();
|
|
1751
|
-
this.addAssistantBubbleText();
|
|
1752
1845
|
}
|
|
1753
1846
|
|
|
1754
1847
|
// add the frame lister to receive message from iframe to the parent
|
|
@@ -1769,7 +1862,7 @@ var YeldaChat = function () {
|
|
|
1769
1862
|
if (this.bubbleContainer) {
|
|
1770
1863
|
this.assistantImage.removeAttribute('id', 'yelda_assistant_img');
|
|
1771
1864
|
this.assistantImage.removeAttribute('class', 'yelda_assistant_img default');
|
|
1772
|
-
this.assistantImage.removeEventListener('click', this.openChat);
|
|
1865
|
+
this.assistantImage.removeEventListener('click', this.openChat.bind(this));
|
|
1773
1866
|
this.assistantImage.replaceWith(this.bubbleContainerClone);
|
|
1774
1867
|
} else {
|
|
1775
1868
|
this.removeElement('yelda_assistant_img');
|
|
@@ -1871,7 +1964,7 @@ var YeldaChat = function () {
|
|
|
1871
1964
|
}, _callee4, _this5);
|
|
1872
1965
|
}));
|
|
1873
1966
|
|
|
1874
|
-
return function (
|
|
1967
|
+
return function (_x7) {
|
|
1875
1968
|
return _ref4.apply(this, arguments);
|
|
1876
1969
|
};
|
|
1877
1970
|
}());
|
|
@@ -1887,8 +1980,109 @@ var YeldaChat = function () {
|
|
|
1887
1980
|
var webchatFrame = document.getElementById('web_chat_frame');
|
|
1888
1981
|
if (webchatFrame) {
|
|
1889
1982
|
this.openChat();
|
|
1890
|
-
webchatFrame.contentWindow.postMessage({ event:
|
|
1983
|
+
webchatFrame.contentWindow.postMessage({ event: _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.SENT.SEND_USER_MESSAGE, data: message });
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
/**
|
|
1988
|
+
* Listen to url update on the page
|
|
1989
|
+
* @param {Boolean} shouldRemoveEvent
|
|
1990
|
+
*/
|
|
1991
|
+
|
|
1992
|
+
}, {
|
|
1993
|
+
key: 'listenUrlUpdate',
|
|
1994
|
+
value: function listenUrlUpdate() {
|
|
1995
|
+
var _this6 = this;
|
|
1996
|
+
|
|
1997
|
+
var shouldRemoveEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1998
|
+
|
|
1999
|
+
if (shouldRemoveEvent && this.urlObserver) {
|
|
2000
|
+
this.urlObserver.disconnect();
|
|
2001
|
+
this.urlObserver = null;
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
try {
|
|
2006
|
+
this.previousUrl = '';
|
|
2007
|
+
this.urlObserver = new MutationObserver(function () {
|
|
2008
|
+
if (location.href === _this6.previousUrl) {
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
_this6.previousUrl = location.href;
|
|
2012
|
+
_this6.urlUpdateListener();
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
this.urlObserver.observe(document, { childList: true, subtree: true });
|
|
2016
|
+
} catch (err) {
|
|
2017
|
+
console.warn('listenUrlUpdate error', err);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
/**
|
|
2022
|
+
* Callback for url update listener
|
|
2023
|
+
*/
|
|
2024
|
+
|
|
2025
|
+
}, {
|
|
2026
|
+
key: 'urlUpdateListener',
|
|
2027
|
+
value: function urlUpdateListener() {
|
|
2028
|
+
var webchatFrame = document.getElementById('web_chat_frame');
|
|
2029
|
+
|
|
2030
|
+
if (!webchatFrame) {
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
webchatFrame.contentWindow.postMessage({ event: _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.SENT.URL_UPDATE, data: window.location.href }, '*');
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* Listen leave viewport event handling
|
|
2038
|
+
* @param {Boolean} shouldRemoveEvent - default false
|
|
2039
|
+
*/
|
|
2040
|
+
|
|
2041
|
+
}, {
|
|
2042
|
+
key: 'listenLeaveViewport',
|
|
2043
|
+
value: function listenLeaveViewport() {
|
|
2044
|
+
var shouldRemoveEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2045
|
+
|
|
2046
|
+
var md = new mobile_detect__WEBPACK_IMPORTED_MODULE_7___default.a(navigator.userAgent);
|
|
2047
|
+
var isMobile = md.mobile() !== null;
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Not needed to listen on mobile since webchat covers the full page of the site
|
|
2051
|
+
* and we can't able to detect mouseout events
|
|
2052
|
+
*/
|
|
2053
|
+
if (isMobile) {
|
|
2054
|
+
return;
|
|
1891
2055
|
}
|
|
2056
|
+
|
|
2057
|
+
var eventHandler = window[shouldRemoveEvent ? 'removeEventListener' : 'addEventListener'];
|
|
2058
|
+
|
|
2059
|
+
if (!this.viewportListenerBind) {
|
|
2060
|
+
this.viewportListenerBind = this.viewportListener.bind(this);
|
|
2061
|
+
}
|
|
2062
|
+
// mouseout event is used to listen leave viewport
|
|
2063
|
+
eventHandler('mouseout', this.viewportListenerBind);
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Callback for leave viewport listener
|
|
2068
|
+
* @param {Event} event
|
|
2069
|
+
*/
|
|
2070
|
+
|
|
2071
|
+
}, {
|
|
2072
|
+
key: 'viewportListener',
|
|
2073
|
+
value: function viewportListener(event) {
|
|
2074
|
+
/**
|
|
2075
|
+
* when mouse moves between dom elements mouseout event is trigged but we need to trigger
|
|
2076
|
+
* the event when mouse moves out of the viewport so toElement and relatedTarget is checked
|
|
2077
|
+
*/
|
|
2078
|
+
if (event.toElement || event.relatedTarget) {
|
|
2079
|
+
return;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// When mouse leaves the viewport send 'leaveViewPort' to webchat
|
|
2083
|
+
document.getElementById('web_chat_frame').contentWindow.postMessage({
|
|
2084
|
+
event: _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.SENT.LEAVE_VIEWPORT
|
|
2085
|
+
}, '*');
|
|
1892
2086
|
}
|
|
1893
2087
|
}]);
|
|
1894
2088
|
|
|
@@ -2012,8 +2206,8 @@ if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
|
|
|
2012
2206
|
var require;var require;/**!
|
|
2013
2207
|
* lg-video.js | 1.2.0 | May 20th 2020
|
|
2014
2208
|
* http://sachinchoolur.github.io/lg-video.js
|
|
2015
|
-
* Copyright (c) 2016 Sachin N;
|
|
2016
|
-
* @license GPLv3
|
|
2209
|
+
* Copyright (c) 2016 Sachin N;
|
|
2210
|
+
* @license GPLv3
|
|
2017
2211
|
*/(function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return require(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2018
2212
|
(function (global, factory) {
|
|
2019
2213
|
if (typeof define === "function" && define.amd) {
|
|
@@ -2281,12 +2475,11 @@ var require;var require;/**!
|
|
|
2281
2475
|
videoTitle = this.core.s.dynamicEl[index].title;
|
|
2282
2476
|
} else {
|
|
2283
2477
|
videoTitle = this.core.items[index].getAttribute('title');
|
|
2284
|
-
|
|
2478
|
+
var firstImage = this.core.items[index].querySelector('img');
|
|
2285
2479
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
videoTitle = videoTitle || firstImage.getAttribute('alt');
|
|
2480
|
+
if (firstImage) {
|
|
2481
|
+
videoTitle = videoTitle || firstImage.getAttribute('alt');
|
|
2482
|
+
}
|
|
2290
2483
|
}
|
|
2291
2484
|
|
|
2292
2485
|
videoTitle = videoTitle ? 'title="' + videoTitle + '"' : '';
|
|
@@ -2387,6 +2580,26 @@ module.exports = {
|
|
|
2387
2580
|
HOST: {
|
|
2388
2581
|
PRODUCTION: 'app.yelda.ai',
|
|
2389
2582
|
STAGING: 'staging.yelda.ai'
|
|
2583
|
+
},
|
|
2584
|
+
FRAME_EVENT_TYPES: {
|
|
2585
|
+
SENT: {
|
|
2586
|
+
OPEN_CHAT: 'openChat',
|
|
2587
|
+
LEAVE_VIEWPORT: 'leaveViewPort',
|
|
2588
|
+
SEND_USER_MESSAGE: 'sendUserMessage',
|
|
2589
|
+
URL_UPDATE: 'urlUpdate'
|
|
2590
|
+
},
|
|
2591
|
+
RECEIVED: {
|
|
2592
|
+
OPEN_CHAT: 'openChat',
|
|
2593
|
+
CLOSE_CHAT: 'closeChat',
|
|
2594
|
+
ABSTAIN_LEAVE_VIEWPORT: 'abstainLeaveViewport',
|
|
2595
|
+
OPEN_LIGHT_GALLERY: 'openLightGallery',
|
|
2596
|
+
IS_SENDING_MESSAGE: 'isSendingMessage',
|
|
2597
|
+
LISTEN_LEAVE_VIEWPORT: 'listenLeaveViewport',
|
|
2598
|
+
LISTEN_URL_UPDATE: 'listenUrlUpdate',
|
|
2599
|
+
ABSTAIN_URL_UPDATE: 'abstainUrlUpdate',
|
|
2600
|
+
ADD_BUBBLE_TEXT: 'addBubbleText',
|
|
2601
|
+
ADD_MINIMAL_NOTIFICATION_TEXT: 'addMinimalNotificationText'
|
|
2602
|
+
}
|
|
2390
2603
|
}
|
|
2391
2604
|
};
|
|
2392
2605
|
|