@textback/notification-widget 2.0.4 → 2.0.6-110502
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/.gitlab-ci.yml +2 -8
- package/{release/builds/textback/notificationwidget/build → build}/index.js +1 -1
- package/package.json +2 -2
- package/release/builds/textback/notificationwidget/.eslintrc.js +0 -291
- package/release/builds/textback/notificationwidget/.gitlab-ci.yml +0 -34
- package/release/builds/textback/notificationwidget/package-lock.json +0 -9985
- package/release/builds/textback/notificationwidget/package.json +0 -70
- package/release/builds/textback/notificationwidget/promote_tag.sh +0 -2
- package/release/builds/textback/notificationwidget/readme.md +0 -569
- package/release/builds/textback/notificationwidget/server.js +0 -224
- package/release/builds/textback/notificationwidget/src/libraries/ai.1.0.11.js +0 -4089
- package/release/builds/textback/notificationwidget/src/libraries/localization/getLocale.js +0 -17
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/.tern-port +0 -1
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/cs.js +0 -23
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/en.js +0 -23
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/index.js +0 -9
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/pl.js +0 -23
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/ro.js +0 -23
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/ru.js +0 -22
- package/release/builds/textback/notificationwidget/src/libraries/localization/locales/uk.js +0 -23
- package/release/builds/textback/notificationwidget/src/libraries/localization/text.js +0 -9
- package/release/builds/textback/notificationwidget/src/libraries/t.js +0 -82
- package/release/builds/textback/notificationwidget/src/sdk/channels/channel.js +0 -31
- package/release/builds/textback/notificationwidget/src/sdk/channels/facebook.js +0 -13
- package/release/builds/textback/notificationwidget/src/sdk/channels/factory.js +0 -34
- package/release/builds/textback/notificationwidget/src/sdk/channels/skype.js +0 -13
- package/release/builds/textback/notificationwidget/src/sdk/channels/telegram.js +0 -18
- package/release/builds/textback/notificationwidget/src/sdk/channels/viber.js +0 -13
- package/release/builds/textback/notificationwidget/src/sdk/channels/vk-modal/vk-modal.html +0 -17
- package/release/builds/textback/notificationwidget/src/sdk/channels/vk-modal/vk-modal.js +0 -25
- package/release/builds/textback/notificationwidget/src/sdk/channels/vk-modal/vk-modal.scss +0 -116
- package/release/builds/textback/notificationwidget/src/sdk/channels/vk.js +0 -195
- package/release/builds/textback/notificationwidget/src/sdk/channels/whatsapp.js +0 -27
- package/release/builds/textback/notificationwidget/src/sdk/channels/whatsappb.js +0 -27
- package/release/builds/textback/notificationwidget/src/sdk/events/observer.js +0 -46
- package/release/builds/textback/notificationwidget/src/sdk/index.js +0 -6
- package/release/builds/textback/notificationwidget/src/sdk/sdk.entry.js +0 -1
- package/release/builds/textback/notificationwidget/src/sdk/sdk.js +0 -67
- package/release/builds/textback/notificationwidget/src/sdk/utils/apiErrorHandler.js +0 -12
- package/release/builds/textback/notificationwidget/src/sdk/utils/appInsights.js +0 -88
- package/release/builds/textback/notificationwidget/src/sdk/utils/browserInfo.js +0 -9
- package/release/builds/textback/notificationwidget/src/sdk/utils/constants.js +0 -18
- package/release/builds/textback/notificationwidget/src/sdk/utils/cookies.js +0 -67
- package/release/builds/textback/notificationwidget/src/sdk/utils/find.js +0 -8
- package/release/builds/textback/notificationwidget/src/sdk/utils/loadConfig.js +0 -21
- package/release/builds/textback/notificationwidget/src/sdk/utils/loadDeepLink.js +0 -48
- package/release/builds/textback/notificationwidget/src/sdk/utils/loadScript.js +0 -26
- package/release/builds/textback/notificationwidget/src/sdk/utils/loadSubscriptions.js +0 -6
- package/release/builds/textback/notificationwidget/src/sdk/utils/parseQueryString.js +0 -34
- package/release/builds/textback/notificationwidget/src/sdk/utils/windowHelper.js +0 -25
- package/release/builds/textback/notificationwidget/src/sdk/widget/widget.js +0 -192
- package/release/builds/textback/notificationwidget/src/widget/components/index.js +0 -52
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/facebook.js +0 -55
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/index.js +0 -35
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/styles.scss +0 -657
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/telegram.js +0 -55
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/viber.js +0 -57
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/vk.js +0 -92
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/whatsapp.js +0 -58
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-button/whatsappb.js +0 -58
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-widget/index.js +0 -694
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-widget/normalize.scss +0 -395
- package/release/builds/textback/notificationwidget/src/widget/components/tb-notification-widget/styles.scss +0 -543
- package/release/builds/textback/notificationwidget/src/widget/components/tb-nw-wahunter/index.js +0 -261
- package/release/builds/textback/notificationwidget/src/widget/components/tb-nw-wahunter/styles.scss +0 -471
- package/release/builds/textback/notificationwidget/src/widget/config.js +0 -5
- package/release/builds/textback/notificationwidget/src/widget/icons/bell-icon.png +0 -0
- package/release/builds/textback/notificationwidget/src/widget/icons/broadcast-icon.png +0 -0
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_chat_window.svg +0 -1
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_close.svg +0 -1
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_facebook.svg +0 -7
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_facebook_circle.svg +0 -7
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_instagram_circle.svg +0 -96
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_skype.svg +0 -44
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_skype_circle.svg +0 -46
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_skype_new.svg +0 -114
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_tg.svg +0 -25
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_tg_circle.svg +0 -17
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_viber.svg +0 -75
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_viber_circle.svg +0 -67
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_viber_new.svg +0 -102
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_vk.svg +0 -14
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_vk_circle.svg +0 -16
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsapp.svg +0 -147
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsapp_circle.svg +0 -4
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsapp_hollow.svg +0 -128
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsapp_new.svg +0 -127
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsappb.svg +0 -147
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsappb_circle.svg +0 -4
- package/release/builds/textback/notificationwidget/src/widget/icons/icon_whatsappb_new.svg +0 -127
- package/release/builds/textback/notificationwidget/src/widget/icons/paper-plane-arrow.svg +0 -3
- package/release/builds/textback/notificationwidget/src/widget/icons/paper-plane-icon.png +0 -0
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo-dark-en.svg +0 -17
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo-dark-ru.svg +0 -17
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo-dark.svg +0 -16
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo-light-en.svg +0 -17
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo-light-ru.svg +0 -17
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo-white.svg +0 -16
- package/release/builds/textback/notificationwidget/src/widget/icons/tb-logo.svg +0 -16
- package/release/builds/textback/notificationwidget/src/widget/index.js +0 -29
- package/release/builds/textback/notificationwidget/src/widget/locales/cs.js +0 -42
- package/release/builds/textback/notificationwidget/src/widget/locales/en.js +0 -42
- package/release/builds/textback/notificationwidget/src/widget/locales/index.js +0 -9
- package/release/builds/textback/notificationwidget/src/widget/locales/pl.js +0 -42
- package/release/builds/textback/notificationwidget/src/widget/locales/ro.js +0 -41
- package/release/builds/textback/notificationwidget/src/widget/locales/ru.js +0 -41
- package/release/builds/textback/notificationwidget/src/widget/locales/uk.js +0 -41
- package/release/builds/textback/notificationwidget/src/widget/utils/cookiesEx.js +0 -41
- package/release/builds/textback/notificationwidget/src/widget/utils/getLocale.js +0 -17
- package/release/builds/textback/notificationwidget/src/widget/utils/stringifyAttributes.js +0 -19
- package/release/builds/textback/notificationwidget/src/widget/utils/text.js +0 -10
- package/release/builds/textback/notificationwidget/src/widget/utils/widgetsStorage.js +0 -28
- package/release/builds/textback/notificationwidget/src/widget/widget.entry.js +0 -3
- package/release/builds/textback/notificationwidget/tests/gf.html +0 -35
- package/release/builds/textback/notificationwidget/tests/gf.js +0 -22
- package/release/builds/textback/notificationwidget/tests/index.js +0 -62
- package/release/builds/textback/notificationwidget/views/examples.ejs +0 -51
- package/release/builds/textback/notificationwidget/views/sdk.html +0 -274
- package/release/builds/textback/notificationwidget/webpack.common.js +0 -72
- package/release/builds/textback/notificationwidget/webpack.dev.js +0 -15
- package/release/builds/textback/notificationwidget/webpack.prod.js +0 -10
- package/widget.tar.gz +0 -0
- /package/{release/builds/textback/notificationwidget/build → build}/sdk.js +0 -0
@@ -1,6 +0,0 @@
|
|
1
|
-
import apiErrorHandler from './apiErrorHandler.js';
|
2
|
-
|
3
|
-
export default function loadSubscriptions(uuid, widgetId, apiPath){
|
4
|
-
const subscribedUsers = fetch(`${apiPath}/endUserNotifications/widgets/${widgetId}/subscribedUsers/${uuid}`).then(apiErrorHandler);
|
5
|
-
return subscribedUsers;
|
6
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
function parseQueryString(query) {
|
2
|
-
const vars = query.split('&'),
|
3
|
-
queryString = {};
|
4
|
-
|
5
|
-
if (query.length > 0) {
|
6
|
-
for (var i = 0; i < vars.length; i++) {
|
7
|
-
const pair = vars[i].split('='),
|
8
|
-
key = decodeURIComponent(pair[0]),
|
9
|
-
value = decodeURIComponent(pair[1]);
|
10
|
-
|
11
|
-
if (!key)
|
12
|
-
continue;
|
13
|
-
|
14
|
-
switch ( typeof queryString[key] ) {
|
15
|
-
// If first entry with this name
|
16
|
-
case 'undefined':
|
17
|
-
queryString[key] = value;
|
18
|
-
break;
|
19
|
-
// If second entry with this name
|
20
|
-
case 'string': {
|
21
|
-
const arr = [ queryString[key], value ];
|
22
|
-
queryString[ key ] = arr;
|
23
|
-
break;
|
24
|
-
}
|
25
|
-
// If third or later entry with this name
|
26
|
-
default:
|
27
|
-
queryString[key].push(value);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
return queryString;
|
32
|
-
}
|
33
|
-
|
34
|
-
export default parseQueryString;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
export default class WindowHelper {
|
4
|
-
constructior() {}
|
5
|
-
|
6
|
-
static get center() {
|
7
|
-
return {
|
8
|
-
x: Math.floor(window.innerWidth * 0.5),
|
9
|
-
y: Math.floor(window.innerHeight * 0.5)
|
10
|
-
};
|
11
|
-
}
|
12
|
-
|
13
|
-
static getRatio(percent) {
|
14
|
-
let r = percent / 100;
|
15
|
-
return {
|
16
|
-
width: Math.floor(window.innerWidth * r),
|
17
|
-
height: Math.floor(window.innerHeight * r)
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
static getRatioPropString(percent) {
|
22
|
-
let ratioObj = this.getRatio(percent);
|
23
|
-
return `width=${ratioObj.width},height=${ratioObj.height}`;
|
24
|
-
}
|
25
|
-
}
|
@@ -1,192 +0,0 @@
|
|
1
|
-
import UUID from 'uuid-js';
|
2
|
-
import assign from 'lodash/assign';
|
3
|
-
|
4
|
-
import apiErrorHandler from '../utils/apiErrorHandler.js';
|
5
|
-
import loadConfig from '../utils/loadConfig.js';
|
6
|
-
import loadDeepLink from '../utils/loadDeepLink.js';
|
7
|
-
import loadSubscriptions from '../utils/loadSubscriptions.js';
|
8
|
-
import cookies from '../utils/cookies.js';
|
9
|
-
import constants from '../utils/constants.js';
|
10
|
-
import parseQueryString from '../utils/parseQueryString.js';
|
11
|
-
import find from '../utils/find.js';
|
12
|
-
import appInsights from '../utils/appInsights.js';
|
13
|
-
|
14
|
-
import channelsFactory from '../channels/factory.js';
|
15
|
-
|
16
|
-
const INITIAL_CONFIG_DEFAULTS = {
|
17
|
-
apiPath: 'https://api.textback.io/api',
|
18
|
-
};
|
19
|
-
|
20
|
-
export default class Widget {
|
21
|
-
constructor(config, sdk) {
|
22
|
-
this.initialConfig = assign({}, INITIAL_CONFIG_DEFAULTS, config);
|
23
|
-
this.sdk = sdk;
|
24
|
-
|
25
|
-
this.config = {};
|
26
|
-
this.channels = [];
|
27
|
-
this.initialized = false;
|
28
|
-
this.initPromise = null;
|
29
|
-
|
30
|
-
this.id = this.initialConfig.widgetId;
|
31
|
-
this.widgetUserId = Widget.getWidgetUserId();
|
32
|
-
this.insecureContext = Widget.createInsecureContext(this.initialConfig.insecureContext);
|
33
|
-
this.secureContextToken = this.initialConfig.secureContextToken;
|
34
|
-
}
|
35
|
-
|
36
|
-
getConfig() {
|
37
|
-
return this.config;
|
38
|
-
}
|
39
|
-
|
40
|
-
initialize() {
|
41
|
-
this.initPromise = Promise.all([
|
42
|
-
this.initializeConfig(),
|
43
|
-
loadSubscriptions(this.widgetUserId, this.initialConfig.widgetId, this.initialConfig.apiPath),
|
44
|
-
]).then(([config, subscriptions]) => {
|
45
|
-
this.config = config.$value;
|
46
|
-
this.subscriptions = subscriptions.$items;
|
47
|
-
|
48
|
-
this.useVKApi = this.config.type === constants.WIDGET_TYPE_API_CALL;
|
49
|
-
this.aiKey = Widget.getAiKey(config);
|
50
|
-
|
51
|
-
let customDeeplinkData = this.config.channels.filter(
|
52
|
-
c => c.hasOwnProperty('additionalProperties') && c.additionalProperties.hasOwnProperty('customDeeplinkValue')
|
53
|
-
).filter(
|
54
|
-
c => c.channel === 'whatsapp' || c.channel === 'whatsappb'
|
55
|
-
).filter(
|
56
|
-
c => c.enabled
|
57
|
-
).map(
|
58
|
-
({additionalProperties, channel, channelId}) => {
|
59
|
-
return {
|
60
|
-
channel: channel,
|
61
|
-
channelId: channelId,
|
62
|
-
customDeeplinkValue: additionalProperties.customDeeplinkValue
|
63
|
-
};
|
64
|
-
}
|
65
|
-
);
|
66
|
-
|
67
|
-
let deeplinkData = {
|
68
|
-
accountId: this.config.accountId,
|
69
|
-
insecureContext: this.insecureContext,
|
70
|
-
widgetId: this.config.id,
|
71
|
-
secureContextToken: this.secureContextToken,
|
72
|
-
user: {
|
73
|
-
id: this.widgetUserId
|
74
|
-
}
|
75
|
-
};
|
76
|
-
|
77
|
-
if(customDeeplinkData.length > 0) {
|
78
|
-
deeplinkData.customDeeplinkValue = customDeeplinkData;
|
79
|
-
}
|
80
|
-
|
81
|
-
return Promise.all([
|
82
|
-
loadDeepLink(
|
83
|
-
this.initialConfig.apiPath,
|
84
|
-
deeplinkData
|
85
|
-
),
|
86
|
-
appInsights.init(this.aiKey, this.widgetUserId, this.config.accountId)
|
87
|
-
]);
|
88
|
-
}).then(([deeplink, ai]) => {
|
89
|
-
this.deeplink = `subscribe_${deeplink.$value.id}`;
|
90
|
-
this.channels = this.config.channels.map(channel => channelsFactory.create(channel, this.deeplink, this))
|
91
|
-
.filter(channel => !!channel);
|
92
|
-
|
93
|
-
const channelInitPromises = this.channels.filter(
|
94
|
-
channel => !!channel.initPromise
|
95
|
-
).map(
|
96
|
-
channel => channel.initPromise
|
97
|
-
);
|
98
|
-
|
99
|
-
return Promise.all(channelInitPromises);
|
100
|
-
}).then(channelPromises => {
|
101
|
-
return this;
|
102
|
-
}, err => {
|
103
|
-
appInsights.trackWidgetEvent(this.config.id, 'Widget.initialize.error', err);
|
104
|
-
return Promise.reject(err);
|
105
|
-
});
|
106
|
-
|
107
|
-
return this.initPromise;
|
108
|
-
}
|
109
|
-
|
110
|
-
initializeConfig() {
|
111
|
-
let promise;
|
112
|
-
if (!this.initialConfig.overrideConfig) {
|
113
|
-
promise = loadConfig(this.initialConfig.widgetId, this.initialConfig.apiPath);
|
114
|
-
} else {
|
115
|
-
promise = Promise.resolve({ $value: this.initialConfig.overrideConfig });
|
116
|
-
}
|
117
|
-
|
118
|
-
return promise;
|
119
|
-
}
|
120
|
-
|
121
|
-
subscribe(channelCode) {
|
122
|
-
const channel = find(this.getEnabledChannels(), chan => chan.channel === channelCode);
|
123
|
-
if (channel) {
|
124
|
-
channel.subscribe();
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
getChannels() {
|
129
|
-
return this.channels;
|
130
|
-
}
|
131
|
-
|
132
|
-
getEnabledChannels() {
|
133
|
-
return this.channels.filter(channel => channel.enabled && !channel.hasError);
|
134
|
-
}
|
135
|
-
|
136
|
-
runWahunter(phoneNumber) {
|
137
|
-
return fetch(`${this.initialConfig.apiPath}/wahunter`, {
|
138
|
-
method: 'POST',
|
139
|
-
headers: {
|
140
|
-
'Content-Type': 'application/json;charset=utf-8'
|
141
|
-
},
|
142
|
-
body: JSON.stringify({
|
143
|
-
notificationWidgetId: this.initialConfig.widgetId,
|
144
|
-
phone: phoneNumber,
|
145
|
-
insecureContext: this.insecureContext,
|
146
|
-
deeplinkId: this.deeplink,
|
147
|
-
}),
|
148
|
-
}).then((resp) => {
|
149
|
-
if (resp.ok) {
|
150
|
-
cookies.setCookie(`${constants.COOKIE_NAME_PREFIX + this.id}_wahunter_was_run`, true, this.config.showWidgetSetting.showSessionLength * 60);
|
151
|
-
} else {
|
152
|
-
return Promise.reject(resp);
|
153
|
-
}
|
154
|
-
})
|
155
|
-
}
|
156
|
-
|
157
|
-
static getWidgetUserId() {
|
158
|
-
let widgetUserId = cookies.getCookie(constants.COOKIE_WIDGET_USER_ID);
|
159
|
-
if (widgetUserId === null) {
|
160
|
-
let uuid = UUID.create(4);
|
161
|
-
widgetUserId = uuid.hex;
|
162
|
-
cookies.setCookie(constants.COOKIE_WIDGET_USER_ID, widgetUserId, constants.WIDGET_USER_ID_COOKIE_TTL);
|
163
|
-
}
|
164
|
-
return widgetUserId;
|
165
|
-
}
|
166
|
-
|
167
|
-
static createInsecureContext(insecureContext = {}) {
|
168
|
-
const ctx = assign({}, insecureContext);//Object.assign({}, insecureContext);
|
169
|
-
ctx.pageTitle = window.document.title;
|
170
|
-
ctx.pageUrl = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
171
|
-
ctx.params = parseQueryString(window.location.search.substring(1));
|
172
|
-
ctx.timezoneOffset = new Date().getTimezoneOffset();
|
173
|
-
ctx.cookies = cookies.getCookieObject();
|
174
|
-
|
175
|
-
const roistatVisitCookie = cookies.getCookie("roistat_visit");
|
176
|
-
|
177
|
-
if (roistatVisitCookie) {
|
178
|
-
ctx.roistatVisit = roistatVisitCookie;
|
179
|
-
}
|
180
|
-
|
181
|
-
return ctx;
|
182
|
-
}
|
183
|
-
|
184
|
-
static getAiKey(config) {
|
185
|
-
let aiKey = undefined;
|
186
|
-
try {
|
187
|
-
aiKey = config.headers.get('X-TB-AIKEY');
|
188
|
-
} catch (e) { }
|
189
|
-
|
190
|
-
return aiKey;
|
191
|
-
}
|
192
|
-
}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
// const merge = require('lodash/merge');
|
2
|
-
import merge from 'lodash/merge';
|
3
|
-
import text from '../utils/text.js';
|
4
|
-
import getLocale from '../utils/getLocale.js';
|
5
|
-
|
6
|
-
export default class Component {
|
7
|
-
constructor(props = {}) {
|
8
|
-
|
9
|
-
if (Object.prototype.hasOwnProperty.call(props, 'parentElement')) this.element = props.parentElement;
|
10
|
-
if (!Object.prototype.hasOwnProperty.call(props, 'parentElement')) this.element = props.element || document.createElement(this.constructor.tagName);
|
11
|
-
|
12
|
-
const dataset = JSON.parse(JSON.stringify(this.element.dataset || {}));
|
13
|
-
const data = merge(JSON.parse(this.element.getAttribute('data')), dataset);
|
14
|
-
|
15
|
-
this.set(this.defaults, props, {data});
|
16
|
-
}
|
17
|
-
|
18
|
-
render() {
|
19
|
-
this.element.innerHTML = this.template;
|
20
|
-
}
|
21
|
-
|
22
|
-
text(string) {
|
23
|
-
return text(string, this.lang);
|
24
|
-
}
|
25
|
-
|
26
|
-
get template() {
|
27
|
-
return this.content;
|
28
|
-
}
|
29
|
-
|
30
|
-
get lang() {
|
31
|
-
return this.element.getAttribute('lang') || getLocale();
|
32
|
-
}
|
33
|
-
|
34
|
-
set lang(value) {
|
35
|
-
if (!value) return;
|
36
|
-
|
37
|
-
this.element.setAttribute('lang', value);
|
38
|
-
}
|
39
|
-
|
40
|
-
set() {
|
41
|
-
merge(this, ...arguments);
|
42
|
-
this.render();
|
43
|
-
}
|
44
|
-
|
45
|
-
get defaults() {
|
46
|
-
return {};
|
47
|
-
}
|
48
|
-
|
49
|
-
static get tagName() {
|
50
|
-
return 'div';
|
51
|
-
}
|
52
|
-
};
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import Button from './index.js';
|
2
|
-
import icon from '../../icons/icon_facebook.svg';
|
3
|
-
import iconCircle from '../../icons/icon_facebook_circle.svg';
|
4
|
-
import constants from '../../../sdk/utils/constants.js';
|
5
|
-
|
6
|
-
class FacebookButton extends Button {
|
7
|
-
render() {
|
8
|
-
super.render();
|
9
|
-
|
10
|
-
const link = this.element.querySelector('a');
|
11
|
-
link.addEventListener('click', (event) => {
|
12
|
-
event.preventDefault();
|
13
|
-
this.channelAPI.subscribe();
|
14
|
-
});
|
15
|
-
}
|
16
|
-
|
17
|
-
get template() {
|
18
|
-
if (this.config.type === constants.WIDGET_TYPE_API_CALL) {
|
19
|
-
return `
|
20
|
-
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
21
|
-
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
22
|
-
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
|
23
|
-
</a>
|
24
|
-
<p class="tb-notification-button__tip">
|
25
|
-
${this.text('facebookTip')}
|
26
|
-
</p>
|
27
|
-
`;
|
28
|
-
} else if(this.config.markUp.style === 'gradient') {
|
29
|
-
return `
|
30
|
-
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
31
|
-
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
32
|
-
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
|
33
|
-
</a>
|
34
|
-
`;
|
35
|
-
} else if (this.config.markUp.style !== 'square') {
|
36
|
-
return `
|
37
|
-
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
38
|
-
<tb-notification-button__icon>${(this.config.markUp.style === 'rounded' ? icon : iconCircle )}</tb-notification-button__icon>
|
39
|
-
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
|
40
|
-
</a>
|
41
|
-
`;
|
42
|
-
} else {
|
43
|
-
return `
|
44
|
-
<div class="tb-notification-button__inner">
|
45
|
-
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
46
|
-
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
47
|
-
<tb-notification-button__text>${this.text('facebookExtended')}</tb-notification-button__text>
|
48
|
-
</a>
|
49
|
-
</div>
|
50
|
-
`;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
};
|
54
|
-
|
55
|
-
module.exports = FacebookButton;
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import Component from '../index.js';
|
2
|
-
import appInsights from '../../../sdk/utils/appInsights.js';
|
3
|
-
import find from '../../../sdk/utils/find.js';
|
4
|
-
import './styles.scss';
|
5
|
-
|
6
|
-
export default class Button extends Component {
|
7
|
-
constructor() {
|
8
|
-
super(...arguments);
|
9
|
-
|
10
|
-
this.element.setAttribute('channel', this.channel);
|
11
|
-
|
12
|
-
this.channelAPI = find(this.widgetAPI.getEnabledChannels(), channel => {
|
13
|
-
return channel.id === this.config.id && channel.channel === this.config.channel && channel.channelId === this.config.channelId;
|
14
|
-
});
|
15
|
-
}
|
16
|
-
|
17
|
-
render() {
|
18
|
-
let self = this;
|
19
|
-
super.render();
|
20
|
-
this.element.addEventListener('click', () => {
|
21
|
-
appInsights.trackButtonClick(this.widgetId, 'notificationWidget.button.click', this.channel)
|
22
|
-
});
|
23
|
-
}
|
24
|
-
|
25
|
-
get defaults() {
|
26
|
-
return {
|
27
|
-
config: JSON.parse(this.element.getAttribute('config')) || {},
|
28
|
-
channel: this.element.getAttribute('channel')
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
static get tagName() {
|
33
|
-
return 'tb-notification-button';
|
34
|
-
}
|
35
|
-
};
|