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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yelda-webchat",
3
- "version": "1.1.8",
3
+ "version": "1.1.12",
4
4
  "description": "Website Chat Plugin",
5
5
  "main": "./dist/js/yeldaWebchatInjector.min.js",
6
6
  "license": "MIT",
@@ -2,8 +2,27 @@
2
2
 
3
3
 
4
4
  .yelda_assistant_img {
5
- opacity: 0.93;
6
5
  cursor: pointer;
6
+ height: auto;
7
+ transition: opacity 0.6s ease-in-out 1.2s, height 1ms linear 1.2s;
8
+ animation-name: appear;
9
+ animation-duration: 0.8s;
10
+ animation-delay: 1s;
11
+ animation-timing-function: cubic-bezier(0.230, 1.000, 0.320, 1.000);
12
+ animation-iteration-count: 1;
13
+ animation-fill-mode: both;
14
+ opacity: 0;
15
+ overflow: hidden;
16
+ }
17
+
18
+ .yelda_container.y_active .yelda_assistant_img{
19
+ display:none;
20
+ animation: none;
21
+ }
22
+
23
+ /* activated : not the first time we see the bubble */
24
+ .yelda_assistant_img.activated{
25
+ transition: opacity 0.6s ease-in-out 0.6s, height 1ms linear 0.6s;
7
26
  }
8
27
 
9
28
  .yelda_assistant_img.default {
@@ -33,25 +52,22 @@
33
52
  }
34
53
 
35
54
  .yelda_assistant_img.default i{
36
- font-size: 32px !important;
37
- }
38
-
39
- .yelda_assistant_img:hover{
40
- animation-name: fonta;
41
- animation-duration: 300ms;
42
- opacity: 1;
43
- }
44
- .yelda_assistant_img.default:hover i{
45
55
  height: 60px;
46
56
  width: 60px;
47
57
  line-height: 65px;
48
58
  font-size: 35px !important;
49
59
  }
50
60
 
61
+
62
+
63
+
51
64
  .yelda_container {
52
65
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
53
66
  'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
54
67
  font-weight: normal;
68
+ display: flex;
69
+ flex-direction: column-reverse;
70
+ align-items: flex-end;
55
71
  }
56
72
 
57
73
  .yelda_container.inner {
@@ -60,11 +76,6 @@
60
76
  top: 80px;
61
77
  }
62
78
 
63
- @keyframes fonta {
64
- from {font-size:32px;}
65
- to {font-size:35px;}
66
- }
67
-
68
79
  #web_chat_frame{
69
80
  height: 100% !important;
70
81
  width: 100% !important;
@@ -78,13 +89,14 @@
78
89
  }
79
90
 
80
91
  .yelda_iframe_container {
81
- width: 430px;
82
- height: calc(100vh - 170px);
92
+ width: 0;
93
+ height: 0;
83
94
  max-height: 600px;
84
- transition-duration: 1s;
85
- margin: 0px 20px 0 0px;
95
+ margin: 0;
86
96
  overflow: hidden;
97
+ transition: opacity 0.6s linear 0s, transform 0.6s ease-in-out 0s, height 1ms linear 0.6s, width 1ms linear 0.6s;
87
98
  opacity: 0;
99
+ transform: translateY(20px);
88
100
  }
89
101
 
90
102
  .yelda_iframe_container:not(.voiceFirstUI) {
@@ -92,9 +104,12 @@
92
104
  border-radius: 6px;
93
105
  }
94
106
 
