yelda-webchat 1.1.8 → 1.1.12

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.
@@ -824,12 +824,14 @@ var YeldaChat = function () {
824
824
  /**
825
825
  * Create an assistantBubbleText component and add it to webChatContainer element
826
826
  * @param {String} text - default null
827
+ * @param {String} cssClass - default ''
827
828
  */
828
829
 
829
830
  }, {
830
831
  key: 'addAssistantBubbleText',
831
832
  value: function addAssistantBubbleText() {
832
833
  var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
834
+ var cssClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
833
835
 
834
836
  text = text || this.webchatSettings && this.webchatSettings.bubbleText;
835
837
  if (!this.webChatContainer || !text) {
@@ -841,6 +843,7 @@ var YeldaChat = function () {
841
843
  // create assistantBubbleText element and set the text
842
844
  this.assistantBubbleText = document.createElement('span');
843
845
  this.assistantBubbleText.setAttribute('id', 'yelda_assistant_bubble_text');
846
+ this.assistantBubbleText.setAttribute('class', cssClass);
844
847
  this.assistantBubbleText.innerText = text;
845
848
  this.addCloseButtonForBubbleText();
846
849
 
@@ -1037,6 +1040,46 @@ var YeldaChat = function () {
1037
1040
  return url;
1038
1041
  }
1039
1042
 
1043
+ /**
1044
+ * Add 'y_active' class to the webChatContainer if required
1045
+ *
1046
+ * To control the opacity/display of the iframe container (.yelda_iframe_container) and the assistant image (.yelda_assistant_img),
1047
+ * We add and remove the "y_active" CSS class to the webChatContainer (.yelda_container) which is always visible
1048
+ * By default
1049
+ * - yelda_iframe_container is hidden (opacity: 0; height:0; width: 0; to not affect page interactions)
1050
+ * - assistant image is hidden (opacity: 0), but immediatly animated by css to be displayed (opacity: 1 with animation-name: appear;) for yelda_assistant_img)
1051
+ *
1052
+ * When we add the class "y_active" to (webChatContainer)
1053
+ * - yelda_iframe_container is now visible (.y_active .yelda_iframe_container => opacity: 1)
1054
+ * - the assistant image is hidden (.yelda_container.y_active .yelda_assistant_img => display:none, no opacity manipulation because no need of animation)
1055
+ *
1056
+ * @param {Boolean} data.shouldBeOpened
1057
+ * @param {Boolean} data.isStartBtn
1058
+ * @param {Boolean} data.canBeClosed
1059
+ */
1060
+
1061
+ }, {
1062
+ key: 'initWebChatContainerYActiveClass',
1063
+ value: function initWebChatContainerYActiveClass(data) {
1064
+ // should be opened on load OR has a start button
1065
+ var shoulBeOpened = data.shouldBeOpened || data.isStartBtn;
1066
+
1067
+ // cannot be closed (canBeClosed explicitly set to false)
1068
+ var cantBeClosed = data.hasOwnProperty('canBeClosed') && !data.canBeClosed;
1069
+
1070
+ /**
1071
+ * If we are sure that the webchat should be opened from the creation and displayed all the time
1072
+ * we add the y_active class to webChatContainer at the creation
1073
+ *
1074
+ * Otherwise yelda_assistant_img click event management will take care of showing and hiding the webchat
1075
+ * - closeChat() remove "y_active" from the yelda container
1076
+ * - openChat() add y_active" to the yelda container
1077
+ */
1078
+ if (shoulBeOpened && cantBeClosed) {
1079
+ this.webChatContainer.classList.add('y_active');
1080
+ }
1081
+ }
1082
+
1040
1083
  /**
1041
1084
  * Create iframeContainer and it's child webchat iframe, and add it to webChatContainer
1042
1085
  * @param {String} url webchat url
@@ -1066,24 +1109,7 @@ var YeldaChat = function () {
1066
1109
  classList += ' inner';
1067
1110
  }
1068
1111
 
1069
- /**
1070
- * add CSS class which controls the opacity of the frame container if the iframe:
1071
- * - should be opened on load OR has a start button
1072
- * - cannot be closed (canBeClosed explicitly set to false)
1073
- *
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
1075
- * Otherwise,
1076
- */
1077
- if ((data.shouldBeOpened || data.isStartBtn) && data.hasOwnProperty('canBeClosed') && !data.canBeClosed) {
1078
- classList += ' y_active';
1079
- } else {
1080
- /**
1081
- * If the iframe can be closed, hide it by default
1082
- * yelda_assistant_img click event management will take care of showing and hiding the webchat
1083
- * And if it should be opened, the webchat will trigger the 'openChat' event on its own
1084
- */
1085
- this.iframeContainer.style.cssText = 'display: none;';
1086
- }
1112
+ this.initWebChatContainerYActiveClass(data);
1087
1113
 
1088
1114
  this.iframeContainer.setAttribute('class', classList);
1089
1115
  this.webChatContainer.appendChild(this.iframeContainer);
@@ -1241,7 +1267,7 @@ var YeldaChat = function () {
1241
1267
  break;
1242
1268
  case _config__WEBPACK_IMPORTED_MODULE_14___default.a.FRAME_EVENT_TYPES.RECEIVED.ADD_MINIMAL_NOTIFICATION_TEXT:
1243
1269
  if (!this.configurationData.hasOwnProperty('canBeClosed') || this.configurationData.canBeClosed) {
1244
- this.addAssistantBubbleText(eventData.text);
1270
+ this.addAssistantBubbleText(eventData.text, 'y_notification');
1245
1271
  }
1246
1272
  break;
1247
1273
  }
@@ -1307,15 +1333,11 @@ var YeldaChat = function () {
1307
1333
  }, {
1308
1334
  key: 'closeChat',
1309
1335
  value: function closeChat() {
1310
- var assistantImgElement = document.getElementById('yelda_assistant_img');
1311
- if (assistantImgElement !== null) {
1312
- assistantImgElement.style.display = 'inline-block';
1313
- }
1314
-
1315
- var yeldaIframeContainerElement = document.getElementById('yelda_iframe_container');
1316
- if (yeldaIframeContainerElement !== null) {
1317
- yeldaIframeContainerElement.classList.remove('y_active');
1318
- yeldaIframeContainerElement.style.display = 'none';
1336
+ // Closing the webchat = remove the y_active class on #yelda_container
1337
+ // Hiding the iframe + showing back the bubble + animation => All is done in CSS
1338
+ var yeldaContainerElement = document.getElementById('yelda_container');
1339
+ if (yeldaContainerElement !== null) {
1340
+ yeldaContainerElement.classList.remove('y_active');
1319
1341
  }
1320
1342
  }
1321
1343
 
@@ -1326,18 +1348,21 @@ var YeldaChat = function () {
1326
1348
  }, {
1327
1349
  key: 'openChat',
1328
1350
  value: function openChat() {
1351
+ // Adding the class "activated" allows the CSS to change the transition/animation after the first opening
1329
1352
  var assistantImgElement = document.getElementById('yelda_assistant_img');
1330
1353
  if (assistantImgElement !== null) {
1331
- assistantImgElement.style.display = 'none';
1354
+ assistantImgElement.classList.add('activated');
1332
1355
  }
1333
1356
 
1334
- var yeldaIframeContainerElement = document.getElementById('yelda_iframe_container');
1335
- if (yeldaIframeContainerElement !== null) {
1336
- yeldaIframeContainerElement.style.display = 'block';
1337
- yeldaIframeContainerElement.classList.add('y_active');
1357
+ // Opening the webchat = adding the y_active class on #yelda_container
1358
+ // Showing the iframe + hiding bubble + hiding minimal notification + animation => All is done in CSS
1359
+ var yeldaContainerElement = document.getElementById('yelda_container');
1360
+ if (yeldaContainerElement !== null) {
1361
+ yeldaContainerElement.classList.add('y_active');
1338
1362
  }
1339
1363
 
1340
- // hide the assistant bubble text while opening the webchat window
1364
+ // Hide the assistant bubble text while opening the webchat window
1365
+ // Note : bubble text container is also hidden in CSS
1341
1366
  if (this.assistantBubbleText) {
1342
1367
  this.assistantBubbleText = null;
1343
1368
  }
@@ -1443,7 +1468,7 @@ var YeldaChat = function () {
1443
1468
  }, _callee, _this2);
1444
1469
  }));
1445
1470
 
1446
- return function (_x5) {
1471
+ return function (_x6) {
1447
1472
  return _ref.apply(this, arguments);
1448
1473
  };
1449
1474
  }());
@@ -1721,7 +1746,7 @@ var YeldaChat = function () {
1721
1746
  }, _callee2, _this4, [[12, 19]]);
1722
1747
  }));
