@subiz/widget-v4 4.0.50 → 4.0.55
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/assets/img/default.jpg +0 -0
- package/assets/less/message.less +101 -10
- package/compiled_src/chatbox/Event.js +6 -0
- package/compiled_src/chatbox/OrderAttachments.js +109 -0
- package/compiled_src/chatbox/ProductAttachments.js +9 -7
- package/compiled_src/notif/notif.js +6 -2
- package/compiled_src/plugin.js +1 -1
- package/compiled_src/store/api.js +1 -0
- package/compiled_src/util/campaign.js +6 -1
- package/compiled_src/util/common.js +7 -0
- package/dist/{17cbc0a3e5f.178.js → 17d7ef81b7a.178.js} +1 -1
- package/dist/{17cbc0a3e5f.213.js → 17d7ef81b7a.213.js} +0 -0
- package/dist/{17cbc0a3e5f.362.js → 17d7ef81b7a.362.js} +1 -1
- package/dist/17d7ef81b7a.441.js +1 -0
- package/dist/17d7ef81b7a.605.js +1 -0
- package/dist/{17cbc0a3e5f.619.js → 17d7ef81b7a.619.js} +1 -1
- package/dist/{17cbc0a3e5f.678.js → 17d7ef81b7a.678.js} +0 -0
- package/dist/17d7ef81b7a.74.js +1 -0
- package/dist/{17cbc0a3e5f.782.js → 17d7ef81b7a.782.js} +1 -1
- package/dist/17d7ef81b7a.app.js +1 -0
- package/dist/{17cbc0a3e5f.index.html → 17d7ef81b7a.index.html} +1 -1
- package/dist/{17cbc0a3e5f.library.html → 17d7ef81b7a.library.html} +1 -1
- package/dist/17d7ef81b7a.library.js +1 -0
- package/dist/{17cbc0a3e5f.preview.html → 17d7ef81b7a.preview.html} +1 -1
- package/dist/17d7ef81b7a.preview.js +1 -0
- package/dist/17d7ef81b7a.screenshoot.js +1 -0
- package/dist/17d7ef84382.178.js +406 -0
- package/dist/17d7ef84382.213.js +3223 -0
- package/dist/17d7ef84382.362.js +107 -0
- package/dist/17d7ef84382.441.js +2706 -0
- package/dist/17d7ef84382.605.js +391 -0
- package/dist/17d7ef84382.619.js +777 -0
- package/dist/17d7ef84382.678.js +107 -0
- package/dist/17d7ef84382.74.js +4732 -0
- package/dist/17d7ef84382.782.js +107 -0
- package/dist/17d7ef84382.screenshoot.js +5719 -0
- package/dist/HASH +1 -1
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/screenshoot.html +7 -0
- package/package.json +12 -12
- package/screenshoot.html +15 -0
- package/screenshoot.js +28 -0
- package/src/chatbox/Event.js +2 -0
- package/src/chatbox/OrderAttachments.js +107 -0
- package/src/chatbox/ProductAttachments.js +14 -8
- package/src/notif/notif.js +36 -27
- package/src/plugin.js +1 -1
- package/src/store/api.js +2 -5
- package/src/store/store.js +9 -8
- package/src/util/campaign.js +14 -11
- package/src/util/common.js +6 -0
- package/take.js +36 -0
- package/webpack.dev.js +7 -0
- package/webpack.prod.js +12 -2
- package/webpack.screenshoot.js +28 -0
- package/dist/17cbc0a3e5f.605.js +0 -1
- package/dist/17cbc0a3e5f.712.js +0 -1
- package/dist/17cbc0a3e5f.84.js +0 -1
- package/dist/17cbc0a3e5f.app.js +0 -1
- package/dist/17cbc0a3e5f.library.js +0 -1
- package/dist/17cbc0a3e5f.preview.js +0 -1
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[605],{
|
|
3
|
+
|
|
4
|
+
/***/ 2493:
|
|
5
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6
|
+
|
|
7
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
/* harmony export */ "M": () => (/* binding */ Com),
|
|
9
|
+
/* harmony export */ "u": () => (/* binding */ Clickaway)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6400);
|
|
12
|
+
/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(819);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Com extends preact__WEBPACK_IMPORTED_MODULE_0__/* .Component */ .wA {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this._isMounted = true;
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
if (this.componentWillUnmount) {
|
|
21
|
+
let old = this.componentWillUnmount.bind(this);
|
|
22
|
+
|
|
23
|
+
this.componentWillUnmount = () => {
|
|
24
|
+
old();
|
|
25
|
+
this._isMounted = false;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}, 10);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
class Clickaway extends Com {
|
|
33
|
+
constructor(props) {
|
|
34
|
+
super(props);
|
|
35
|
+
this.setWrapperRef = this.setWrapperRef.bind(this);
|
|
36
|
+
this.onClick = this.onClick.bind(this);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
componentDidMount() {
|
|
40
|
+
document.addEventListener('mousedown', this.onClick);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
componentWillUnmount() {
|
|
44
|
+
document.removeEventListener('mousedown', this.onClick);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setWrapperRef(node) {
|
|
48
|
+
this.wrapperRef = node;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onClick(event) {
|
|
52
|
+
if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
|
|
53
|
+
this.props.onClickaway && this.props.onClickaway();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
render() {
|
|
58
|
+
return (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", {
|
|
59
|
+
ref: this.setWrapperRef
|
|
60
|
+
}, this.props.children);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/***/ }),
|
|
66
|
+
|
|
67
|
+
/***/ 9605:
|
|
68
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
69
|
+
|
|
70
|
+
__webpack_require__.r(__webpack_exports__);
|
|
71
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
72
|
+
/* harmony export */ "default": () => (/* binding */ Notif)
|
|
73
|
+
/* harmony export */ });
|
|
74
|
+
/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(819);
|
|
75
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6400);
|
|
76
|
+
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2493);
|
|
77
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
let notifCSS = (() => __webpack_require__.e(/* import() */ 362).then(__webpack_require__.bind(__webpack_require__, 362)))();
|
|
84
|
+
|
|
85
|
+
class Notif extends _common_js__WEBPACK_IMPORTED_MODULE_2__/* .Com */ .M {
|
|
86
|
+
constructor(props) {
|
|
87
|
+
super(props);
|
|
88
|
+
|
|
89
|
+
_defineProperty(this, "state", {
|
|
90
|
+
close: true,
|
|
91
|
+
cssready: false,
|
|
92
|
+
closeAnimation: true,
|
|
93
|
+
imageReady: false,
|
|
94
|
+
user: {},
|
|
95
|
+
timestamp: '',
|
|
96
|
+
message: '',
|
|
97
|
+
title: '',
|
|
98
|
+
last_show: 0
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
setTimeout(async () => {
|
|
102
|
+
let {
|
|
103
|
+
body: impression
|
|
104
|
+
} = await this.props.store.sendImpression(this.props.plugin.id);
|
|
105
|
+
this.impressionToken = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(impression, 'impression_token') || '';
|
|
106
|
+
let image = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.background_url');
|
|
107
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].preloadImg */ .Z.preloadImg(image, () => this.setState({
|
|
108
|
+
imageReady: true
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setOver(over) {
|
|
114
|
+
if (!over) this.mouse_leave = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now();else this.mouse_leave = 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
randomTimestampt() {
|
|
118
|
+
let random = Math.floor(Math.random() * 5);
|
|
119
|
+
if (random == 0) return this.props.t('just_now');
|
|
120
|
+
if (random == 1) return '1 ' + this.props.t('minute_ago');
|
|
121
|
+
if (random == 2) return '2 ' + this.props.t('minutes_ago');
|
|
122
|
+
if (random == 3) return '3 ' + this.props.t('minutes_ago');
|
|
123
|
+
return '4 ' + this.props.t('minutes_ago');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
onClick(e) {
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
if (this.props.plugin._dont_follow) return;
|
|
129
|
+
this.props.store.sendConversion(this.props.plugin.id, null, this.impressionToken);
|
|
130
|
+
let url = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.url');
|
|
131
|
+
if (!url) return;
|
|
132
|
+
if (!url.startsWith('http://') && !url.startsWith('https://')) url = '//' + url;
|
|
133
|
+
let new_tab = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.new_tab', false);
|
|
134
|
+
if (new_tab) return window.open(url);
|
|
135
|
+
window.location.href = url;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
onCloseButtonClick(e) {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
e.stopPropagation();
|
|
141
|
+
this.setClose(true);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
renderCloseButton() {
|
|
145
|
+
return (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
146
|
+
class: "btn_close",
|
|
147
|
+
onClick: e => this.onCloseButtonClick(e)
|
|
148
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("svg", {
|
|
149
|
+
class: "btn_close__icon",
|
|
150
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
151
|
+
width: "24",
|
|
152
|
+
height: "24",
|
|
153
|
+
viewBox: "0 0 24 24",
|
|
154
|
+
"stroke-linecap": "round",
|
|
155
|
+
"stroke-linejoin": "round"
|
|
156
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("line", {
|
|
157
|
+
x1: "18",
|
|
158
|
+
y1: "6",
|
|
159
|
+
x2: "6",
|
|
160
|
+
y2: "18",
|
|
161
|
+
style: "stroke-width: 3 !important;"
|
|
162
|
+
}), (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("line", {
|
|
163
|
+
x1: "6",
|
|
164
|
+
y1: "6",
|
|
165
|
+
x2: "18",
|
|
166
|
+
y2: "18",
|
|
167
|
+
style: "stroke-width: 3 !important;"
|
|
168
|
+
})));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async waitForT() {
|
|
172
|
+
if (this.props.t) return;
|
|
173
|
+
await _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].sleep */ .Z.sleep(100);
|
|
174
|
+
return this.waitForT();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async setClose(close) {
|
|
178
|
+
await this.waitForT();
|
|
179
|
+
if (!this.props.t) return;
|
|
180
|
+
|
|
181
|
+
if (!close) {
|
|
182
|
+
clearTimeout(this.lastCloseTimeout);
|
|
183
|
+
this.setState({
|
|
184
|
+
closeAnimation: false
|
|
185
|
+
});
|
|
186
|
+
let timestamp = this.randomTimestampt();
|
|
187
|
+
let profiles = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.profiles', []);
|
|
188
|
+
let user = profiles[Math.floor(Math.random() * _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].size */ .Z.size(profiles))];
|
|
189
|
+
|
|
190
|
+
if (user.avatar_url && user.avatar_url.startsWith('http')) {
|
|
191
|
+
await _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].preloadImg */ .Z.preloadImg(user.avatar_url);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].map */ .Z.map(_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props.plugin, 'notification.custom_avatar_urls'), url => {
|
|
195
|
+
profiles.push({
|
|
196
|
+
type: 'person',
|
|
197
|
+
fullname: randomName(),
|
|
198
|
+
avatar_url: url,
|
|
199
|
+
email: randomEmail(),
|
|
200
|
+
address: randomAddress(),
|
|
201
|
+
phone: ramdomPhone(),
|
|
202
|
+
age: randomAge()
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
let i18n_messages = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.i18n_message_quill_deltas', []);
|
|
206
|
+
let i18n_message = i18n_messages[Math.floor(Math.random() * _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].size */ .Z.size(i18n_messages))];
|
|
207
|
+
let fallbackmsgs = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.message_quill_deltas', []);
|
|
208
|
+
let fallbackmessage = fallbackmsgs[Math.floor(Math.random() * _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].size */ .Z.size(fallbackmsgs))];
|
|
209
|
+
let i18n_title = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.i18n_title_quill_delta');
|
|
210
|
+
return this.setState({
|
|
211
|
+
close: false,
|
|
212
|
+
last_show: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now(),
|
|
213
|
+
timestamp: timestamp,
|
|
214
|
+
user: user,
|
|
215
|
+
title: this.props.t.i18n(i18n_title) || _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props, 'plugin.notification.title_quill_delta'),
|
|
216
|
+
message: this.props.t.i18n(i18n_message) || fallbackmessage
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.setState({
|
|
221
|
+
closeAnimation: true
|
|
222
|
+
});
|
|
223
|
+
this.mouse_leave = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now();
|
|
224
|
+
this.lastCloseTimeout = setTimeout(() => this.setState({
|
|
225
|
+
close: true,
|
|
226
|
+
closeAnimation: false
|
|
227
|
+
}), 150);
|
|
228
|
+
if (this.props.plugin._dont_close) setTimeout(() => this.setState({
|
|
229
|
+
closeAnimation: false,
|
|
230
|
+
close: false
|
|
231
|
+
}), 1000);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async refreshCSS() {
|
|
235
|
+
let plugins = this.props.store.matchPlugin();
|
|
236
|
+
let found = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].find */ .Z.find(plugins, plugin => plugin.id === this.props.plugin.id);
|
|
237
|
+
if (!found) return;
|
|
238
|
+
let css = (await notifCSS).default.default.toString();
|
|
239
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].setCss */ .Z.setCss(this.props.plugin.id, this.$cssStyleDiv, css);
|
|
240
|
+
this.setClose(this.state.close);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
componentWillUnmount() {
|
|
244
|
+
clearInterval(this.interval);
|
|
245
|
+
_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].setCss */ .Z.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async componentDidMount() {
|
|
249
|
+
this.setState({
|
|
250
|
+
last_show: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now()
|
|
251
|
+
});
|
|
252
|
+
this.$cssStyleDiv = document.getElementById('subiz-style-for-' + this.props.plugin.id);
|
|
253
|
+
|
|
254
|
+
if (!this.$cssStyleDiv) {
|
|
255
|
+
this.$cssStyleDiv = document.createElement('style');
|
|
256
|
+
document.head.appendChild(this.$cssStyleDiv);
|
|
257
|
+
this.$cssStyleDiv.type = 'text/css';
|
|
258
|
+
this.$cssStyleDiv.id = 'subiz-style-for-' + this.props.plugin.id;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
262
|
+
await this.refreshCSS();
|
|
263
|
+
this.interval = setInterval(() => {
|
|
264
|
+
if (this.props._destroy) return this.componentWillUnmount();
|
|
265
|
+
let mouseleave = this.mouse_leave;
|
|
266
|
+
if (mouseleave === 0) mouseleave = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now();
|
|
267
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now() - mouseleave < 1000) return;
|
|
268
|
+
|
|
269
|
+
if (!this.state.close && !this.props.plugin._dont_close) {
|
|
270
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now() - this.state.last_show > 8000) return this.setClose(true);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].Date.now */ .Z.Date.now() - this.state.last_show > this.props.plugin.notification.interval_sec) {
|
|
275
|
+
return this.setClose(false);
|
|
276
|
+
}
|
|
277
|
+
}, 1000);
|
|
278
|
+
setTimeout(() => {
|
|
279
|
+
this.setState({
|
|
280
|
+
cssready: true
|
|
281
|
+
});
|
|
282
|
+
this.setClose(false);
|
|
283
|
+
}, 50);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
renderTextFromQuillDelta(quilldelta, profile) {
|
|
287
|
+
let qd = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].parseJSON */ .Z.parseJSON(quilldelta);
|
|
288
|
+
if (!qd || !qd.ops) return null;
|
|
289
|
+
return _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].map */ .Z.map(qd.ops, op => {
|
|
290
|
+
let out = null;
|
|
291
|
+
if (!op.insert) return null;
|
|
292
|
+
if (typeof op.insert == 'string') out = op.insert;
|
|
293
|
+
|
|
294
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(op, 'insert.dynamicField')) {
|
|
295
|
+
let key = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(op, 'insert.dynamicField.key');
|
|
296
|
+
if (key === 'user.fullname') out = profile.fullname;
|
|
297
|
+
if (key === 'user.email') out = profile.email;
|
|
298
|
+
if (key === 'user.address') out = profile.address;
|
|
299
|
+
if (key === 'user.phone') out = profile.phone;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(op, 'attributes.bold')) out = (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("b", null, out);
|
|
303
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(op, 'attributes.italic')) out = (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("b", null, out);
|
|
304
|
+
return out;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
render() {
|
|
309
|
+
if (!this.props.t) return null;
|
|
310
|
+
if (!this.state.cssready) return null;
|
|
311
|
+
if (!this.state.imageReady) return null;
|
|
312
|
+
if (this.state.close) return null;
|
|
313
|
+
if (!this.state.message) return null;
|
|
314
|
+
let notif = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(this.props.plugin, 'notification', {});
|
|
315
|
+
if (!notif) return null;
|
|
316
|
+
let animation = '';
|
|
317
|
+
let pos = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(notif, 'position', 'bottom-left');
|
|
318
|
+
if (this.props.mobile) pos = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(notif, 'mobile_position', pos);
|
|
319
|
+
if (pos === 'top-left' || pos === 'top-right') animation = 'fadeInDown';else if (pos === 'top-center') animation = 'fadeInDownCenter';else if (pos === 'bottom-center') animation = 'fadeInUpCenter';else if (pos === 'bottom-right') {
|
|
320
|
+
animation = 'fadeInUpBig';
|
|
321
|
+
} else {
|
|
322
|
+
pos = 'bottom-left';
|
|
323
|
+
animation = 'fadeInUpBig';
|
|
324
|
+
}
|
|
325
|
+
let user = this.state.user || {};
|
|
326
|
+
let subtextStyle = notif.subtext_style || {};
|
|
327
|
+
if (subtextStyle.color === undefined) subtextStyle.color = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].get */ .Z.get(notif, 'message_style.color', 'black');
|
|
328
|
+
let st = 'position: fixed !important; z-index: 1000000000 !important';
|
|
329
|
+
if (this.props.plugin._preview) st = 'position: absolute !important;';
|
|
330
|
+
if (this.state.closeAnimation) animation = 'fadeOut';
|
|
331
|
+
return (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
332
|
+
class: animation + ' notif' + ' notif__' + pos,
|
|
333
|
+
onClick: e => this.onClick(e),
|
|
334
|
+
onmouseover: e => this.setOver(true),
|
|
335
|
+
style: st,
|
|
336
|
+
onmouseleave: e => this.setOver(false)
|
|
337
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
338
|
+
style: "position: relative !important; display: flex !important; align-items: center !important;"
|
|
339
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("img", {
|
|
340
|
+
alt: "notification background",
|
|
341
|
+
class: "notif_bg",
|
|
342
|
+
src: notif.background_url,
|
|
343
|
+
style: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].js2css */ .Z.js2css(notif.background_style)
|
|
344
|
+
}), this.renderCloseButton(), (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
345
|
+
class: "notif_avatar",
|
|
346
|
+
style: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].js2css */ .Z.js2css(notif.avatar_style)
|
|
347
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("img", {
|
|
348
|
+
alt: "notification avatar",
|
|
349
|
+
class: "notif_avatar__img",
|
|
350
|
+
src: user.avatar_url
|
|
351
|
+
})), (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
352
|
+
class: "notif_body"
|
|
353
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
354
|
+
class: "notif_title",
|
|
355
|
+
style: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].js2css */ .Z.js2css(notif.title_style)
|
|
356
|
+
}, this.renderTextFromQuillDelta(this.state.title, user)), (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
357
|
+
class: "notif_message",
|
|
358
|
+
style: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].js2css */ .Z.js2css(notif.message_style)
|
|
359
|
+
}, this.renderTextFromQuillDelta(this.state.message, user)), (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)("div", {
|
|
360
|
+
class: "notif_time",
|
|
361
|
+
style: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"].js2css */ .Z.js2css(notif.subtext_style)
|
|
362
|
+
}, this.state.timestamp))));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function randomName() {
|
|
368
|
+
let db = ['Kiều Thanh', 'Phương Anh', 'Lê Thùy Linh', 'Trang Nguyễn', 'Thanh Hoa', 'Hoài Đức', 'Huơng Giang'];
|
|
369
|
+
return db[Math.floor(Math.random() * db.length)];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function randomAge() {
|
|
373
|
+
return 15 + Math.floor(Math.random() * 20);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function ramdomPhone() {
|
|
377
|
+
return '+84' + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + 'xxxx';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function randomEmail() {
|
|
381
|
+
return randomName().split(' ').join('.').toLowerCase() + '@gmail.com';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function randomAddress() {
|
|
385
|
+
let db = ['Dịch Vọng Hậu, Cầu Giấy', 'Quận 1, TP Hồ Chí Minh', 'Ngõ 34 Tôn Thất Thuyết', '87 Phạm Hùng', 'Đống Đa, Hà Nội'];
|
|
386
|
+
return db[Math.floor(Math.random() * db.length)];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/***/ })
|
|
390
|
+
|
|
391
|
+
}]);
|