95
- .yelda_iframe_container.y_active{
107
+ .y_active .yelda_iframe_container{
108
+ width: 430px;
109
+ height: calc(100vh - 170px);
110
+ transition: opacity 0.6s linear 0s, transform 0.6s ease-in-out 0s, height 1ms linear 0s, width 1ms linear 0s;
96
111
  opacity: 1 !important;
97
- margin-bottom: 20px !important;
112
+ transform: translateY(0);
98
113
  }
99
114
 
100
115
  .lg-backdrop {
@@ -120,74 +135,102 @@
120
135
  z-index: 2147483647;
121
136
  }
122
137
 
138
+ .y_active .yelda_iframe_container{
139
+ width: 100% !important;
140
+ }
141
+
123
142
  .yelda_iframe_container:not(.inner) {
124
143
  position: fixed;
125
144
  left: 0;
126
145
  top: 0;
127
146
  right: 0;
128
147
  bottom: 0;
129
- width: 100%;
148
+ width: 0;
130
149
  height: auto;
131
150
  max-height: none;
132
151
  border-radius: 0;
133
152
  margin: 0 !important;
134
153
  padding: 0;
135
- transition-duration: 0s;
136
154
  }
137
155
 
156
+
157
+
138
158
  .yelda_iframe_container.inner {
139
159
  width: 100%;
140
160
  box-shadow: 0 5px 32px rgba(0,0,0,.16);
141
161
  border-radius: 6px;
142
- transition-duration: 1s;
143
162
  margin: 0px 20px 0 0px;
144
163
  overflow: hidden;
145
164
  }
146
165
  }
147
166
  /** CSS for assistant bubble text */
148
167
  #yelda_assistant_bubble_text {
149
- animation: 1s ease-out 0s 1 fadeAndSlideInFromRight;
150
- position: absolute;
151
- padding: 7px 10px;
168
+ animation-name: fadeAndSlideInFromRight;
169
+ animation-duration: 1s;
170
+ animation-delay: 2s;
171
+ animation-timing-function: cubic-bezier(0.230, 1.000, 0.320, 1.000);
172
+ animation-iteration-count: 1;
173
+ animation-fill-mode: both;
174
+ padding: 7px 10px 6px;
152
175
  border-radius: 8px;
153
- box-shadow: #00000030 0px 2px 8px 0px;
176
+ box-shadow: #00000030 0 2px 8px 0;
154
177
  background-color: white;
155
178
  cursor: pointer;
156
- right: 0;
157
- bottom: 76px;
158
179
  max-width: 300px;
159
- width: calc(66vw);
160
180
  text-align: left;
161
181
  font-size: 14px;
162
182
  font-weight: normal;
183
+ display: inline-block;
184
+ margin-bottom: 10px;
185
+ }
186
+ #yelda_assistant_bubble_text.y_notification{
187
+ animation-delay: 0s;
163
188
  }
164
189
 
165
190
  #yelda_assistant_bubble_text.hidden {
166
191
  display: none;
167
192
  }
168
193
 
194
+ .y_active #yelda_assistant_bubble_text{
195
+ display: none;
196
+ }
197
+
169
198
  /* Close button for bubble text */
170
199
  .bubbleCloseButton {
171
- position: relative;
172
- top: -17px;
173
- left: 95%;
200
+ position: absolute;
174
201
  color: white;
175
202
  background: grey;
176
- border-radius: 50%;
177
- padding: 1px 4px;
178
- font-size: 16px;
179
- visibility: hidden; /* Don't show the close button by default */
203
+ border-radius: 68%;
204
+ padding: 0;
205
+ font-size: 20px;
206
+ width: 27px;
207
+ height: 27px;
208
+ line-height: 22px;
209
+ text-align: center;
210
+ right: -14px;
211
+ top: -17px;
212
+ text-decoration: none !important;
213
+ transition: all 0.15s ease-in;
214
+ transform: scale(0.7);
215
+ opacity:0; /* Don't show the close button by default */
216
+ }
217
+
218
+ a.bubbleCloseButton:hover {
219
+ color: white;
220
+ background: #5a5a5a;
180
221
  }
181
222
 
182
223
  /* Show the close button on mouse hover */
183
224
  #yelda_assistant_bubble_text:hover .bubbleCloseButton {
184
- visibility: visible;
225
+ opacity:1;
226
+ transform: scale(1);
185
227
  }
186
228
 
187
229
  /* Show the close button always on mobile screen */
188
230
  @media only screen and (max-width: 768px) {
189
231
  .bubbleCloseButton {
190
- visibility: visible !important;
232
+ opacity: 1;
233
+ transform: none;
191
234
  }
192
235
  }