1723
1748
 
1724
- return function (_x6) {
1749
+ return function (_x7) {
1725
1750
  return _ref2.apply(this, arguments);
1726
1751
  };
1727
1752
  }());
@@ -1964,7 +1989,7 @@ var YeldaChat = function () {
1964
1989
  }, _callee4, _this5);
1965
1990
  }));
1966
1991
 
1967
- return function (_x7) {
1992
+ return function (_x8) {
1968
1993
  return _ref4.apply(this, arguments);
1969
1994
  };
1970
1995
  }());
@@ -2206,8 +2231,8 @@ if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
2206
2231
  var require;var require;/**!
2207
2232
  * lg-video.js | 1.2.0 | May 20th 2020
2208
2233
  * http://sachinchoolur.github.io/lg-video.js
2209
- * Copyright (c) 2016 Sachin N;
2210
- * @license GPLv3
2234
+ * Copyright (c) 2016 Sachin N;
2235
+ * @license GPLv3
2211
2236
  */(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){
2212
2237
  (function (global, factory) {
2213
2238
  if (typeof define === "function" && define.amd) {
@@ -2475,11 +2500,12 @@ var require;var require;/**!
2475
2500
  videoTitle = this.core.s.dynamicEl[index].title;
2476
2501
  } else {
2477
2502
  videoTitle = this.core.items[index].getAttribute('title');
2478
- var firstImage = this.core.items[index].querySelector('img');
2503
+ }
2479
2504
 
2480
- if (firstImage) {
2481
- videoTitle = videoTitle || firstImage.getAttribute('alt');
2482
- }
2505
+ var firstImage = this.core.items[index].querySelector('img');
2506
+
2507
+ if (firstImage) {
2508
+ videoTitle = videoTitle || firstImage.getAttribute('alt');
2483
2509
  }
2484
2510
 
2485
2511
  videoTitle = videoTitle ? 'title="' + videoTitle + '"' : '';