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