@textback/notification-widget 2.0.1-110361 → 2.0.1-13997
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/build/index.js +2 -5
- package/build/sdk.js +2 -2
- package/package.json +4 -5
- package/readme.md +11 -90
- package/server.js +220 -224
- package/src/libraries/localization/getLocale.js +17 -17
- package/src/libraries/localization/locales/cs.js +21 -23
- package/src/libraries/localization/locales/en.js +21 -23
- package/src/libraries/localization/locales/pl.js +21 -23
- package/src/libraries/localization/locales/ro.js +21 -23
- package/src/libraries/localization/locales/ru.js +21 -22
- package/src/libraries/localization/locales/uk.js +21 -23
- package/src/sdk/channels/facebook.js +1 -1
- package/src/sdk/channels/factory.js +33 -33
- package/src/sdk/channels/skype.js +1 -1
- package/src/sdk/channels/telegram.js +2 -2
- package/src/sdk/channels/viber.js +1 -1
- package/src/sdk/channels/vk.js +147 -158
- package/src/sdk/channels/whatsapp.js +21 -27
- package/src/sdk/sdk.js +5 -42
- package/src/sdk/utils/appInsights.js +2 -2
- package/src/sdk/utils/cookies.js +1 -18
- package/src/sdk/utils/loadDeepLink.js +13 -40
- package/src/sdk/widget/widget.js +107 -159
- package/src/widget/components/index.js +48 -52
- package/src/widget/components/tb-notification-button/facebook.js +48 -55
- package/src/widget/components/tb-notification-button/skype.js +47 -0
- package/src/widget/components/tb-notification-button/styles.scss +16 -240
- package/src/widget/components/tb-notification-button/telegram.js +48 -55
- package/src/widget/components/tb-notification-button/viber.js +49 -56
- package/src/widget/components/tb-notification-button/vk.js +83 -92
- package/src/widget/components/tb-notification-button/whatsapp.js +51 -58
- package/src/widget/components/tb-notification-widget/index.js +473 -694
- package/src/widget/components/tb-notification-widget/normalize.scss +1 -2
- package/src/widget/components/tb-notification-widget/styles.scss +180 -543
- package/src/widget/config.js +1 -1
- package/src/widget/icons/icon_facebook_circle.svg +2 -0
- package/src/widget/icons/icon_tg_circle.svg +10 -0
- package/src/widget/icons/icon_viber_circle.svg +10 -0
- package/src/widget/icons/icon_viber_new.svg +1 -1
- package/src/widget/icons/icon_vk_circle.svg +1 -1
- package/src/widget/icons/icon_whatsapp.svg +4 -4
- package/src/widget/icons/icon_whatsapp_circle.svg +2 -2
- package/src/widget/icons/icon_whatsapp_new.svg +2 -2
- package/src/widget/icons/text-back-badge.png +0 -0
- package/src/widget/locales/cz.js +20 -0
- package/src/widget/locales/en.js +20 -42
- package/src/widget/locales/index.js +8 -8
- package/src/widget/locales/pl.js +20 -42
- package/src/widget/locales/ro.js +19 -40
- package/src/widget/locales/ru.js +20 -41
- package/src/widget/locales/uk.js +20 -41
- package/src/widget/utils/getLocale.js +14 -16
- package/src/widget/utils/stringifyAttributes.js +1 -1
- package/src/widget/utils/text.js +8 -9
- package/src/widget/widget.entry.js +1 -0
- package/tests/gf.html +2 -2
- package/v8-compile-cache-0/5.1.281.102/zSvstszSagentzS_workzS5zSszSnode_moduleszSwebpack-clizSbinzScli.js.BLOB +0 -0
- package/v8-compile-cache-0/5.1.281.102/zSvstszSagentzS_workzS5zSszSnode_moduleszSwebpack-clizSbinzScli.js.MAP +1 -0
- package/views/examples.ejs +47 -51
- package/views/sdk.html +17 -35
- package/webpack.dev.js +2 -2
- package/src/sdk/channels/whatsappb.js +0 -27
- package/src/widget/components/tb-notification-button/whatsappb.js +0 -58
- package/src/widget/components/tb-nw-wahunter/index.js +0 -261
- package/src/widget/components/tb-nw-wahunter/styles.scss +0 -471
- package/src/widget/icons/icon_chat_window.svg +0 -1
- package/src/widget/icons/icon_close.svg +0 -1
- package/src/widget/icons/icon_whatsapp_hollow.svg +0 -128
- package/src/widget/icons/icon_whatsappb.svg +0 -147
- package/src/widget/icons/icon_whatsappb_circle.svg +0 -4
- package/src/widget/icons/icon_whatsappb_new.svg +0 -127
- package/src/widget/icons/paper-plane-arrow.svg +0 -3
- package/src/widget/icons/tb-logo-dark-en.svg +0 -17
- package/src/widget/icons/tb-logo-dark-ru.svg +0 -17
- package/src/widget/icons/tb-logo-dark.svg +0 -16
- package/src/widget/icons/tb-logo-light-en.svg +0 -17
- package/src/widget/icons/tb-logo-light-ru.svg +0 -17
- package/src/widget/icons/tb-logo-white.svg +0 -16
- package/src/widget/icons/tb-logo.svg +0 -16
- package/src/widget/locales/cs.js +0 -42
@@ -1,694 +1,473 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
|
4
|
-
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
|
10
|
-
|
11
|
-
import
|
12
|
-
|
13
|
-
|
14
|
-
import
|
15
|
-
import
|
16
|
-
import
|
17
|
-
|
18
|
-
import
|
19
|
-
import
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
};
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
}
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
if (isPopupWithImage) {
|
476
|
-
popupBodyStyleClass += ` ${popupBodyStyleClass}_image-align_${imageUrlNotEmpty ? markUp.image.align : 'none'}`
|
477
|
-
}
|
478
|
-
|
479
|
-
return `
|
480
|
-
<tb-notification-widget-inner id="tb-notification-widget-inner" class="tb-notification-widget-inner">
|
481
|
-
<tb-notification-widget-overlay class="hidden">
|
482
|
-
<tb-notification-widget-popup class="${popupStyleClass}">
|
483
|
-
<span id="tb-notification-widget-close" class="tb-notification-widget-close-icon">×</span>
|
484
|
-
${this.getTbBrandBadge(this.config)}
|
485
|
-
<tb-notification-widget-popup-body class="${popupBodyStyleClass}">
|
486
|
-
${(markUp.image && markUp.image.show) ? this.image : this.icon}
|
487
|
-
<tb-notification-widget-popup-main>
|
488
|
-
${this.header}
|
489
|
-
${this.description}
|
490
|
-
<div class="tb-widget-buttons tb-btn-align-center ${buttonsStyleClass}">${body}</div>
|
491
|
-
</tb-notification-widget-popup-main>
|
492
|
-
</tb-notification-widget-popup-body>
|
493
|
-
</tb-notification-widget-popup>
|
494
|
-
</tb-notification-widget-overlay>
|
495
|
-
</tb-notification-widget-inner>
|
496
|
-
`;
|
497
|
-
}
|
498
|
-
|
499
|
-
get inlineTemplate() {
|
500
|
-
|
501
|
-
this.element.className = (this.config.type === constants.WIDGET_TYPE_WIDGET ? 'tb-no-api-call' : '');
|
502
|
-
|
503
|
-
const buttonsContainerClasses = this.config.type === constants.WIDGET_TYPE_WIDGET
|
504
|
-
? this.getButtonsClasses()
|
505
|
-
: 'tb-btn-style-rounded tb-btn-mode-horizontal tb-btn-align-left';
|
506
|
-
|
507
|
-
const channels = this.widget.getEnabledChannels();
|
508
|
-
|
509
|
-
const body = channels.map((channel, index) => {
|
510
|
-
const item = assign({}, channel.config, { type: this.config.type, markUp: this.config.markUp.buttons });
|
511
|
-
const attributes = stringifyAttributes({
|
512
|
-
channel: item.channel,
|
513
|
-
config: item,
|
514
|
-
});
|
515
|
-
|
516
|
-
if (item.enabled) {
|
517
|
-
let html = `<tb-notification-button id="tb-notification-button-${index}" ${attributes}></tb-notification-button>`;
|
518
|
-
if (this.config.markUp.buttons.displayMode === 'vertical') {
|
519
|
-
html = `<div>${html}</div>`;
|
520
|
-
}
|
521
|
-
return html;
|
522
|
-
} else {
|
523
|
-
return '';
|
524
|
-
}
|
525
|
-
}).join('');
|
526
|
-
|
527
|
-
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.inline.show', 'displaySettings');
|
528
|
-
|
529
|
-
if (this.config.widgetKind === 'WAHUNTER') {
|
530
|
-
return `
|
531
|
-
<tb-notification-widget-inner id="tb-notification-widget-inner" class="tb-notification-widget-inner">
|
532
|
-
<tb-nw-wahunter class="tb-nw-wahunter tb-nw-wahunter_mode_inline tb-nw-wahunter_inline-mode-align_${this.config.markUp.buttons.align}"></tb-nw-wahunter>
|
533
|
-
</tb-notification-widget-inner>
|
534
|
-
`;
|
535
|
-
}
|
536
|
-
|
537
|
-
return `
|
538
|
-
<tb-notification-widget-inner id="tb-notification-widget-inner" class="tb-notification-widget-inner">
|
539
|
-
<div class="tb-widget-buttons ${buttonsContainerClasses}">
|
540
|
-
${body}
|
541
|
-
</div>
|
542
|
-
</tb-notification-widget-inner>
|
543
|
-
`;
|
544
|
-
}
|
545
|
-
|
546
|
-
get cornerPopupTemplate() {
|
547
|
-
const markUp = this.config.markUp;
|
548
|
-
|
549
|
-
if (this.config.widgetKind === 'WAHUNTER') {
|
550
|
-
return `
|
551
|
-
<tb-notification-widget-inner id="tb-notification-widget-inner" class="tb-notification-widget-inner">
|
552
|
-
<tb-notification-widget-corner-popup>
|
553
|
-
<tb-widget-corner-popup-window class="${this.pallet}">
|
554
|
-
<div class="tb-fullscreen-close-rectangle">
|
555
|
-
${iconClose}
|
556
|
-
</div>
|
557
|
-
<tb-nw-wahunter class="tb-nw-wahunter tb-nw-wahunter_mode_corner-popup"></tb-nw-wahunter>
|
558
|
-
${this.getTbBrandBadge(this.config)}
|
559
|
-
</tb-widget-corner-popup-window>
|
560
|
-
<tb-widget-corner-popup-button style="background: ${markUp.wahunterButton.color}">
|
561
|
-
${iconChatWindow}
|
562
|
-
${iconClose}
|
563
|
-
</tb-widget-corner-popup-button>
|
564
|
-
<tb-widget-corner-popup-tooltip-container
|
565
|
-
class="${markUp.description.showOnMobile ? 'tb-widget-corner-popup-tooltip-container_show-on-mobile' : ''}"
|
566
|
-
style="${markUp.description.value.trim() ? '' : 'display:none'}"
|
567
|
-
>
|
568
|
-
<tb-widget-corner-popup-tooltip style="color:${markUp.description.color}">\
|
569
|
-
${markUp.description.value}\
|
570
|
-
</tb-widget-corner-popup-tooltip>
|
571
|
-
<tb-widget-corner-popup-tooltip-arrow />
|
572
|
-
</tb-widget-corner-popup-tooltip-container>
|
573
|
-
</tb-notification-widget-corner-popup>
|
574
|
-
</tb-notification-widget-inner>
|
575
|
-
`;
|
576
|
-
}
|
577
|
-
|
578
|
-
return '';
|
579
|
-
}
|
580
|
-
|
581
|
-
static get tagName() {
|
582
|
-
return 'tb-notification-widget';
|
583
|
-
}
|
584
|
-
|
585
|
-
static getWidget(widgetId) {
|
586
|
-
return widgetsStorage.getWidget(widgetId);
|
587
|
-
}
|
588
|
-
|
589
|
-
show() {
|
590
|
-
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
591
|
-
const popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
592
|
-
if (popup.className.indexOf('hidden') !== -1 || popup.className.indexOf('closed')) {
|
593
|
-
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.show', 'manual');
|
594
|
-
}
|
595
|
-
popup.className = '';
|
596
|
-
}
|
597
|
-
}
|
598
|
-
|
599
|
-
showWithRules() {
|
600
|
-
let showWidgetSetting = this.config.showWidgetSetting;
|
601
|
-
let sessionShowCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_s_show_counter';
|
602
|
-
let daysShowCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_days_show_counter';
|
603
|
-
let daysCloseCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_days_close_counter';
|
604
|
-
let totalCloseCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_total_close_counter';
|
605
|
-
|
606
|
-
if (showWidgetSetting) {
|
607
|
-
if (!showWidgetSetting.showIfSubscribed && this.widgetSubscriptions.length > 0) {
|
608
|
-
return false;
|
609
|
-
}
|
610
|
-
|
611
|
-
let daysTimeout = showWidgetSetting.showAfterDays * constants.SECONDS_IN_DAY;
|
612
|
-
let sessionTimeout = showWidgetSetting.showSessionLength * 60;
|
613
|
-
let daysShowCounter = cookiesEx.incrementIntCookie(daysShowCounterName, daysTimeout);
|
614
|
-
let sessionShowCounter = cookiesEx.incrementIntCookie(sessionShowCounterName, sessionTimeout);
|
615
|
-
let daysCloseCounter = cookiesEx.getIntCookie(daysCloseCounterName) || 0;
|
616
|
-
let totalCloseCounter = cookiesEx.getIntCookie(totalCloseCounterName) || 0;
|
617
|
-
|
618
|
-
if (sessionShowCounter > showWidgetSetting.showTimesInSession ||
|
619
|
-
(showWidgetSetting.showTimesInRow > 0 && daysShowCounter > showWidgetSetting.showTimesInRow) ||
|
620
|
-
(showWidgetSetting.closeTimesInRow > 0 && daysCloseCounter >= showWidgetSetting.closeTimesInRow) ||
|
621
|
-
(showWidgetSetting.closeTimesInTotal > 0 && totalCloseCounter >= showWidgetSetting.closeTimesInTotal)) {
|
622
|
-
return false;
|
623
|
-
}
|
624
|
-
}
|
625
|
-
|
626
|
-
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
627
|
-
const popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
628
|
-
if (popup.className.indexOf('hidden') !== -1 || popup.className.indexOf('closed')) {
|
629
|
-
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.show', 'manual');
|
630
|
-
}
|
631
|
-
popup.className = '';
|
632
|
-
return popup;
|
633
|
-
}
|
634
|
-
|
635
|
-
return false;
|
636
|
-
}
|
637
|
-
|
638
|
-
hide() {
|
639
|
-
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
640
|
-
const popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
641
|
-
if (popup.className.indexOf('hidden') !== -1) {
|
642
|
-
popup.className += 'hidden';
|
643
|
-
}
|
644
|
-
}
|
645
|
-
}
|
646
|
-
|
647
|
-
getButtonsClasses() {
|
648
|
-
const classes = [];
|
649
|
-
|
650
|
-
if (this.config.markUp && this.config.markUp.buttons) {
|
651
|
-
const markUp = this.config.markUp.buttons;
|
652
|
-
classes.push(getButtonsStyleClass(markUp.style));
|
653
|
-
classes.push(getButtonsAlignmentClass(markUp.align));
|
654
|
-
classes.push(getButtonsDisplayModeClass(markUp.displayMode));
|
655
|
-
}
|
656
|
-
|
657
|
-
function getButtonsStyleClass(style) {
|
658
|
-
const prefix = 'tb-btn-style';
|
659
|
-
switch (style) {
|
660
|
-
case 'rounded':
|
661
|
-
return `${prefix}-rounded`;
|
662
|
-
case 'icons':
|
663
|
-
return `${prefix}-icons`;
|
664
|
-
case 'gradient':
|
665
|
-
return `${prefix}-gradient`;
|
666
|
-
default:
|
667
|
-
return `${prefix}-square`;
|
668
|
-
}
|
669
|
-
}
|
670
|
-
|
671
|
-
function getButtonsAlignmentClass(align) {
|
672
|
-
const prefix = 'tb-btn-align';
|
673
|
-
switch (align) {
|
674
|
-
case 'left':
|
675
|
-
return `${prefix}-left`;
|
676
|
-
case 'right':
|
677
|
-
return `${prefix}-right`;
|
678
|
-
default:
|
679
|
-
return `${prefix}-center`;
|
680
|
-
}
|
681
|
-
}
|
682
|
-
|
683
|
-
function getButtonsDisplayModeClass(mode) {
|
684
|
-
const prefix = 'tb-btn-mode';
|
685
|
-
if (mode === 'vertical') {
|
686
|
-
return `${prefix}-vertical`;
|
687
|
-
} else {
|
688
|
-
return `${prefix}-horizontal`;
|
689
|
-
}
|
690
|
-
}
|
691
|
-
|
692
|
-
return classes.join(' ');
|
693
|
-
}
|
694
|
-
};
|
1
|
+
import assign from 'lodash/assign';
|
2
|
+
import Component from '../index.js';
|
3
|
+
|
4
|
+
import stringifyAttributes from '../../utils/stringifyAttributes.js';
|
5
|
+
import cookiesEx from '../../utils/cookiesEx.js';
|
6
|
+
import appInsights from '../../../sdk/utils/appInsights';
|
7
|
+
import config from '../../config';
|
8
|
+
import widgetsStorage from '../../utils/widgetsStorage.js';
|
9
|
+
|
10
|
+
import constants from '../../../sdk/utils/constants';
|
11
|
+
import SDK from '../../../sdk/index.js';
|
12
|
+
|
13
|
+
import iconBell from '../../icons/bell-icon.png';
|
14
|
+
import iconBroadcast from '../../icons/broadcast-icon.png';
|
15
|
+
import iconPaperPlane from '../../icons/paper-plane-icon.png';
|
16
|
+
import iconTextBackBadge from '../../icons/text-back-badge.png';
|
17
|
+
|
18
|
+
import './normalize.scss';
|
19
|
+
import './styles.scss';
|
20
|
+
|
21
|
+
const channelButtons = {
|
22
|
+
vk: require('../tb-notification-button/vk'),
|
23
|
+
tg: require('../tb-notification-button/telegram'),
|
24
|
+
facebook: require('../tb-notification-button/facebook'),
|
25
|
+
skype: require('../tb-notification-button/skype'),
|
26
|
+
viber: require('../tb-notification-button/viber'),
|
27
|
+
whatsapp: require('../tb-notification-button/whatsapp')
|
28
|
+
};
|
29
|
+
|
30
|
+
|
31
|
+
const DEFAULT_BUTTONS_MARKUP = {
|
32
|
+
style: 'square',
|
33
|
+
displayMode: 'horizontal',
|
34
|
+
align: 'center',
|
35
|
+
};
|
36
|
+
|
37
|
+
export default class Widget extends Component {
|
38
|
+
constructor() {
|
39
|
+
super(...arguments);
|
40
|
+
|
41
|
+
this.apiPath = this.apiPath || config.apiPath;
|
42
|
+
this.onlyManual = this.onlyManual || this.element.hasAttribute('only-manual');
|
43
|
+
|
44
|
+
const predefinedConfig = this.widgetConfig;
|
45
|
+
|
46
|
+
//override widgetId property with data from widgetConfig
|
47
|
+
if (!!predefinedConfig) {
|
48
|
+
this.widgetId = predefinedConfig.id;
|
49
|
+
}
|
50
|
+
|
51
|
+
let widgetInitPromise = SDK.getWidget(this.widgetId);
|
52
|
+
if (!widgetInitPromise) {
|
53
|
+
// init widget
|
54
|
+
widgetInitPromise = SDK.initWidget({
|
55
|
+
widgetId: this.widgetId,
|
56
|
+
apiPath: this.apiPath,
|
57
|
+
insecureContext: this.data,
|
58
|
+
secureContextToken: this.secureContextToken,
|
59
|
+
overrideConfig: predefinedConfig,
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
widgetInitPromise = widgetInitPromise
|
64
|
+
.then(widget => {
|
65
|
+
this.widget = widget;
|
66
|
+
|
67
|
+
this.widgetUserId = widget.widgetUserId;
|
68
|
+
this.config = widget.getConfig();
|
69
|
+
this.config.type = this.config.type || constants.DEFAULT_WIDGET_TYPE;
|
70
|
+
this.config.markUp = this.config.markUp || {};
|
71
|
+
this.config.markUp.buttons = assign({}, DEFAULT_BUTTONS_MARKUP, this.config.markUp.buttons);
|
72
|
+
|
73
|
+
this.widgetSubscriptions = widget.subscriptions;
|
74
|
+
this.deepLink = widget.deeplink;
|
75
|
+
const aiKey = widget.aiKey;
|
76
|
+
|
77
|
+
return appInsights.init(aiKey, this.widgetUserId, this.config.accountId);
|
78
|
+
})
|
79
|
+
.then(res => {
|
80
|
+
this.set({
|
81
|
+
ready: true
|
82
|
+
});
|
83
|
+
return this;
|
84
|
+
}, err => {
|
85
|
+
console.error(err);
|
86
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.error', err);
|
87
|
+
this.set({error: err});
|
88
|
+
return this;
|
89
|
+
});
|
90
|
+
|
91
|
+
widgetsStorage.setWidget(this.widgetId, widgetInitPromise);
|
92
|
+
}
|
93
|
+
|
94
|
+
get defaults() {
|
95
|
+
return {
|
96
|
+
widgetId: this.element.getAttribute('widget-id'),
|
97
|
+
secureContextToken: this.element.getAttribute('secure-context-token'),
|
98
|
+
apiPath: this.element.getAttribute('api-path') || config.apiPath
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
render() {
|
103
|
+
super.render();
|
104
|
+
|
105
|
+
this.element.id = this.element.id ? this.element.id : 'tb-notification-widget';
|
106
|
+
|
107
|
+
const buttons = this.element.querySelectorAll('tb-notification-button');
|
108
|
+
|
109
|
+
if (buttons) {
|
110
|
+
for (let i = 0; i < buttons.length; i++) {
|
111
|
+
const channel = buttons[i].getAttribute('channel');
|
112
|
+
new channelButtons[channel]({
|
113
|
+
element: buttons[i],
|
114
|
+
accountId: this.config.accountId,
|
115
|
+
userId: this.userId,
|
116
|
+
apiPath: this.apiPath,
|
117
|
+
insecureContext: this.data,
|
118
|
+
secureContextToken: this.secureContextToken,
|
119
|
+
deepLink: this.deepLink,
|
120
|
+
lang: this.lang,
|
121
|
+
vkApiId: this.config.vkApiId,
|
122
|
+
widgetId: this.config.id,
|
123
|
+
widget: this,
|
124
|
+
widgetAPI: this.widget,
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
130
|
+
let sessionShowCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_s_show_counter';
|
131
|
+
let daysShowCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_days_show_counter';
|
132
|
+
let daysCloseCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_days_close_counter';
|
133
|
+
let totalCloseCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_total_close_counter';
|
134
|
+
|
135
|
+
let showWidgetSetting = this.config.showWidgetSetting;
|
136
|
+
|
137
|
+
let popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
138
|
+
this.element.querySelector('#tb-notification-widget-close').addEventListener("click", (e) => {
|
139
|
+
popup.className += " hidden closed";
|
140
|
+
e.preventDefault();
|
141
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.click.close', 'userAction');
|
142
|
+
if (showWidgetSetting) {
|
143
|
+
let daysTimeout = showWidgetSetting.showAfterDays * constants.SECONDS_IN_DAY;
|
144
|
+
|
145
|
+
cookiesEx.incrementIntCookie(daysCloseCounterName, daysTimeout);
|
146
|
+
cookiesEx.incrementIntCookie(totalCloseCounterName, constants.WIDGET_USER_ID_COOKIE_TTL);
|
147
|
+
}
|
148
|
+
});
|
149
|
+
|
150
|
+
|
151
|
+
if (showWidgetSetting) {
|
152
|
+
if (!showWidgetSetting.showIfSubscribed && this.widgetSubscriptions.length > 0) {
|
153
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.notShown', 'alreadySubscribed');
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
let daysTimeout = showWidgetSetting.showAfterDays * constants.SECONDS_IN_DAY;
|
159
|
+
let sessionTimeout = showWidgetSetting.showSessionLength * 60;
|
160
|
+
|
161
|
+
let daysShowCounter = cookiesEx.incrementIntCookie(daysShowCounterName, daysTimeout);
|
162
|
+
let sessionShowCounter = cookiesEx.incrementIntCookie(sessionShowCounterName, sessionTimeout);
|
163
|
+
let daysCloseCounter = cookiesEx.getIntCookie(daysCloseCounterName) || 0;
|
164
|
+
let totalCloseCounter = cookiesEx.getIntCookie(totalCloseCounterName) || 0;
|
165
|
+
|
166
|
+
const sendNonDisplayed = (reason) => {
|
167
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.notShown', reason);
|
168
|
+
return true;
|
169
|
+
};
|
170
|
+
|
171
|
+
if (sessionShowCounter > showWidgetSetting.showTimesInSession && sendNonDisplayed('timesPerSession')|| // Не более N раз в сессию
|
172
|
+
(showWidgetSetting.showTimesInRow > 0 && daysShowCounter > showWidgetSetting.showTimesInRow && sendNonDisplayed('timesPerDays')) ||// Не более N раз в M дней
|
173
|
+
(showWidgetSetting.closeTimesInRow > 0 && daysCloseCounter >= showWidgetSetting.closeTimesInRow && sendNonDisplayed('closedTimesPerDays')) || // Не более N закрытий в M дней
|
174
|
+
(showWidgetSetting.closeTimesInTotal > 0 && totalCloseCounter >= showWidgetSetting.closeTimesInTotal && sendNonDisplayed('closedTimes')) // Не более N закрытий всего
|
175
|
+
) {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
if (this.onlyManual) {
|
181
|
+
popup.className = 'hidden';
|
182
|
+
return;
|
183
|
+
}
|
184
|
+
|
185
|
+
if (this.config.displayOptions && (this.config.displayOptions.onTimeout || this.config.displayOptions.onLeave)) {
|
186
|
+
let telemetryFlag = false;
|
187
|
+
if (this.config.displayOptions.onTimeout) {
|
188
|
+
setTimeout(() => {
|
189
|
+
if(popup.className.indexOf('closed') === -1 && !telemetryFlag){
|
190
|
+
telemetryFlag = true;
|
191
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.show', 'timeout');
|
192
|
+
}
|
193
|
+
popup.className = popup.className.indexOf('closed') === -1 ? "" : popup.className;
|
194
|
+
}, +this.config.displayOptions.timeoutDelay * 1000);
|
195
|
+
}
|
196
|
+
if (this.config.displayOptions.onLeave) {
|
197
|
+
document.addEventListener('mousemove', (e) => {
|
198
|
+
if (e.clientY < 50) {
|
199
|
+
if(popup.className.indexOf('closed') === -1 && !telemetryFlag){
|
200
|
+
telemetryFlag = true;
|
201
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.show', 'onLeave');
|
202
|
+
}
|
203
|
+
popup.className = popup.className.indexOf('closed') === -1 ? "" : popup.className;
|
204
|
+
}
|
205
|
+
});
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
get header() {
|
212
|
+
if (this.config.markUp && this.config.markUp.header && this.config.markUp.header.value) {
|
213
|
+
var color = this.config.markUp.header.color ? 'style="color: ' + this.config.markUp.header.color + '"' : undefined;
|
214
|
+
var result = '';
|
215
|
+
|
216
|
+
result += '<tb-widget-header-line ' + color + ' class="tb-widget-header-line">' + this.config.markUp.header.value + '</tb-widget-header-line>';
|
217
|
+
|
218
|
+
return '<tb-widget-header-container>' + result + '</tb-widget-header-container>';
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
return '';
|
222
|
+
}
|
223
|
+
|
224
|
+
}
|
225
|
+
|
226
|
+
get description() {
|
227
|
+
if (this.config.markUp && this.config.markUp.description && this.config.markUp.description.value) {
|
228
|
+
var color = this.config.markUp.description.color ? 'style="color: ' + this.config.markUp.description.color + '"' : undefined;
|
229
|
+
var result = '';
|
230
|
+
|
231
|
+
result += '<tb-widget-description-line ' + color + ' class="tb-widget-description-line">' + this.config.markUp.description.value + '</tb-widget-description-line>'
|
232
|
+
|
233
|
+
return '<tb-widget-description-container>' + result + '</tb-widget-description-container>';
|
234
|
+
}
|
235
|
+
else {
|
236
|
+
return '';
|
237
|
+
}
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
static iconPreset(val) {
|
242
|
+
switch (val) {
|
243
|
+
case 'widgetIconBell':
|
244
|
+
return iconBell;
|
245
|
+
case 'widgetIconBroadcast':
|
246
|
+
return iconBroadcast;
|
247
|
+
case 'widgetIconPaperPlane':
|
248
|
+
return iconPaperPlane;
|
249
|
+
case 'text-back-badge':
|
250
|
+
return iconTextBackBadge;
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
get icon() {
|
256
|
+
if (this.config.markUp && this.config.markUp.icon && this.config.markUp.icon.type === "custom") {
|
257
|
+
return '<tb-notification-widget-icon_body>'
|
258
|
+
+ '<img src="' + this.config.markUp.icon.url + '">'
|
259
|
+
+ '</tb-notification-widget-icon_body>'
|
260
|
+
}
|
261
|
+
if (this.config.markUp && this.config.markUp.icon && this.config.markUp.icon.type === "preset") {
|
262
|
+
return '<tb-notification-widget-icon_body>'
|
263
|
+
+ '<img src="' + Widget.iconPreset(this.config.markUp.icon.value) + '">'
|
264
|
+
+ '</tb-notification-widget-icon_body>'
|
265
|
+
}
|
266
|
+
else {
|
267
|
+
return '';
|
268
|
+
}
|
269
|
+
|
270
|
+
}
|
271
|
+
|
272
|
+
get pallet() {
|
273
|
+
return this.config && this.config.markUp.body.palette && this.config.markUp.body.palette === "light" ? 'pallet-light' : 'pallet-dark'
|
274
|
+
}
|
275
|
+
|
276
|
+
get template() {
|
277
|
+
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
278
|
+
this.element.className = (this.config.type === constants.WIDGET_TYPE_WIDGET ? 'tb-no-api-call' : '');
|
279
|
+
|
280
|
+
const buttonsStyle = (this.config.type === constants.WIDGET_TYPE_WIDGET ? 'square' : 'rounded'),
|
281
|
+
buttonsStyleClass = (this.config.type === constants.WIDGET_TYPE_WIDGET ? 'tb-btn-style-square' : 'tb-btn-style-rounded');
|
282
|
+
|
283
|
+
var body = '';
|
284
|
+
if (this.ready) {
|
285
|
+
const channels = this.widget.getEnabledChannels();
|
286
|
+
body = channels.map((channel, index) => {
|
287
|
+
const item = assign({}, channel.config, {
|
288
|
+
type: this.config.type,
|
289
|
+
markUp: assign({}, this.config.markUp.buttons, { style: buttonsStyle }),
|
290
|
+
});
|
291
|
+
const attributes = stringifyAttributes({
|
292
|
+
channel: item.channel,
|
293
|
+
config: item,
|
294
|
+
});
|
295
|
+
|
296
|
+
return item.enabled ? `<div><tb-notification-button id="tb-notification-button-${index}" ${attributes}></tb-notification-button></div>` : '';
|
297
|
+
}).join('');
|
298
|
+
} else if (this.error) {
|
299
|
+
console.warn('could not render widget. reason: ' + this.error);
|
300
|
+
body = '';
|
301
|
+
} else {
|
302
|
+
body = '';
|
303
|
+
}
|
304
|
+
|
305
|
+
return `<tb-notification-widget-inner id="tb-notification-widget-inner" class="tb-notification-widget-inner"><tb-notification-widget-overlay class="hidden">
|
306
|
+
<tb-notification-widget-popup class="${this.pallet}">
|
307
|
+
<span id="tb-notification-widget-close" class="tb-notification-widget-close-icon">×</span>
|
308
|
+
<a target="_blank" href="//textback.ru/?utm_source=${window.location.host}&utm_medium=link&utm_content=notify_widget_opened&utm_campaign=ref_ad">
|
309
|
+
<img id="tb-notification-brand-badge" src="${Widget.iconPreset('text-back-badge')}">
|
310
|
+
</a>
|
311
|
+
${this.icon}
|
312
|
+
${this.header}
|
313
|
+
${this.description}
|
314
|
+
<div class="tb-widget-buttons tb-btn-align-center ${buttonsStyleClass}">${body}</div>
|
315
|
+
</tb-notification-widget-popup>
|
316
|
+
</tb-notification-widget-overlay></tb-notification-widget-inner>`;
|
317
|
+
|
318
|
+
} else {
|
319
|
+
if (this.ready) {
|
320
|
+
this.element.className = (this.config.type === constants.WIDGET_TYPE_WIDGET ? 'tb-no-api-call' : '');
|
321
|
+
const buttonsContainerClasses = (this.config.type === constants.WIDGET_TYPE_WIDGET
|
322
|
+
? this.getButtonsClasses()
|
323
|
+
: 'tb-btn-style-rounded tb-btn-mode-horizontal tb-btn-align-left');
|
324
|
+
// let
|
325
|
+
|
326
|
+
const channels = this.widget.getEnabledChannels();
|
327
|
+
const body = channels.map((channel, index) => {
|
328
|
+
const item = assign({}, channel.config, { type: this.config.type, markUp: this.config.markUp.buttons });
|
329
|
+
const attributes = stringifyAttributes({
|
330
|
+
channel: item.channel,
|
331
|
+
config: item,
|
332
|
+
});
|
333
|
+
|
334
|
+
if (item.enabled) {
|
335
|
+
let html = `<tb-notification-button id="tb-notification-button-${index}" ${attributes}></tb-notification-button>`;
|
336
|
+
if (this.config.markUp.buttons.displayMode === 'vertical') {
|
337
|
+
html = `<div>${html}</div>`;
|
338
|
+
}
|
339
|
+
return html;
|
340
|
+
} else {
|
341
|
+
return '';
|
342
|
+
}
|
343
|
+
}).join('');
|
344
|
+
|
345
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.inline.show', 'displaySettings');
|
346
|
+
return `<tb-notification-widget-inner id="tb-notification-widget-inner" class="tb-notification-widget-inner">
|
347
|
+
<div class="tb-widget-buttons ${buttonsContainerClasses}">
|
348
|
+
${body}
|
349
|
+
</div>
|
350
|
+
</tb-notification-widget-inner>`;
|
351
|
+
} else if (this.error) {
|
352
|
+
console.warn('could not render widget. reason: ' + this.error);
|
353
|
+
return '';
|
354
|
+
} else {
|
355
|
+
return ''
|
356
|
+
}
|
357
|
+
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
static get tagName() {
|
362
|
+
return 'tb-notification-widget';
|
363
|
+
}
|
364
|
+
|
365
|
+
static getWidget(widgetId) {
|
366
|
+
return widgetsStorage.getWidget(widgetId);
|
367
|
+
}
|
368
|
+
|
369
|
+
show() {
|
370
|
+
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
371
|
+
const popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
372
|
+
if (popup.className.indexOf('hidden') !== -1 || popup.className.indexOf('closed')) {
|
373
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.show', 'manual');
|
374
|
+
}
|
375
|
+
popup.className = '';
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
showWithRules() {
|
380
|
+
let showWidgetSetting = this.config.showWidgetSetting;
|
381
|
+
let sessionShowCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_s_show_counter';
|
382
|
+
let daysShowCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_days_show_counter';
|
383
|
+
let daysCloseCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_days_close_counter';
|
384
|
+
let totalCloseCounterName = constants.COOKIE_NAME_PREFIX + this.widgetId + '_total_close_counter';
|
385
|
+
|
386
|
+
if (showWidgetSetting) {
|
387
|
+
if (!showWidgetSetting.showIfSubscribed && this.widgetSubscriptions.length > 0) {
|
388
|
+
return false;
|
389
|
+
}
|
390
|
+
|
391
|
+
let daysTimeout = showWidgetSetting.showAfterDays * constants.SECONDS_IN_DAY;
|
392
|
+
let sessionTimeout = showWidgetSetting.showSessionLength * 60;
|
393
|
+
let daysShowCounter = cookiesEx.incrementIntCookie(daysShowCounterName, daysTimeout);
|
394
|
+
let sessionShowCounter = cookiesEx.incrementIntCookie(sessionShowCounterName, sessionTimeout);
|
395
|
+
let daysCloseCounter = cookiesEx.getIntCookie(daysCloseCounterName) || 0;
|
396
|
+
let totalCloseCounter = cookiesEx.getIntCookie(totalCloseCounterName) || 0;
|
397
|
+
|
398
|
+
if (sessionShowCounter > showWidgetSetting.showTimesInSession ||
|
399
|
+
(showWidgetSetting.showTimesInRow > 0 && daysShowCounter > showWidgetSetting.showTimesInRow) ||
|
400
|
+
(showWidgetSetting.closeTimesInRow > 0 && daysCloseCounter >= showWidgetSetting.closeTimesInRow) ||
|
401
|
+
(showWidgetSetting.closeTimesInTotal > 0 && totalCloseCounter >= showWidgetSetting.closeTimesInTotal)) {
|
402
|
+
return false;
|
403
|
+
}
|
404
|
+
}
|
405
|
+
|
406
|
+
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
407
|
+
const popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
408
|
+
if (popup.className.indexOf('hidden') !== -1 || popup.className.indexOf('closed')) {
|
409
|
+
appInsights.trackWidgetEvent(this.config.id, 'notificationWidget.popup.show', 'manual');
|
410
|
+
}
|
411
|
+
popup.className = '';
|
412
|
+
return popup;
|
413
|
+
}
|
414
|
+
|
415
|
+
return false;
|
416
|
+
}
|
417
|
+
|
418
|
+
hide() {
|
419
|
+
if (this.config && this.config.displayMode && this.config.displayMode === "popup") {
|
420
|
+
const popup = this.element.getElementsByTagName("tb-notification-widget-overlay")[0];
|
421
|
+
if (popup.className.indexOf('hidden') !== -1) {
|
422
|
+
popup.className += 'hidden';
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
getButtonsClasses() {
|
428
|
+
console.log(this.config);
|
429
|
+
const classes = [];
|
430
|
+
|
431
|
+
if (this.config.markUp && this.config.markUp.buttons) {
|
432
|
+
const markUp = this.config.markUp.buttons;
|
433
|
+
classes.push( getButtonsStyleClass(markUp.style) );
|
434
|
+
classes.push( getButtonsAlignmentClass(markUp.align) );
|
435
|
+
classes.push( getButtonsDisplayModeClass(markUp.displayMode) );
|
436
|
+
}
|
437
|
+
|
438
|
+
function getButtonsStyleClass(style) {
|
439
|
+
const prefix = 'tb-btn-style';
|
440
|
+
switch (style) {
|
441
|
+
case 'rounded':
|
442
|
+
return `${prefix}-rounded`;
|
443
|
+
case 'icons':
|
444
|
+
return `${prefix}-icons`;
|
445
|
+
default:
|
446
|
+
return `${prefix}-square`;
|
447
|
+
}
|
448
|
+
}
|
449
|
+
|
450
|
+
function getButtonsAlignmentClass(align) {
|
451
|
+
const prefix = 'tb-btn-align';
|
452
|
+
switch (align) {
|
453
|
+
case 'left':
|
454
|
+
return `${prefix}-left`;
|
455
|
+
case 'right':
|
456
|
+
return `${prefix}-right`;
|
457
|
+
default:
|
458
|
+
return `${prefix}-center`;
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
462
|
+
function getButtonsDisplayModeClass(mode) {
|
463
|
+
const prefix = 'tb-btn-mode';
|
464
|
+
if (mode === 'vertical') {
|
465
|
+
return `${prefix}-vertical`;
|
466
|
+
} else {
|
467
|
+
return `${prefix}-horizontal`;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
|
471
|
+
return classes.join(' ');
|
472
|
+
}
|
473
|
+
};
|