yelda-webchat 1.1.7 → 1.1.11
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/css/yeldaWebchatInjector.css +122 -53
- package/dist/css/yeldaWebchatInjector.min.css +17 -13
- package/dist/css/yeldaWebchatInjector.min.css.map +1 -1
- package/dist/js/yeldaWebchatInjector.js +104 -44
- package/dist/js/yeldaWebchatInjector.js.map +1 -1
- package/dist/js/yeldaWebchatInjector.min.js +1 -1
- package/package.json +1 -1
- package/src/css/yeldaWebchatInjector.css +122 -53
- package/src/js/yeldaWebchatInjector.js +85 -36
package/package.json
CHANGED
|
@@ -2,8 +2,29 @@
|
|
|
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
|
+
opacity:0 ;
|
|
20
|
+
height: 0 !important;
|
|
21
|
+
width: 0 !important;
|
|
22
|
+
transition: opacity 1ms linear 0s, height 1ms linear 0s;
|
|
23
|
+
animation: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.yelda_assistant_img.activated{
|
|
27
|
+
transition: opacity 0.6s ease-in-out 0.6s, height 1ms linear 0.6s;
|
|
7
28
|
}
|
|
8
29
|
|
|
9
30
|
.yelda_assistant_img.default {
|
|
@@ -33,32 +54,30 @@
|
|
|
33
54
|
}
|
|
34
55
|
|
|
35
56
|
.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
57
|
height: 60px;
|
|
46
58
|
width: 60px;
|
|
47
59
|
line-height: 65px;
|
|
48
60
|
font-size: 35px !important;
|
|
49
61
|
}
|
|
50
62
|
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
.yelda_container {
|
|
67
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
|
|
68
|
+
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
69
|
+
font-weight: normal;
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column-reverse;
|
|
72
|
+
align-items: flex-end;
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
.yelda_container.inner {
|
|
52
76
|
position: absolute !important;
|
|
53
77
|
left: 45px;
|
|
54
78
|
top: 80px;
|
|
55
79
|
}
|
|
56
80
|
|
|
57
|
-
@keyframes fonta {
|
|
58
|
-
from {font-size:32px;}
|
|
59
|
-
to {font-size:35px;}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
81
|
#web_chat_frame{
|
|
63
82
|
height: 100% !important;
|
|
64
83
|
width: 100% !important;
|
|
@@ -72,13 +91,14 @@
|
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
.yelda_iframe_container {
|
|
75
|
-
width:
|
|
76
|
-
height:
|
|
94
|
+
width: 0;
|
|
95
|
+
height: 0;
|
|
77
96
|
max-height: 600px;
|
|
78
|
-
|
|
79
|
-
margin: 0px 20px 0 0px;
|
|
97
|
+
margin: 0;
|
|
80
98
|
overflow: hidden;
|
|
99
|
+
transition: opacity 0.6s linear 0s, transform 0.6s ease-in-out 0s, height 1ms linear 0.6s, width 1ms linear 0.6s;
|
|
81
100
|
opacity: 0;
|
|
101
|
+
transform: translateY(20px);
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
.yelda_iframe_container:not(.voiceFirstUI) {
|
|
@@ -86,9 +106,12 @@
|
|
|
86
106
|
border-radius: 6px;
|
|
87
107
|
}
|
|
88
108
|
|
|
89
|
-
.yelda_iframe_container
|
|
109
|
+
.y_active .yelda_iframe_container{
|
|
110
|
+
width: 430px;
|
|
111
|
+
height: calc(100vh - 170px);
|
|
112
|
+
transition: opacity 0.6s linear 0s, transform 0.6s ease-in-out 0s, height 1ms linear 0s, width 1ms linear 0s;
|
|
90
113
|
opacity: 1 !important;
|
|
91
|
-
|
|
114
|
+
transform: translateY(0);
|
|
92
115
|
}
|
|
93
116
|
|
|
94
117
|
.lg-backdrop {
|
|
@@ -114,82 +137,128 @@
|
|
|
114
137
|
z-index: 2147483647;
|
|
115
138
|
}
|
|
116
139
|
|
|
140
|
+
.y_active .yelda_iframe_container{
|
|
141
|
+
width: 100% !important;
|
|
142
|
+
}
|
|
143
|
+
|
|
117
144
|
.yelda_iframe_container:not(.inner) {
|
|
118
145
|
position: fixed;
|
|
119
146
|
left: 0;
|
|
120
147
|
top: 0;
|
|
121
148
|
right: 0;
|
|
122
149
|
bottom: 0;
|
|
123
|
-
width:
|
|
150
|
+
width: 0;
|
|
124
151
|
height: auto;
|
|
125
152
|
max-height: none;
|
|
126
153
|
border-radius: 0;
|
|
127
154
|
margin: 0 !important;
|
|
128
155
|
padding: 0;
|
|
129
|
-
transition-duration: 0s;
|
|
130
156
|
}
|
|
131
157
|
|
|
158
|
+
|
|
159
|
+
|
|
132
160
|
.yelda_iframe_container.inner {
|
|
133
161
|
width: 100%;
|
|
134
162
|
box-shadow: 0 5px 32px rgba(0,0,0,.16);
|
|
135
163
|
border-radius: 6px;
|
|
136
|
-
transition-duration: 1s;
|
|
137
164
|
margin: 0px 20px 0 0px;
|
|
138
165
|
overflow: hidden;
|
|
139
166
|
}
|
|
140
167
|
}
|
|
141
168
|
/** CSS for assistant bubble text */
|
|
142
169
|
#yelda_assistant_bubble_text {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
170
|
+
animation-name: fadeAndSlideInFromRight;
|
|
171
|
+
animation-duration: 1s;
|
|
172
|
+
animation-delay: 2s;
|
|
173
|
+
animation-timing-function: cubic-bezier(0.230, 1.000, 0.320, 1.000);
|
|
174
|
+
animation-iteration-count: 1;
|
|
175
|
+
animation-fill-mode: both;
|
|
176
|
+
padding: 7px 10px 6px;
|
|
177
|
+
border-radius: 8px;
|
|
178
|
+
box-shadow: #00000030 0 2px 8px 0;
|
|
151
179
|
background-color: white;
|
|
152
180
|
cursor: pointer;
|
|
153
|
-
|
|
181
|
+
right: 0;
|
|
182
|
+
bottom: 76px;
|
|
183
|
+
max-width: 300px;
|
|
184
|
+
text-align: left;
|
|
185
|
+
font-size: 14px;
|
|
186
|
+
font-weight: normal;
|
|
187
|
+
display: inline-block;
|
|
188
|
+
margin-bottom: 10px;
|
|
189
|
+
}
|
|
190
|
+
#yelda_assistant_bubble_text.y_notification{
|
|
191
|
+
animation-delay: 0s;
|
|
154
192
|
}
|
|
155
193
|
|
|
156
194
|
#yelda_assistant_bubble_text.hidden {
|
|
157
195
|
display: none;
|
|
158
196
|
}
|
|
159
197
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
198
|
+
.y_active #yelda_assistant_bubble_text{
|
|
199
|
+
display: none;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Close button for bubble text */
|
|
203
|
+
.bubbleCloseButton {
|
|
164
204
|
position: absolute;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
205
|
+
color: white;
|
|
206
|
+
background: grey;
|
|
207
|
+
border-radius: 68%;
|
|
208
|
+
padding: 0;
|
|
209
|
+
font-size: 20px;
|
|
210
|
+
width: 27px;
|
|
211
|
+
height: 27px;
|
|
212
|
+
line-height: 22px;
|
|
213
|
+
text-align: center;
|
|
214
|
+
right: -14px;
|
|
215
|
+
top: -17px;
|
|
216
|
+
text-decoration: none !important;
|
|
217
|
+
transition: all 0.15s ease-in;
|
|
218
|
+
transform: scale(0.7);
|
|
219
|
+
opacity:0; /* Don't show the close button by default */
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
a.bubbleCloseButton:hover {
|
|
223
|
+
color: white;
|
|
224
|
+
background: #5a5a5a;
|
|
169
225
|
}
|
|
170
226
|
|
|
171
|
-
/*
|
|
172
|
-
#yelda_assistant_bubble_text
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
margin-left: 1px;
|
|
227
|
+
/* Show the close button on mouse hover */
|
|
228
|
+
#yelda_assistant_bubble_text:hover .bubbleCloseButton {
|
|
229
|
+
opacity:1;
|
|
230
|
+
transform: scale(1);
|
|
176
231
|
}
|
|
177
232
|
|
|
178
|
-
/*
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
233
|
+
/* Show the close button always on mobile screen */
|
|
234
|
+
@media only screen and (max-width: 768px) {
|
|
235
|
+
.bubbleCloseButton {
|
|
236
|
+
opacity: 1;
|
|
237
|
+
transform: none;
|
|
238
|
+
}
|
|
183
239
|
}
|
|
184
240
|
|
|
185
241
|
/** Animation for assistant bubble text */
|
|
186
242
|
@keyframes fadeAndSlideInFromRight {
|
|
187
243
|
0% {
|
|
188
|
-
transform:
|
|
244
|
+
transform: translateY(10%);
|
|
189
245
|
opacity: 0;
|
|
190
246
|
}
|
|
191
247
|
100% {
|
|
192
|
-
transform:
|
|
248
|
+
transform: translateY(0%);
|
|
249
|
+
opacity: 1;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@keyframes appear {
|
|
255
|
+
from {
|
|
256
|
+
transform: scale(0.5);
|
|
257
|
+
opacity: 0;
|
|
258
|
+
}
|
|
259
|
+
to {
|
|
260
|
+
transform: scale(1);
|
|
193
261
|
opacity: 1;
|
|
194
262
|
}
|
|
195
263
|
}
|
|
264
|
+
|
|
@@ -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,7 +96,9 @@ 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')
|
|
98
|
-
this.assistantBubbleText.
|
|
99
|
+
this.assistantBubbleText.setAttribute('class', cssClass)
|
|
100
|
+
this.assistantBubbleText.innerText = text
|
|
101
|
+
this.addCloseButtonForBubbleText()
|
|
99
102
|
|
|
100
103
|
// Add click event to assistant text
|
|
101
104
|
this.assistantBubbleText.addEventListener('click', this.openChat.bind(this))
|
|
@@ -104,6 +107,31 @@ class YeldaChat {
|
|
|
104
107
|
this.webChatContainer.appendChild(this.assistantBubbleText)
|
|
105
108
|
}
|
|
106
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Add close button for bubble text
|
|
112
|
+
*/
|
|
113
|
+
addCloseButtonForBubbleText() {
|
|
114
|
+
// Create close button and add it to the bubble text container
|
|
115
|
+
const closeButton = document.createElement('a')
|
|
116
|
+
closeButton.setAttribute('class', 'bubbleCloseButton')
|
|
117
|
+
closeButton.setAttribute('id', 'yelda_assistant_bubble_text_close')
|
|
118
|
+
closeButton.setAttribute('href', '#')
|
|
119
|
+
closeButton.innerHTML = '×'
|
|
120
|
+
closeButton.onclick = this.closeBubbleText.bind(this)
|
|
121
|
+
this.assistantBubbleText.prepend(closeButton)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Callback function for bubble text close button
|
|
126
|
+
* @param {Event} event
|
|
127
|
+
*/
|
|
128
|
+
closeBubbleText(event) {
|
|
129
|
+
event.preventDefault()
|
|
130
|
+
event.stopPropagation()
|
|
131
|
+
this.removeElement('yelda_assistant_bubble_text')
|
|
132
|
+
this.assistantBubbleText = null
|
|
133
|
+
}
|
|
134
|
+
|
|
107
135
|
/**
|
|
108
136
|
* Create assistantImage element and add it to webChatContainer element
|
|
109
137
|
*/
|
|
@@ -251,6 +279,43 @@ class YeldaChat {
|
|
|
251
279
|
return url
|
|
252
280
|
}
|
|
253
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Add 'y_active' class to the webChatContainer if required
|
|
284
|
+
*
|
|
285
|
+
* To control the opacity 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;)
|
|
289
|
+
* - assistant image is visible (opacity: 1 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 => opacity: 0
|
|
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
|
+
|
|
254
319
|
/**
|
|
255
320
|
* Create iframeContainer and it's child webchat iframe, and add it to webChatContainer
|
|
256
321
|
* @param {String} url webchat url
|
|
@@ -277,24 +342,7 @@ class YeldaChat {
|
|
|
277
342
|
classList += ' inner'
|
|
278
343
|
}
|
|
279
344
|
|
|
280
|
-
|
|
281
|
-
* add CSS class which controls the opacity of the frame container if the iframe:
|
|
282
|
-
* - should be opened on load OR has a start button
|
|
283
|
-
* - cannot be closed (canBeClosed explicitly set to false)
|
|
284
|
-
*
|
|
285
|
-
* If we are sure that the webchat should be opened and displayed all the time, we can add the y_active class right away
|
|
286
|
-
* Otherwise,
|
|
287
|
-
*/
|
|
288
|
-
if ((data.shouldBeOpened || data.isStartBtn) && data.hasOwnProperty('canBeClosed') && !data.canBeClosed) {
|
|
289
|
-
classList += ' y_active'
|
|
290
|
-
} else {
|
|
291
|
-
/**
|
|
292
|
-
* If the iframe can be closed, hide it by default
|
|
293
|
-
* yelda_assistant_img click event management will take care of showing and hiding the webchat
|
|
294
|
-
* And if it should be opened, the webchat will trigger the 'openChat' event on its own
|
|
295
|
-
*/
|
|
296
|
-
this.iframeContainer.style.cssText = 'display: none;'
|
|
297
|
-
}
|
|
345
|
+
this.initWebChatContainerYActiveClass(data)
|
|
298
346
|
|
|
299
347
|
this.iframeContainer.setAttribute('class', classList)
|
|
300
348
|
this.webChatContainer.appendChild(this.iframeContainer)
|
|
@@ -442,7 +490,9 @@ class YeldaChat {
|
|
|
442
490
|
}
|
|
443
491
|
break
|
|
444
492
|
case config.FRAME_EVENT_TYPES.RECEIVED.ADD_MINIMAL_NOTIFICATION_TEXT:
|
|
445
|
-
this.
|
|
493
|
+
if (!this.configurationData.hasOwnProperty('canBeClosed') || this.configurationData.canBeClosed) {
|
|
494
|
+
this.addAssistantBubbleText(eventData.text, 'y_notification')
|
|
495
|
+
}
|
|
446
496
|
break;
|
|
447
497
|
}
|
|
448
498
|
}
|
|
@@ -500,15 +550,11 @@ class YeldaChat {
|
|
|
500
550
|
* Close the webchat window
|
|
501
551
|
*/
|
|
502
552
|
closeChat() {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
const yeldaIframeContainerElement = document.getElementById('yelda_iframe_container')
|
|
509
|
-
if (yeldaIframeContainerElement !== null) {
|
|
510
|
-
yeldaIframeContainerElement.classList.remove('y_active')
|
|
511
|
-
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')
|
|
512
558
|
}
|
|
513
559
|
}
|
|
514
560
|
|
|
@@ -516,18 +562,21 @@ class YeldaChat {
|
|
|
516
562
|
* Open the webchat window
|
|
517
563
|
*/
|
|
518
564
|
openChat() {
|
|
565
|
+
// Adding the class "activated" allows the CSS to change the transition/animation after the first opening
|
|
519
566
|
const assistantImgElement = document.getElementById('yelda_assistant_img')
|
|
520
567
|
if (assistantImgElement !== null) {
|
|
521
|
-
assistantImgElement.
|
|
568
|
+
assistantImgElement.classList.add('activated')
|
|
522
569
|
}
|
|
523
570
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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')
|
|
528
576
|
}
|
|
529
577
|
|
|
530
|
-
//
|
|
578
|
+
// Hide the assistant bubble text while opening the webchat window
|
|
579
|
+
// Note : bubble text container is also hidden in CSS
|
|
531
580
|
if (this.assistantBubbleText) {
|
|
532
581
|
this.assistantBubbleText = null
|
|
533
582
|
}
|