193
236
 
@@ -202,3 +245,16 @@
202
245
  opacity: 1;
203
246
  }
204
247
  }
248
+
249
+
250
+ @keyframes appear {
251
+ from {
252
+ transform: scale(0.5);
253
+ opacity: 0;
254
+ }
255
+ to {
256
+ transform: scale(1);
257
+ opacity: 1;
258
+ }
259
+ }
260
+
@@ -83,8 +83,9 @@ class YeldaChat {
83
83
  /**
84
84
  * Create an assistantBubbleText component and add it to webChatContainer element
85
85
  * @param {String} text - default null
86
+ * @param {String} cssClass - default ''
86
87
  */
87
- addAssistantBubbleText(text = null) {
88
+ addAssistantBubbleText(text = null, cssClass = '') {
88
89
  text = text || this.webchatSettings && this.webchatSettings.bubbleText
89
90
  if (!this.webChatContainer || !text) {
90
91
  return
@@ -95,6 +96,7 @@ class YeldaChat {
95
96
  // create assistantBubbleText element and set the text
96
97
  this.assistantBubbleText = document.createElement('span')
97
98
  this.assistantBubbleText.setAttribute('id', 'yelda_assistant_bubble_text')
99
+ this.assistantBubbleText.setAttribute('class', cssClass)
98
100
  this.assistantBubbleText.innerText = text
99
101
  this.addCloseButtonForBubbleText()
100
102
 
@@ -277,6 +279,43 @@ class YeldaChat {
277
279
  return url
278
280
  }
279
281
 
282
+ /**
283
+ * Add 'y_active' class to the webChatContainer if required
284
+ *
285
+ * To control the opacity/display of the iframe container (.yelda_iframe_container) and the assistant image (.yelda_assistant_img),
286
+ * We add and remove the "y_active" CSS class to the webChatContainer (.yelda_container) which is always visible
287
+ * By default
288
+ * - yelda_iframe_container is hidden (opacity: 0; height:0; width: 0; to not affect page interactions)
289
+ * - assistant image is hidden (opacity: 0), but immediatly animated by css to be displayed (opacity: 1 with animation-name: appear;) for yelda_assistant_img)
290
+ *
291
+ * When we add the class "y_active" to (webChatContainer)
292
+ * - yelda_iframe_container is now visible (.y_active .yelda_iframe_container => opacity: 1)
293
+ * - the assistant image is hidden (.yelda_container.y_active .yelda_assistant_img => display:none, no opacity manipulation because no need of animation)
294
+ *
295
+ * @param {Boolean} data.shouldBeOpened
296
+ * @param {Boolean} data.isStartBtn
297
+ * @param {Boolean} data.canBeClosed
298
+ */
299
+ initWebChatContainerYActiveClass(data) {
300
+ // should be opened on load OR has a start button
301
+ const shoulBeOpened = data.shouldBeOpened || data.isStartBtn
302
+
303
+ // cannot be closed (canBeClosed explicitly set to false)
304
+ const cantBeClosed = data.hasOwnProperty('canBeClosed') && !data.canBeClosed
305
+
306
+ /**
307
+ * If we are sure that the webchat should be opened from the creation and displayed all the time
308
+ * we add the y_active class to webChatContainer at the creation
309
+ *
310
+ * Otherwise yelda_assistant_img click event management will take care of showing and hiding the webchat
311
+ * - closeChat() remove "y_active" from the yelda container
312
+ * - openChat() add y_active" to the yelda container
313
+ */
314
+ if (shoulBeOpened && cantBeClosed) {
315
+ this.webChatContainer.classList.add('y_active')
316
+ }
317
+ }
318
+
280
319
  /**
281
320
  * Create iframeContainer and it's child webchat iframe, and add it to webChatContainer
282
321
  * @param {String} url webchat url
@@ -303,24 +342,7 @@ class YeldaChat {
303
342
  classList += ' inner'
304
343
  }
305
344
 
306
- /**
307
- * add CSS class which controls the opacity of the frame container if the iframe:
308
- * - should be opened on load OR has a start button
309
- * - cannot be closed (canBeClosed explicitly set to false)
310
- *
311
- * If we are sure that the webchat should be opened and displayed all the time, we can add the y_active class right away
312
- * Otherwise,
313
- */
314
- if ((data.shouldBeOpened || data.isStartBtn) && data.hasOwnProperty('canBeClosed') && !data.canBeClosed) {
315
- classList += ' y_active'
316
- } else {
317
- /**
318
- * If the iframe can be closed, hide it by default
319
- * yelda_assistant_img click event management will take care of showing and hiding the webchat
320
- * And if it should be opened, the webchat will trigger the 'openChat' event on its own
321
- */
322
- this.iframeContainer.style.cssText = 'display: none;'
323
- }
345
+ this.initWebChatContainerYActiveClass(data)
324
346
 
325
347
  this.iframeContainer.setAttribute('class', classList)
326
348
  this.webChatContainer.appendChild(this.iframeContainer)
@@ -469,7 +491,7 @@ class YeldaChat {
469
491
  break
470
492
  case config.FRAME_EVENT_TYPES.RECEIVED.ADD_MINIMAL_NOTIFICATION_TEXT:
471
493
  if (!this.configurationData.hasOwnProperty('canBeClosed') || this.configurationData.canBeClosed) {
472
- this.addAssistantBubbleText(eventData.text)
494
+ this.addAssistantBubbleText(eventData.text, 'y_notification')
473
495
  }
474
496
  break;
475
497
  }
@@ -528,15 +550,11 @@ class YeldaChat {
528
550
  * Close the webchat window
529
551
  */
530
552
  closeChat() {
531
- const assistantImgElement = document.getElementById('yelda_assistant_img')
532
- if (assistantImgElement !== null) {
533
- assistantImgElement.style.display = 'inline-block'
534
- }
535
-
536
- const yeldaIframeContainerElement = document.getElementById('yelda_iframe_container')
537
- if (yeldaIframeContainerElement !== null) {
538
- yeldaIframeContainerElement.classList.remove('y_active')
539
- yeldaIframeContainerElement.style.display = 'none'
553
+ // Closing the webchat = remove the y_active class on #yelda_container
554
+ // Hiding the iframe + showing back the bubble + animation => All is done in CSS
555
+ const yeldaContainerElement = document.getElementById('yelda_container')
556
+ if (yeldaContainerElement !== null) {
557
+ yeldaContainerElement.classList.remove('y_active')
540
558
  }
541
559
  }
542
560
 
@@ -544,18 +562,21 @@ class YeldaChat {
544
562
  * Open the webchat window
545
563
  */
546
564
  openChat() {
565
+ // Adding the class "activated" allows the CSS to change the transition/animation after the first opening
547
566
  const assistantImgElement = document.getElementById('yelda_assistant_img')
548
567
  if (assistantImgElement !== null) {
549
- assistantImgElement.style.display = 'none'
568
+ assistantImgElement.classList.add('activated')
550
569
  }
551
570
 
552
- const yeldaIframeContainerElement = document.getElementById('yelda_iframe_container')
553
- if (yeldaIframeContainerElement !== null) {
554
- yeldaIframeContainerElement.style.display = 'block'
555
- yeldaIframeContainerElement.classList.add('y_active')
571
+ // Opening the webchat = adding the y_active class on #yelda_container
572
+ // Showing the iframe + hiding bubble + hiding minimal notification + animation => All is done in CSS
573
+ const yeldaContainerElement = document.getElementById('yelda_container')
574
+ if (yeldaContainerElement !== null) {
575
+ yeldaContainerElement.classList.add('y_active')
556
576
  }
557
577
 
558
- // hide the assistant bubble text while opening the webchat window
578
+ // Hide the assistant bubble text while opening the webchat window
579
+ // Note : bubble text container is also hidden in CSS
559
580
  if (this.assistantBubbleText) {
560
581
  this.assistantBubbleText = null
561
582
  }