@textback/notification-widget 2.0.0 → 2.0.1-102913
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +291 -291
- package/build/index.js +12 -0
- package/build/sdk.js +9 -0
- package/package.json +70 -68
- package/promote_tag.sh +1 -1
- package/readme.md +569 -490
- package/server.js +8 -4
- package/src/libraries/ai.1.0.11.js +4088 -4088
- package/src/libraries/localization/locales/cs.js +14 -12
- package/src/libraries/localization/locales/en.js +14 -12
- package/src/libraries/localization/locales/index.js +8 -8
- package/src/libraries/localization/locales/pl.js +14 -12
- package/src/libraries/localization/locales/ro.js +14 -12
- package/src/libraries/localization/locales/ru.js +13 -12
- package/src/libraries/localization/locales/uk.js +14 -12
- package/src/libraries/localization/text.js +9 -9
- package/src/libraries/t.js +82 -82
- package/src/sdk/channels/channel.js +30 -30
- package/src/sdk/channels/facebook.js +13 -13
- package/src/sdk/channels/factory.js +3 -3
- package/src/sdk/channels/skype.js +12 -12
- package/src/sdk/channels/telegram.js +18 -18
- package/src/sdk/channels/viber.js +12 -12
- package/src/sdk/channels/vk-modal/vk-modal.html +17 -17
- package/src/sdk/channels/vk-modal/vk-modal.js +25 -25
- package/src/sdk/channels/vk-modal/vk-modal.scss +116 -116
- package/src/sdk/channels/vk.js +195 -184
- package/src/sdk/channels/whatsapp.js +16 -10
- package/src/sdk/channels/whatsappb.js +27 -0
- package/src/sdk/events/observer.js +46 -46
- package/src/sdk/index.js +5 -5
- package/src/sdk/sdk.js +67 -30
- package/src/sdk/utils/apiErrorHandler.js +11 -11
- package/src/sdk/utils/appInsights.js +88 -88
- package/src/sdk/utils/browserInfo.js +8 -8
- package/src/sdk/utils/constants.js +17 -17
- package/src/sdk/utils/cookies.js +67 -50
- package/src/sdk/utils/find.js +7 -7
- package/src/sdk/utils/loadConfig.js +20 -20
- package/src/sdk/utils/loadDeepLink.js +48 -21
- package/src/sdk/utils/loadScript.js +25 -25
- package/src/sdk/utils/loadSubscriptions.js +6 -6
- package/src/sdk/utils/parseQueryString.js +33 -33
- package/src/sdk/utils/windowHelper.js +25 -25
- package/src/sdk/widget/widget.js +192 -140
- package/src/widget/components/index.js +6 -2
- package/src/widget/components/tb-notification-button/facebook.js +9 -2
- package/src/widget/components/tb-notification-button/index.js +34 -34
- package/src/widget/components/tb-notification-button/styles.scss +657 -433
- package/src/widget/components/tb-notification-button/telegram.js +9 -2
- package/src/widget/components/tb-notification-button/viber.js +9 -2
- package/src/widget/components/tb-notification-button/vk.js +59 -50
- package/src/widget/components/tb-notification-button/whatsapp.js +15 -8
- package/src/widget/components/tb-notification-button/whatsappb.js +58 -0
- package/src/widget/components/tb-notification-widget/index.js +589 -384
- package/src/widget/components/tb-notification-widget/normalize.scss +395 -394
- package/src/widget/components/tb-notification-widget/styles.scss +502 -139
- package/src/widget/components/tb-nw-wahunter/index.js +259 -0
- package/src/widget/components/tb-nw-wahunter/styles.scss +471 -0
- package/src/widget/config.js +5 -5
- package/src/widget/icons/icon_chat_window.svg +1 -0
- package/src/widget/icons/icon_close.svg +1 -0
- package/src/widget/icons/icon_facebook.svg +7 -7
- package/src/widget/icons/icon_facebook_circle.svg +7 -9
- package/src/widget/icons/icon_instagram_circle.svg +95 -95
- package/src/widget/icons/icon_skype.svg +44 -44
- package/src/widget/icons/icon_skype_circle.svg +46 -46
- package/src/widget/icons/icon_skype_new.svg +113 -113
- package/src/widget/icons/icon_tg.svg +25 -25
- package/src/widget/icons/icon_tg_circle.svg +17 -27
- package/src/widget/icons/icon_viber.svg +75 -75
- package/src/widget/icons/icon_viber_circle.svg +67 -77
- package/src/widget/icons/icon_viber_new.svg +102 -102
- package/src/widget/icons/icon_vk.svg +14 -14
- package/src/widget/icons/icon_vk_circle.svg +16 -16
- package/src/widget/icons/icon_whatsapp.svg +147 -147
- package/src/widget/icons/icon_whatsapp_circle.svg +3 -3
- package/src/widget/icons/icon_whatsapp_hollow.svg +128 -0
- package/src/widget/icons/icon_whatsapp_new.svg +127 -127
- package/src/widget/icons/icon_whatsappb.svg +147 -0
- package/src/widget/icons/icon_whatsappb_circle.svg +4 -0
- package/src/widget/icons/icon_whatsappb_new.svg +127 -0
- package/src/widget/icons/paper-plane-arrow.svg +3 -0
- package/src/widget/icons/tb-logo.svg +21 -0
- package/src/widget/index.js +28 -28
- package/src/widget/locales/cs.js +42 -0
- package/src/widget/locales/en.js +42 -20
- package/src/widget/locales/index.js +2 -2
- package/src/widget/locales/pl.js +41 -19
- package/src/widget/locales/ro.js +41 -20
- package/src/widget/locales/ru.js +40 -19
- package/src/widget/locales/uk.js +40 -19
- package/src/widget/utils/cookiesEx.js +41 -41
- package/src/widget/utils/getLocale.js +4 -2
- package/src/widget/utils/stringifyAttributes.js +19 -19
- package/src/widget/utils/text.js +2 -1
- package/src/widget/utils/widgetsStorage.js +28 -28
- package/src/widget/widget.entry.js +3 -4
- package/tests/gf.html +35 -35
- package/tests/gf.js +21 -21
- package/tests/index.js +61 -61
- package/views/examples.ejs +7 -3
- package/views/sdk.html +274 -256
- package/webpack.common.js +72 -72
- package/webpack.dev.js +15 -15
- package/webpack.prod.js +10 -10
- package/src/widget/components/tb-notification-button/skype.js +0 -47
- package/src/widget/icons/text-back-badge.png +0 -0
- package/src/widget/locales/cz.js +0 -20
@@ -22,9 +22,16 @@ class TelegramButton extends Button {
|
|
22
22
|
<tb-notification-button__text>${this.text('telegram')}</tb-notification-button__text>
|
23
23
|
</a>
|
24
24
|
<p class="tb-notification-button__tip">
|
25
|
-
${this.text('
|
25
|
+
${this.text('telegramTip')}
|
26
26
|
</p>
|
27
27
|
`;
|
28
|
+
} else if(this.config.markUp.style === 'gradient') {
|
29
|
+
return `
|
30
|
+
<a target="_blank" href="https://telegram.me/${this.config.id}?start=${this.deepLink}">
|
31
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
32
|
+
<tb-notification-button__text>${this.text('telegram')}</tb-notification-button__text>
|
33
|
+
</a>
|
34
|
+
`;
|
28
35
|
} else if (this.config.markUp.style !== 'square') {
|
29
36
|
return `
|
30
37
|
<a target="_blank" href="https://telegram.me/${this.config.id}?start=${this.deepLink}">
|
@@ -37,7 +44,7 @@ class TelegramButton extends Button {
|
|
37
44
|
<div class="tb-notification-button__inner">
|
38
45
|
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
39
46
|
<a target="_blank" href="https://telegram.me/${this.config.id}?start=${this.deepLink}">
|
40
|
-
<tb-notification-button__text>${this.text('
|
47
|
+
<tb-notification-button__text>${this.text('telegramExtended')}</tb-notification-button__text>
|
41
48
|
</a>
|
42
49
|
</div>
|
43
50
|
`;
|
@@ -23,9 +23,16 @@ class ViberButton extends Button {
|
|
23
23
|
<tb-notification-button__text>${this.text('viber')}</tb-notification-button__text>
|
24
24
|
</a>
|
25
25
|
<p class="tb-notification-button__tip">
|
26
|
-
${this.text('
|
26
|
+
${this.text('viberTip')}
|
27
27
|
</p>
|
28
28
|
`;
|
29
|
+
} else if(this.config.markUp.style === 'gradient') {
|
30
|
+
return `
|
31
|
+
<a target="_blank" href="viber://pa?chatURI=${this.config.id}&context=${this.deepLink}">
|
32
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
33
|
+
<tb-notification-button__text>${this.text('viber')}</tb-notification-button__text>
|
34
|
+
</a>
|
35
|
+
`;
|
29
36
|
} else if (this.config.markUp.style !== 'square') {
|
30
37
|
return `
|
31
38
|
<a target="_blank" href="viber://pa?chatURI=${this.config.id}&context=${this.deepLink}">
|
@@ -38,7 +45,7 @@ class ViberButton extends Button {
|
|
38
45
|
<div class="tb-notification-button__inner">
|
39
46
|
<tb-notification-button__icon>${iconNew}</tb-notification-button__icon>
|
40
47
|
<a target="_blank" href="viber://pa?chatURI=${this.config.id}&context=${this.deepLink}">
|
41
|
-
<tb-notification-button__text>${this.text('
|
48
|
+
<tb-notification-button__text>${this.text('viberExtended')}</tb-notification-button__text>
|
42
49
|
</a>
|
43
50
|
</div>
|
44
51
|
`;
|
@@ -7,77 +7,86 @@ import iconCircle from '../../icons/icon_vk_circle.svg';
|
|
7
7
|
import constants from '../../../sdk/utils/constants.js';
|
8
8
|
|
9
9
|
class VKButton extends Button {
|
10
|
-
|
11
|
-
|
10
|
+
constructor() {
|
11
|
+
super(...arguments);
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
this.useVkApp = this.widget.config.useVkApp;
|
14
|
+
this.landingUrl = this.config.additionalProperties ? this.config.additionalProperties.landingUrl : undefined;
|
15
|
+
this.element.setAttribute('type', this.config.type || 'widget');
|
15
16
|
|
16
|
-
|
17
|
+
this.buttonContainerId = UUID.create(4).hex;
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if (this.config.type === constants.WIDGET_TYPE_API_CALL) {
|
20
|
+
this.element.setAttribute('authorized', this.channelAPI.authorized);
|
21
|
+
this.element.addEventListener('click', event => {
|
22
|
+
event.preventDefault();
|
23
|
+
this.channelAPI.subscribeViaApi();
|
24
|
+
});
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
this.set({
|
27
|
+
ready: true
|
28
|
+
});
|
29
|
+
} else if (this.useVkApp || this.config.markUp.style !== 'square'|| this.config.markUp.style === 'gradient' || this.landingUrl) {
|
30
|
+
this.element.addEventListener('click', event => {
|
31
|
+
event.preventDefault();
|
32
|
+
this.channelAPI.subscribe();
|
33
|
+
});
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
this.set({
|
36
|
+
ready: true
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
this.set({
|
40
|
+
ready: true
|
41
|
+
});
|
41
42
|
|
42
|
-
|
43
|
-
}
|
43
|
+
this.channelAPI.renderVKSubscriptionButton(30, this.buttonContainerId);
|
44
44
|
}
|
45
|
+
}
|
45
46
|
|
46
47
|
|
47
48
|
get template() {
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
if (this.ready) {
|
50
|
+
if (this.config.type === constants.WIDGET_TYPE_API_CALL) {
|
51
|
+
return `
|
51
52
|
<a href="javascript:void(0)">
|
52
|
-
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
53
|
-
<tb-notification-button__text for="login">${this.text('
|
53
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
54
|
+
<tb-notification-button__text for="login">${this.text('vkontakteLogin')}</tb-notification-button__text>
|
54
55
|
<tb-notification-button__text for="subscribe">${this.text('vkontakte')}</tb-notification-button__text>
|
55
56
|
</a>
|
56
57
|
<p class="tb-notification-button__tip">
|
57
|
-
${this.text('
|
58
|
+
${this.text('vkontakteTip')}
|
58
59
|
</p>
|
59
60
|
`;
|
60
|
-
|
61
|
-
|
61
|
+
} else if(this.config.markUp.style === 'gradient') {
|
62
|
+
return `
|
63
|
+
<a class="vk-app-link" href="#">
|
64
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
65
|
+
<tb-notification-button__text>${this.text('vkontakte')}</tb-notification-button__text>
|
66
|
+
</a>
|
67
|
+
`;
|
68
|
+
} else if (this.config.markUp.style !== 'square') {
|
69
|
+
return `
|
62
70
|
<a href="#">
|
63
|
-
<tb-notification-button__icon>${(this.config.markUp.style === 'rounded' ? icon : iconCircle)}</tb-notification-button__icon>
|
71
|
+
<tb-notification-button__icon>${(this.config.markUp.style === 'rounded' ? icon : iconCircle)}</tb-notification-button__icon>
|
64
72
|
<tb-notification-button__text>${this.text('vkontakte')}</tb-notification-button__text>
|
65
73
|
</a>
|
66
74
|
`;
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
return '';
|
75
|
+
} else {
|
76
|
+
return `
|
77
|
+
<div class="tb-notification-button__inner">
|
78
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
79
|
+
<a id="${this.buttonContainerId}">
|
80
|
+
${
|
81
|
+
this.useVkApp || this.landingUrl ? this.text('vkontakteExtended') : ''
|
82
|
+
}
|
83
|
+
</a>
|
84
|
+
</div>
|
85
|
+
`
|
86
|
+
}
|
80
87
|
}
|
88
|
+
return '';
|
89
|
+
}
|
81
90
|
}
|
82
91
|
|
83
92
|
module.exports = VKButton;
|
@@ -9,29 +9,36 @@ const prefixText = encodeURIComponent('Отправьте не изменяя э
|
|
9
9
|
class WhatsappButton extends Button {
|
10
10
|
render() {
|
11
11
|
super.render();
|
12
|
-
|
12
|
+
|
13
13
|
const link = this.element.querySelector('a');
|
14
14
|
link.addEventListener('click', (event) => {
|
15
15
|
event.preventDefault();
|
16
16
|
this.channelAPI.subscribe();
|
17
17
|
});
|
18
18
|
}
|
19
|
-
|
19
|
+
|
20
20
|
get template() {
|
21
21
|
if (this.config.type === constants.WIDGET_TYPE_API_CALL) {
|
22
22
|
return `
|
23
|
-
<a target="_blank" href="https://api.whatsapp.com/send
|
23
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
24
24
|
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
25
25
|
<tb-notification-button__text>${this.text('whatsapp')}</tb-notification-button__text>
|
26
26
|
</a>
|
27
27
|
<p class="tb-notification-button__tip">
|
28
|
-
${this.text('
|
28
|
+
${this.text('whatsappTip')}
|
29
29
|
</p>
|
30
30
|
`;
|
31
|
+
} else if(this.config.markUp.style === 'gradient' || this.config.markUp.style === 'icons') {
|
32
|
+
return `
|
33
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
34
|
+
<tb-notification-button__icon>${iconCircle}</tb-notification-button__icon>
|
35
|
+
<tb-notification-button__text>${this.text('whatsapp')}</tb-notification-button__text>
|
36
|
+
</a>
|
37
|
+
`;
|
31
38
|
} else if (this.config.markUp.style !== 'square') {
|
32
39
|
return `
|
33
|
-
<a target="_blank" href="https://api.whatsapp.com/send
|
34
|
-
<tb-notification-button__icon>${( this.config.markUp.style === 'rounded' ?
|
40
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
41
|
+
<tb-notification-button__icon>${( this.config.markUp.style === 'rounded' ? iconCircle : icon )}</tb-notification-button__icon>
|
35
42
|
<tb-notification-button__text>${this.text('whatsapp')}</tb-notification-button__text>
|
36
43
|
</a>
|
37
44
|
`;
|
@@ -39,8 +46,8 @@ class WhatsappButton extends Button {
|
|
39
46
|
return `
|
40
47
|
<div class="tb-notification-button__inner">
|
41
48
|
<tb-notification-button__icon>${iconNew}</tb-notification-button__icon>
|
42
|
-
<a target="_blank" href="https://api.whatsapp.com/send
|
43
|
-
<tb-notification-button__text>${this.text('
|
49
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
50
|
+
<tb-notification-button__text>${this.text('whatsappExtended')}</tb-notification-button__text>
|
44
51
|
</a>
|
45
52
|
</div>
|
46
53
|
`;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import Button from './index.js';
|
2
|
+
import icon from '../../icons/icon_whatsappb.svg';
|
3
|
+
import iconNew from '../../icons/icon_whatsappb_new.svg';
|
4
|
+
import iconCircle from '../../icons/icon_whatsappb_circle.svg';
|
5
|
+
import constants from '../../../sdk/utils/constants.js';
|
6
|
+
|
7
|
+
const prefixText = encodeURIComponent('Отправьте не изменяя это сообщение ');
|
8
|
+
|
9
|
+
class WhatsappbButton extends Button {
|
10
|
+
render() {
|
11
|
+
super.render();
|
12
|
+
|
13
|
+
const link = this.element.querySelector('a');
|
14
|
+
link.addEventListener('click', (event) => {
|
15
|
+
event.preventDefault();
|
16
|
+
this.channelAPI.subscribe();
|
17
|
+
});
|
18
|
+
}
|
19
|
+
|
20
|
+
get template() {
|
21
|
+
if (this.config.type === constants.WIDGET_TYPE_API_CALL) {
|
22
|
+
return `
|
23
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
24
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
25
|
+
<tb-notification-button__text>${this.text('whatsappb')}</tb-notification-button__text>
|
26
|
+
</a>
|
27
|
+
<p class="tb-notification-button__tip">
|
28
|
+
${this.text('whatsappTip')}
|
29
|
+
</p>
|
30
|
+
`;
|
31
|
+
} else if(this.config.markUp.style === 'gradient' || this.config.markUp.style === 'icons') {
|
32
|
+
return `
|
33
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
34
|
+
<tb-notification-button__icon>${iconCircle}</tb-notification-button__icon>
|
35
|
+
<tb-notification-button__text>${this.text('whatsappb')}</tb-notification-button__text>
|
36
|
+
</a>
|
37
|
+
`;
|
38
|
+
} else if (this.config.markUp.style !== 'square') {
|
39
|
+
return `
|
40
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
41
|
+
<tb-notification-button__icon>${( this.config.markUp.style === 'rounded' ? iconCircle : icon )}</tb-notification-button__icon>
|
42
|
+
<tb-notification-button__text>${this.text('whatsappb')}</tb-notification-button__text>
|
43
|
+
</a>
|
44
|
+
`;
|
45
|
+
} else {
|
46
|
+
return `
|
47
|
+
<div class="tb-notification-button__inner">
|
48
|
+
<tb-notification-button__icon>${iconNew}</tb-notification-button__icon>
|
49
|
+
<a target="_blank" href="https://api.whatsapp.com/send/?phone=+${this.config.id}&text=${prefixText + this.deepLink}">
|
50
|
+
<tb-notification-button__text>${this.text('whatsappbExtended')}</tb-notification-button__text>
|
51
|
+
</a>
|
52
|
+
</div>
|
53
|
+
`;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
module.exports = WhatsappbButton;
|