@subiz/widget-v4 4.0.92 → 4.0.93
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/compiled_src/bot.js +0 -11
- package/compiled_src/call/call.js +0 -61
- package/compiled_src/call/css.js +0 -2
- package/compiled_src/chatbox/AgentsAvatar.js +0 -16
- package/compiled_src/chatbox/AudioAttachments.js +0 -14
- package/compiled_src/chatbox/ButtonAttachments.js +1 -14
- package/compiled_src/chatbox/Buttons.js +0 -13
- package/compiled_src/chatbox/ChatButton.js +1 -78
- package/compiled_src/chatbox/DropdownSelect.js +3 -44
- package/compiled_src/chatbox/Emoji.js +0 -7
- package/compiled_src/chatbox/Event.js +0 -59
- package/compiled_src/chatbox/Events.js +4 -44
- package/compiled_src/chatbox/FileAttachments.js +0 -14
- package/compiled_src/chatbox/FormAttachment.js +1 -52
- package/compiled_src/chatbox/FormAttachments.js +0 -14
- package/compiled_src/chatbox/FormSubmitAttachments.js +0 -11
- package/compiled_src/chatbox/GenericTemplateAttachments.js +1 -20
- package/compiled_src/chatbox/Header.js +1 -46
- package/compiled_src/chatbox/ImageAttachments.js +0 -16
- package/compiled_src/chatbox/InfoMessage.js +0 -13
- package/compiled_src/chatbox/ListField.js +0 -16
- package/compiled_src/chatbox/MessageInput.js +1 -47
- package/compiled_src/chatbox/Order.js +0 -35
- package/compiled_src/chatbox/OrderAttachments.js +1 -23
- package/compiled_src/chatbox/PoweredBy.js +0 -7
- package/compiled_src/chatbox/ProductAttachments.js +0 -19
- package/compiled_src/chatbox/QuickReplies.js +0 -18
- package/compiled_src/chatbox/Rating.js +0 -37
- package/compiled_src/chatbox/ShadowDomRoot.js +0 -9
- package/compiled_src/chatbox/TextMessage.js +0 -64
- package/compiled_src/chatbox/Typing.js +0 -15
- package/compiled_src/chatbox/VideoAttachments.js +0 -14
- package/compiled_src/chatbox/Widget.js +6 -167
- package/compiled_src/chatbox/css.js +0 -2
- package/compiled_src/chatbox/dragscroll.js +1 -5
- package/compiled_src/chatbox/main.js +1 -40
- package/compiled_src/chatbox/releaseAnimation.js +0 -11
- package/compiled_src/chatbox/spinner.js +0 -10
- package/compiled_src/chatbox/time.js +0 -22
- package/compiled_src/chatbox/touchscroll.js +0 -7
- package/compiled_src/common.js +0 -22
- package/compiled_src/contact/contact.js +2 -52
- package/compiled_src/contact/css.js +0 -2
- package/compiled_src/lib.js +19 -46
- package/compiled_src/notif/css.js +0 -2
- package/compiled_src/notif/notif.js +0 -63
- package/compiled_src/order/address_picker.js +4 -38
- package/compiled_src/order/icon.js +0 -16
- package/compiled_src/order/index.js +1 -34
- package/compiled_src/order/order.js +2 -156
- package/compiled_src/plugin.js +1 -77
- package/compiled_src/popup/countdown.js +2 -33
- package/compiled_src/popup/css.js +0 -2
- package/compiled_src/popup/popup.js +2 -165
- package/compiled_src/popup/tick.core.commonjs.js +72 -222
- package/compiled_src/popup/tick.view.flip.commonjs.js +23 -31
- package/compiled_src/store/api.js +99 -65
- package/compiled_src/store/api_fake.js +3 -39
- package/compiled_src/store/realtime_fake.js +0 -6
- package/compiled_src/store/store.js +42 -248
- package/compiled_src/util/campaign.js +0 -13
- package/compiled_src/util/common.js +15 -185
- package/compiled_src/util/common.test.js +0 -4
- package/compiled_src/util/extractor.js +1 -21
- package/compiled_src/util/extractor.test.js +0 -3
- package/compiled_src/util/gate.js +0 -7
- package/compiled_src/util/gate.test.js +1 -2
- package/compiled_src/util/index.js +1 -7
- package/compiled_src/util/mutex.js +31 -0
- package/compiled_src/util/op.js +1 -14
- package/compiled_src/util/pubsub.js +0 -6
- package/compiled_src/util/pubsub.test.js +0 -2
- package/package.json +11 -11
- package/src/lib.js +24 -2
- package/src/store/api.js +110 -21
- package/src/store/api_fake.js +5 -6
- package/src/store/store.js +31 -5
- package/src/util/index.js +1 -0
- package/src/util/mutex.js +27 -0
- package/dist/132.js +0 -7092
- package/dist/178.js +0 -406
- package/dist/18364d15f37.132.js +0 -1
- package/dist/18364d15f37.178.js +0 -1
- package/dist/18364d15f37.213.js +0 -1
- package/dist/18364d15f37.335.js +0 -1
- package/dist/18364d15f37.362.js +0 -1
- package/dist/18364d15f37.441.js +0 -1
- package/dist/18364d15f37.605.js +0 -1
- package/dist/18364d15f37.678.js +0 -1
- package/dist/18364d15f37.782.js +0 -1
- package/dist/18364d15f37.app.js +0 -1
- package/dist/18364d15f37.index.html +0 -26
- package/dist/18364d15f37.library.html +0 -26
- package/dist/18364d15f37.library.js +0 -1
- package/dist/18364d15f37.preview.html +0 -759
- package/dist/18364d15f37.preview.js +0 -1
- package/dist/18364d15f37.screenshoot.js +0 -1
- package/dist/213.js +0 -3215
- package/dist/335.js +0 -411
- package/dist/362.js +0 -107
- package/dist/441.js +0 -2834
- package/dist/605.js +0 -328
- package/dist/678.js +0 -107
- package/dist/782.js +0 -107
- package/dist/HASH +0 -1
- package/dist/assets/img/Facebook.64607ec.png +0 -0
- package/dist/assets/img/Zalo.6845707.png +0 -0
- package/dist/assets/img/award1a.1a58e10.png +0 -0
- package/dist/assets/img/award3a.3b74423.png +0 -0
- package/dist/assets/img/award4a.ed6ccd4.png +0 -0
- package/dist/assets/img/award5.39eb7ae.png +0 -0
- package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
- package/dist/assets/img/caret.998eb8f.svg +0 -1
- package/dist/assets/img/convos_empty.2353007.svg +0 -72
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
- package/dist/assets/img/done_gray.d7e8203.svg +0 -4
- package/dist/assets/img/done_green.b817fd4.svg +0 -4
- package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
- package/dist/assets/img/empty.29bed2d.svg +0 -23
- package/dist/assets/img/empty_1.0b98af0.svg +0 -11
- package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
- package/dist/assets/img/external-link.90577cc.svg +0 -1
- package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
- package/dist/assets/img/ghn.070f8e3.svg +0 -17
- package/dist/assets/img/ghtk.326eac1.svg +0 -18
- package/dist/assets/img/image_default.be0698b.png +0 -0
- package/dist/assets/img/info.ebce7ea.svg +0 -1
- package/dist/assets/img/loader.37000a7.svg +0 -1
- package/dist/assets/img/loading_static.8f403ae.svg +0 -10
- package/dist/assets/img/main-service1.d536cc2.png +0 -0
- package/dist/assets/img/main-service2.9b99549.png +0 -0
- package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
- package/dist/assets/img/package.8d37d0f.svg +0 -5
- package/dist/assets/img/package_fade.763c001.svg +0 -1
- package/dist/assets/img/rating--average.1ea492c.svg +0 -12
- package/dist/assets/img/rating--great.e3d712e.svg +0 -16
- package/dist/assets/img/rating--poor.2938a25.svg +0 -12
- package/dist/assets/img/search.f9705ff.svg +0 -1
- package/dist/assets/img/send.6db52a9.svg +0 -3
- package/dist/assets/img/shop.f7dc7d8.svg +0 -1
- package/dist/assets/img/shop_faded.df7845a.svg +0 -1
- package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
- package/dist/assets/img/x.26fdfa3.svg +0 -5
- package/dist/malicious-app.js +0 -13
- package/dist/screenshoot.html +0 -7
- package/dist/screenshoot.js +0 -5953
|
@@ -4,29 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
9
|
-
|
|
10
8
|
var _countdown = _interopRequireDefault(require("./countdown.js"));
|
|
11
|
-
|
|
12
9
|
var _preact = require("preact");
|
|
13
|
-
|
|
14
10
|
var _common = require("../common.js");
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
15
|
let popupCSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('./css.js'))))();
|
|
25
16
|
|
|
26
17
|
class Popup extends _common.Com {
|
|
27
18
|
constructor(props) {
|
|
28
19
|
super(props);
|
|
29
|
-
|
|
30
20
|
_defineProperty(this, "state", {
|
|
31
21
|
close: false,
|
|
32
22
|
cssready: false,
|
|
@@ -35,7 +25,6 @@ class Popup extends _common.Com {
|
|
|
35
25
|
imageReady: false,
|
|
36
26
|
fontReady: false
|
|
37
27
|
});
|
|
38
|
-
|
|
39
28
|
this._formRef = (0, _preact.createRef)();
|
|
40
29
|
setTimeout(() => this.fillForm(), 1000);
|
|
41
30
|
setTimeout(async () => {
|
|
@@ -48,33 +37,26 @@ class Popup extends _common.Com {
|
|
|
48
37
|
let fonts = {};
|
|
49
38
|
fonts[this.props.plugin.popup.font_family] = true;
|
|
50
39
|
let images = {};
|
|
51
|
-
|
|
52
40
|
_index.default.map(this.props.plugin.popup.pages, page => {
|
|
53
41
|
if (!page) return;
|
|
54
|
-
|
|
55
42
|
_index.default.map(page.components, com => {
|
|
56
43
|
fonts[_index.default.get(com, 'style.font_family')] = true;
|
|
57
44
|
fonts[_index.default.get(com, 'mobile_style.font_family')] = true;
|
|
58
|
-
|
|
59
45
|
if (com.type === 'image' && com.image && com.image.url && com.image.url.startsWith('http')) {
|
|
60
46
|
images[com.image.url] = true;
|
|
61
47
|
}
|
|
62
48
|
});
|
|
63
49
|
});
|
|
64
|
-
|
|
65
50
|
delete fonts.undefined;
|
|
66
51
|
delete fonts.null;
|
|
67
52
|
delete fonts[''];
|
|
68
53
|
if (_index.default.size(images) == 0) this.setState({
|
|
69
54
|
imageReady: true
|
|
70
55
|
});
|
|
71
|
-
|
|
72
56
|
_index.default.map(images, (_, image) => _index.default.preloadImg(image, () => this.setState({
|
|
73
57
|
imageReady: true
|
|
74
58
|
})));
|
|
75
|
-
|
|
76
59
|
_index.default.preloadWebfonts(Object.keys(fonts));
|
|
77
|
-
|
|
78
60
|
setTimeout(async () => {
|
|
79
61
|
await this.waitForFont(Object.keys(fonts));
|
|
80
62
|
this.setState({
|
|
@@ -83,11 +65,9 @@ class Popup extends _common.Com {
|
|
|
83
65
|
});
|
|
84
66
|
});
|
|
85
67
|
}
|
|
86
|
-
|
|
87
68
|
async waitForFont(fonts) {
|
|
88
69
|
if (_index.default.size(fonts) == 0) return;
|
|
89
70
|
let ready = {};
|
|
90
|
-
|
|
91
71
|
for (var t = 0; t < 10; t++) {
|
|
92
72
|
for (var i = 0; i < fonts.length; i++) {
|
|
93
73
|
try {
|
|
@@ -95,60 +75,45 @@ class Popup extends _common.Com {
|
|
|
95
75
|
if (Object.keys(readycount) == fonts.length) return;
|
|
96
76
|
} catch (e) {}
|
|
97
77
|
}
|
|
98
|
-
|
|
99
78
|
await _index.default.sleep(200);
|
|
100
79
|
}
|
|
101
|
-
|
|
102
80
|
return;
|
|
103
81
|
}
|
|
104
|
-
|
|
105
82
|
openPopup() {
|
|
106
83
|
this.setState({
|
|
107
84
|
close: false
|
|
108
85
|
});
|
|
109
86
|
}
|
|
110
|
-
|
|
111
87
|
getPageIndex() {
|
|
112
88
|
if (this.props.plugin._page_index !== undefined) return this.props.plugin._page_index;
|
|
113
89
|
return this.props.pageIndex;
|
|
114
90
|
}
|
|
115
|
-
|
|
116
91
|
isFormFilled() {
|
|
117
92
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
118
|
-
|
|
119
93
|
let form = _index.default.find(page.components, com => com.type === 'form');
|
|
120
|
-
|
|
121
94
|
if (!form || !form.form) return true;
|
|
122
95
|
|
|
123
96
|
let fields = _index.default.get(form, 'form.fields', []);
|
|
124
|
-
|
|
125
97
|
let wrong = _index.default.find(fields, field => {
|
|
126
98
|
if (!field.is_required) return false;
|
|
127
99
|
if (!this.isFieldValid(field.key, field.validate)) return true;
|
|
128
100
|
return this.isFieldEmpty(field.key);
|
|
129
101
|
});
|
|
130
|
-
|
|
131
102
|
return !wrong;
|
|
132
103
|
}
|
|
133
|
-
|
|
134
104
|
fillForm() {
|
|
135
105
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
136
|
-
|
|
137
106
|
let form = _index.default.find(page.components, com => com.type === 'form');
|
|
138
|
-
|
|
139
107
|
if (!form) return;
|
|
140
|
-
let user = this.props.store.matchUser();
|
|
141
108
|
|
|
109
|
+
let user = this.props.store.matchUser();
|
|
142
110
|
let userAttributes = _index.default.get(user, 'attributes');
|
|
143
|
-
|
|
144
111
|
let fields = _index.default.get(form, 'form.fields', []);
|
|
145
|
-
|
|
146
112
|
_index.default.each(fields, field => {
|
|
147
113
|
let fieldkey = field.key;
|
|
148
114
|
if (fieldkey === 'email') fieldkey = 'emails';
|
|
149
115
|
if (fieldkey === 'phone') fieldkey = 'phones';
|
|
150
116
|
if (fieldkey !== 'emails' || fieldkey != 'phones' || fieldkey !== 'fullname') return;
|
|
151
|
-
|
|
152
117
|
_index.default.map(userAttributes, attr => {
|
|
153
118
|
if (fieldkey !== attr.key) return;
|
|
154
119
|
var input = this._formRef.current.elements[field.key];
|
|
@@ -157,12 +122,10 @@ class Popup extends _common.Com {
|
|
|
157
122
|
});
|
|
158
123
|
});
|
|
159
124
|
}
|
|
160
|
-
|
|
161
125
|
isFieldValid(key, validate) {
|
|
162
126
|
if (!validate) return true;
|
|
163
127
|
if (!this._formRef || !this._formRef.current) return false;
|
|
164
128
|
var formData = new FormData(this._formRef.current);
|
|
165
|
-
|
|
166
129
|
for (var pair of formData.entries()) {
|
|
167
130
|
if (pair[0] !== key) continue;
|
|
168
131
|
if (validate === 'email') return _index.default.isEmail(pair[1]);
|
|
@@ -171,22 +134,17 @@ class Popup extends _common.Com {
|
|
|
171
134
|
if (validate === 'number') return _index.default.isNumber(pair[1]);
|
|
172
135
|
return true;
|
|
173
136
|
}
|
|
174
|
-
|
|
175
137
|
return true;
|
|
176
138
|
}
|
|
177
|
-
|
|
178
139
|
isFieldEmpty(key) {
|
|
179
140
|
if (!this._formRef || !this._formRef.current) return false;
|
|
180
141
|
var formData = new FormData(this._formRef.current);
|
|
181
|
-
|
|
182
142
|
for (var pair of formData.entries()) {
|
|
183
143
|
if (pair[0] !== key) continue;
|
|
184
144
|
return pair[1] === '' || pair[1] === undefined;
|
|
185
145
|
}
|
|
186
|
-
|
|
187
146
|
return true;
|
|
188
147
|
}
|
|
189
|
-
|
|
190
148
|
renderCloseButton() {
|
|
191
149
|
if (!this.props.plugin.popup.show_close_button) return null;
|
|
192
150
|
return (0, _preact.h)("div", {
|
|
@@ -214,7 +172,6 @@ class Popup extends _common.Com {
|
|
|
214
172
|
style: "stroke-width: 3 !important;"
|
|
215
173
|
})));
|
|
216
174
|
}
|
|
217
|
-
|
|
218
175
|
setClose(close) {
|
|
219
176
|
if (close) {
|
|
220
177
|
document.body.style.setProperty('overflow', this.lastoverflow);
|
|
@@ -241,23 +198,16 @@ class Popup extends _common.Com {
|
|
|
241
198
|
});
|
|
242
199
|
}
|
|
243
200
|
}
|
|
244
|
-
|
|
245
201
|
onButtonClick(e, buttontype) {
|
|
246
202
|
e.stopPropagation();
|
|
247
|
-
|
|
248
203
|
let popup = _index.default.get(this.props.plugin, 'popup', {});
|
|
249
|
-
|
|
250
204
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
251
|
-
|
|
252
205
|
let actions = [];
|
|
253
|
-
|
|
254
206
|
let buttons = _index.default.find(page.components, com => com.type === 'buttons');
|
|
255
|
-
|
|
256
207
|
if (buttontype === 'background') actions = _index.default.get(page, 'background_click.actions') || [];
|
|
257
208
|
if (buttontype === 'primary' && buttons.buttons.primary_enabled) actions = buttons.buttons.primary_actions || [];
|
|
258
209
|
if (buttontype === 'secondary' && buttons.buttons.secondary_enabled) actions = buttons.buttons.secondary_actions || [];
|
|
259
210
|
let mustfillform = false;
|
|
260
|
-
|
|
261
211
|
for (let a of actions) {
|
|
262
212
|
if (a.action === 'conversion' || a.action === 'submit') {
|
|
263
213
|
mustfillform = true;
|
|
@@ -266,42 +216,31 @@ class Popup extends _common.Com {
|
|
|
266
216
|
});
|
|
267
217
|
}
|
|
268
218
|
}
|
|
269
|
-
|
|
270
219
|
if (mustfillform && !this.isFormFilled()) return;
|
|
271
220
|
var hasConversion = false;
|
|
272
|
-
|
|
273
221
|
for (let a of actions) {
|
|
274
222
|
if (a.action === 'submit' || a.action === 'conversion') hasConversion = true;
|
|
275
223
|
}
|
|
276
|
-
|
|
277
224
|
if (hasConversion) {
|
|
278
225
|
var formData = this._formRef.current ? new FormData(this._formRef.current) : new FormData();
|
|
279
226
|
var summitFields = [];
|
|
280
|
-
|
|
281
227
|
let user = _index.default.cloneDeep(this.props.store.matchUser());
|
|
282
|
-
|
|
283
228
|
let is_lead = false;
|
|
284
|
-
let modifiedPairs = {};
|
|
285
229
|
|
|
230
|
+
let modifiedPairs = {};
|
|
286
231
|
for (var pair of formData.entries()) {
|
|
287
232
|
if (modifiedPairs[pair[0]]) {
|
|
288
233
|
let currentValue = _index.default.get(modifiedPairs, `${pair[0]}.1`, '');
|
|
289
|
-
|
|
290
234
|
currentValue += `,${pair[1]}`;
|
|
291
|
-
|
|
292
235
|
_index.default.set(modifiedPairs, `${pair[0]}.1`, currentValue);
|
|
293
236
|
} else {
|
|
294
237
|
modifiedPairs[pair[0]] = [pair[0], pair[1]];
|
|
295
238
|
}
|
|
296
239
|
}
|
|
297
|
-
|
|
298
240
|
for (const [_, pair] of Object.entries(modifiedPairs)) {
|
|
299
241
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
300
|
-
|
|
301
242
|
let form = _index.default.find(page.components, com => com.type === 'form');
|
|
302
|
-
|
|
303
243
|
let fields = _index.default.get(form, 'form.fields', []);
|
|
304
|
-
|
|
305
244
|
let field = _index.default.find(fields, field => field.key === pair[0]) || {};
|
|
306
245
|
if (!field.type) return;
|
|
307
246
|
summitFields.push({
|
|
@@ -313,13 +252,11 @@ class Popup extends _common.Com {
|
|
|
313
252
|
if (key === 'email') key = 'emails';
|
|
314
253
|
if (key === 'phone') key = 'phones';
|
|
315
254
|
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
316
|
-
|
|
317
255
|
_index.default.setUserAttr(user, {
|
|
318
256
|
key: key,
|
|
319
257
|
text: pair[1]
|
|
320
258
|
});
|
|
321
259
|
}
|
|
322
|
-
|
|
323
260
|
if (is_lead) _index.default.setUserAttr(user, {
|
|
324
261
|
key: 'lead_source',
|
|
325
262
|
text: 'plugin.' + this.props.plugin.id
|
|
@@ -327,32 +264,26 @@ class Popup extends _common.Com {
|
|
|
327
264
|
this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
|
|
328
265
|
this.props.store.setUser(user);
|
|
329
266
|
}
|
|
330
|
-
|
|
331
267
|
for (let a of actions) {
|
|
332
268
|
if (a.action === 'open_widget') this.props.showWidget('list');
|
|
333
269
|
}
|
|
334
|
-
|
|
335
270
|
for (let a of actions) {
|
|
336
271
|
if (a.action === 'close') setTimeout(() => this.setClose(true), 100);
|
|
337
272
|
if (a.action === 'next_page') this.props.nextPage();
|
|
338
273
|
}
|
|
339
|
-
|
|
340
274
|
for (let a of actions) {
|
|
341
275
|
if (!a.url) continue;
|
|
342
276
|
let url = a.url;
|
|
343
277
|
if (!url.startsWith('http://') && !url.startsWith('https://')) url = '//' + url;
|
|
344
278
|
if (a.action === 'open_url' && a.new_tab) return window.open(url, '_blank');
|
|
345
|
-
|
|
346
279
|
if (a.action === 'open_url' && !a.new_tab) {
|
|
347
280
|
window.location.href = url;
|
|
348
281
|
return;
|
|
349
282
|
}
|
|
350
283
|
}
|
|
351
284
|
}
|
|
352
|
-
|
|
353
285
|
renderButtons(com, page) {
|
|
354
286
|
let popup = _index.default.get(this.props.plugin, 'popup', {});
|
|
355
|
-
|
|
356
287
|
let buttonsstyle = com.style || {};
|
|
357
288
|
let primarystyle = Object.assign({}, buttonsstyle);
|
|
358
289
|
delete primarystyle.justify_content;
|
|
@@ -364,7 +295,6 @@ class Popup extends _common.Com {
|
|
|
364
295
|
primarystyle.font_size = primarystyle.font_size || popup.font_size || '14px';
|
|
365
296
|
primarystyle.background = primarystyle.background || popup.text_color;
|
|
366
297
|
let $primary = null;
|
|
367
|
-
|
|
368
298
|
if (com.buttons.primary_enabled && com.buttons.primary_text) {
|
|
369
299
|
let style = Object.assign({
|
|
370
300
|
font_size: popup.font_size || '14px'
|
|
@@ -377,9 +307,7 @@ class Popup extends _common.Com {
|
|
|
377
307
|
onClick: e => this.onButtonClick(e, 'primary')
|
|
378
308
|
}, this.props.t.i18n(com.buttons.i18n_primary_text) || com.buttons.primary_text);
|
|
379
309
|
}
|
|
380
|
-
|
|
381
310
|
let $secondary = null;
|
|
382
|
-
|
|
383
311
|
if (com.buttons.secondary_enabled && com.buttons.secondary_text) {
|
|
384
312
|
let style = Object.assign({
|
|
385
313
|
font_size: popup.font_size || '14px'
|
|
@@ -390,7 +318,6 @@ class Popup extends _common.Com {
|
|
|
390
318
|
onClick: e => this.onButtonClick(e, 'secondary')
|
|
391
319
|
}, this.props.t.i18n(com.buttons.i18n_secondary_text) || com.buttons.secondary_text);
|
|
392
320
|
}
|
|
393
|
-
|
|
394
321
|
return (0, _preact.h)("div", {
|
|
395
322
|
class: "popup_component",
|
|
396
323
|
style: this.js2css({
|
|
@@ -405,7 +332,6 @@ class Popup extends _common.Com {
|
|
|
405
332
|
})
|
|
406
333
|
}), $secondary);
|
|
407
334
|
}
|
|
408
|
-
|
|
409
335
|
js2css(js, onlyProps) {
|
|
410
336
|
let spacer = this.props.plugin.popup.spacer || 10;
|
|
411
337
|
return _index.default.js2css(js, onlyProps, {
|
|
@@ -420,10 +346,8 @@ class Popup extends _common.Com {
|
|
|
420
346
|
'@spacer3': spacer * 3 + 'px'
|
|
421
347
|
});
|
|
422
348
|
}
|
|
423
|
-
|
|
424
349
|
renderSingleChoiceField(field) {
|
|
425
350
|
var cls = 'form-control form-control__select ' + this.props.plugin.popup.theme;
|
|
426
|
-
|
|
427
351
|
let $options = _index.default.map(field.options, option => {
|
|
428
352
|
return (0, _preact.h)("label", {
|
|
429
353
|
class: cls
|
|
@@ -433,21 +357,16 @@ class Popup extends _common.Com {
|
|
|
433
357
|
value: option.value
|
|
434
358
|
}), (0, _preact.h)("span", null, this.props.t.i18n(option.i18n_label) || option.label));
|
|
435
359
|
});
|
|
436
|
-
|
|
437
360
|
return (0, _preact.h)(_preact.Fragment, null, $options);
|
|
438
361
|
}
|
|
439
|
-
|
|
440
362
|
renderDropdownField(field) {
|
|
441
363
|
let $options = _index.default.map(field.options, option => {
|
|
442
364
|
return (0, _preact.h)("option", {
|
|
443
365
|
value: option.value
|
|
444
366
|
}, option.value);
|
|
445
367
|
});
|
|
446
|
-
|
|
447
368
|
let theme = _index.default.get(this.props.plugin, 'popup.theme');
|
|
448
|
-
|
|
449
369
|
var cls = 'form-control form-control__select ' + theme;
|
|
450
|
-
|
|
451
370
|
if (theme === 'vintage') {
|
|
452
371
|
return (0, _preact.h)("div", {
|
|
453
372
|
class: "form-control__text_container"
|
|
@@ -458,16 +377,13 @@ class Popup extends _common.Com {
|
|
|
458
377
|
name: field.key
|
|
459
378
|
}, $options));
|
|
460
379
|
}
|
|
461
|
-
|
|
462
380
|
return (0, _preact.h)("select", {
|
|
463
381
|
class: cls,
|
|
464
382
|
name: field.key
|
|
465
383
|
}, $options);
|
|
466
384
|
}
|
|
467
|
-
|
|
468
385
|
renderMutiChoiceField(field) {
|
|
469
386
|
var cls = 'form-control form-control__check ' + this.props.plugin.popup.theme;
|
|
470
|
-
|
|
471
387
|
let $options = _index.default.map(field.options, option => {
|
|
472
388
|
return (0, _preact.h)("label", {
|
|
473
389
|
class: cls
|
|
@@ -478,15 +394,11 @@ class Popup extends _common.Com {
|
|
|
478
394
|
value: option.value
|
|
479
395
|
}), (0, _preact.h)("span", null, this.props.t.i18n(option.i18n_label) || option.label));
|
|
480
396
|
});
|
|
481
|
-
|
|
482
397
|
return (0, _preact.h)(_preact.Fragment, null, $options);
|
|
483
398
|
}
|
|
484
|
-
|
|
485
399
|
renderTextField(field) {
|
|
486
400
|
let theme = _index.default.get(this.props.plugin, 'popup.theme');
|
|
487
|
-
|
|
488
401
|
var cls = 'form-control form-control__text ' + theme;
|
|
489
|
-
|
|
490
402
|
if (theme === 'simple') {
|
|
491
403
|
return (0, _preact.h)("input", {
|
|
492
404
|
type: field.type,
|
|
@@ -496,7 +408,6 @@ class Popup extends _common.Com {
|
|
|
496
408
|
placeholder: this.props.t.i18n(field.i18n_label) || field.label || this.props.t.i18n(field.i18n_placeholder) || field.placeholder
|
|
497
409
|
});
|
|
498
410
|
}
|
|
499
|
-
|
|
500
411
|
if (theme === 'vintage') {
|
|
501
412
|
return (0, _preact.h)("div", {
|
|
502
413
|
class: "form-control__text_container"
|
|
@@ -510,7 +421,6 @@ class Popup extends _common.Com {
|
|
|
510
421
|
placeholder: this.props.t.i18n(field.i18n_placeholder) || field.placeholder
|
|
511
422
|
}));
|
|
512
423
|
}
|
|
513
|
-
|
|
514
424
|
return (0, _preact.h)("input", {
|
|
515
425
|
type: field.type,
|
|
516
426
|
class: cls,
|
|
@@ -519,12 +429,9 @@ class Popup extends _common.Com {
|
|
|
519
429
|
placeholder: this.props.t.i18n(field.i18n_placeholder) || field.placeholder
|
|
520
430
|
});
|
|
521
431
|
}
|
|
522
|
-
|
|
523
432
|
renderMultilineTextField(field) {
|
|
524
433
|
let theme = _index.default.get(this.props.plugin, 'popup.theme');
|
|
525
|
-
|
|
526
434
|
var cls = 'form-control form-control__text ' + theme;
|
|
527
|
-
|
|
528
435
|
if (theme === 'simple') {
|
|
529
436
|
return (0, _preact.h)("textarea", {
|
|
530
437
|
rows: "3",
|
|
@@ -539,7 +446,6 @@ class Popup extends _common.Com {
|
|
|
539
446
|
placeholder: this.props.t.i18n(field.i18n_label) || field.label || this.props.t.i18n(field.i18n_placeholder) || field.placeholder
|
|
540
447
|
});
|
|
541
448
|
}
|
|
542
|
-
|
|
543
449
|
if (theme === 'vintage') {
|
|
544
450
|
return (0, _preact.h)("div", {
|
|
545
451
|
class: "form-control__text_container"
|
|
@@ -558,7 +464,6 @@ class Popup extends _common.Com {
|
|
|
558
464
|
placeholder: this.props.t.i18n(field.i18n_label) || field.label || this.props.t.i18n(field.i18n_placeholder) || field.placeholder
|
|
559
465
|
}));
|
|
560
466
|
}
|
|
561
|
-
|
|
562
467
|
return (0, _preact.h)("textarea", {
|
|
563
468
|
rows: "3",
|
|
564
469
|
name: field.key,
|
|
@@ -572,10 +477,8 @@ class Popup extends _common.Com {
|
|
|
572
477
|
placeholder: this.props.t.i18n(field.i18n_placeholder) || field.placeholder
|
|
573
478
|
});
|
|
574
479
|
}
|
|
575
|
-
|
|
576
480
|
renderFormComponent(com) {
|
|
577
481
|
let popup = _index.default.get(this.props.plugin, 'popup', {});
|
|
578
|
-
|
|
579
482
|
let $fields = _index.default.map(com.form.fields, field => {
|
|
580
483
|
if (field.type === 'email') return this.renderTextField(field);
|
|
581
484
|
if (field.type === 'single-choice') return this.renderSingleChoiceField(field);
|
|
@@ -585,9 +488,7 @@ class Popup extends _common.Com {
|
|
|
585
488
|
if (field.type === 'dropdown') return this.renderDropdownField(field);
|
|
586
489
|
return;
|
|
587
490
|
});
|
|
588
|
-
|
|
589
491
|
let theme = _index.default.get(popup, 'theme');
|
|
590
|
-
|
|
591
492
|
$fields = _index.default.map($fields, ($field, i) => {
|
|
592
493
|
let $label = null;
|
|
593
494
|
let field = com.form.fields[i];
|
|
@@ -600,13 +501,10 @@ class Popup extends _common.Com {
|
|
|
600
501
|
})
|
|
601
502
|
}, this.props.t.i18n(field.i18n_label) || field.label);
|
|
602
503
|
if (theme === 'vintage' && field.type === 'dropdown') $label = null;
|
|
603
|
-
|
|
604
504
|
if (theme === 'vintage' || theme === 'simple') {
|
|
605
505
|
if (field.type === 'email' || field.type === 'text' || field.type === 'multiline-text') $label = null;
|
|
606
506
|
}
|
|
607
|
-
|
|
608
507
|
let $error = null;
|
|
609
|
-
|
|
610
508
|
if (this.state.pressedSubmit && !this.isFieldValid(field.key, field.validate)) {
|
|
611
509
|
$error = (0, _preact.h)("div", {
|
|
612
510
|
class: "text__danger ",
|
|
@@ -617,7 +515,6 @@ class Popup extends _common.Com {
|
|
|
617
515
|
})
|
|
618
516
|
}, this.props.t('invalid_field'));
|
|
619
517
|
}
|
|
620
|
-
|
|
621
518
|
if (this.state.pressedSubmit && field.is_required && this.isFieldEmpty(field.key)) {
|
|
622
519
|
$error = (0, _preact.h)("div", {
|
|
623
520
|
class: "text__danger ",
|
|
@@ -628,7 +525,6 @@ class Popup extends _common.Com {
|
|
|
628
525
|
})
|
|
629
526
|
}, this.props.t('required'));
|
|
630
527
|
}
|
|
631
|
-
|
|
632
528
|
return (0, _preact.h)("div", {
|
|
633
529
|
class: "field"
|
|
634
530
|
}, $label, $field, $error);
|
|
@@ -643,7 +539,6 @@ class Popup extends _common.Com {
|
|
|
643
539
|
|
|
644
540
|
renderComponents(page) {
|
|
645
541
|
let buttons = _index.default.find(page.components, com => com.type === 'buttons');
|
|
646
|
-
|
|
647
542
|
let $buttons = null;
|
|
648
543
|
if (buttons) $buttons = this.renderButtons(buttons, page);
|
|
649
544
|
let comIndexWithoutImg = 0;
|
|
@@ -668,10 +563,8 @@ class Popup extends _common.Com {
|
|
|
668
563
|
}));
|
|
669
564
|
});
|
|
670
565
|
}
|
|
671
|
-
|
|
672
566
|
renderFollowFacebook(com) {
|
|
673
567
|
let fburl = _index.default.get(com, 'follow_facebook.url');
|
|
674
|
-
|
|
675
568
|
if (!fburl) return null;
|
|
676
569
|
let style = this.props.mobile && com.mobile_style || com.style;
|
|
677
570
|
let containerstyle = {
|
|
@@ -699,12 +592,9 @@ class Popup extends _common.Com {
|
|
|
699
592
|
}, textstyle))
|
|
700
593
|
}, this.props.t('follow_us_on_facebook'))));
|
|
701
594
|
}
|
|
702
|
-
|
|
703
595
|
renderSocialButtons(com) {
|
|
704
596
|
let fburl = _index.default.get(com, 'social_buttons.facebook');
|
|
705
|
-
|
|
706
597
|
let $fb = null;
|
|
707
|
-
|
|
708
598
|
if (fburl) {
|
|
709
599
|
$fb = (0, _preact.h)("a", {
|
|
710
600
|
href: fburl,
|
|
@@ -716,11 +606,8 @@ class Popup extends _common.Com {
|
|
|
716
606
|
src: require('../../assets/img/Facebook.png')
|
|
717
607
|
}));
|
|
718
608
|
}
|
|
719
|
-
|
|
720
609
|
let zlurl = _index.default.get(com, 'social_buttons.zalo');
|
|
721
|
-
|
|
722
610
|
let $zl = null;
|
|
723
|
-
|
|
724
611
|
if (zlurl) {
|
|
725
612
|
$zl = (0, _preact.h)("a", {
|
|
726
613
|
href: zlurl,
|
|
@@ -732,7 +619,6 @@ class Popup extends _common.Com {
|
|
|
732
619
|
src: require('../../assets/img/Zalo.png')
|
|
733
620
|
}));
|
|
734
621
|
}
|
|
735
|
-
|
|
736
622
|
let style = this.props.mobile && com.mobile_style || com.style;
|
|
737
623
|
return (0, _preact.h)("div", {
|
|
738
624
|
class: "social_buttons popup_component",
|
|
@@ -740,7 +626,6 @@ class Popup extends _common.Com {
|
|
|
740
626
|
onClick: e => e.stopPropagation()
|
|
741
627
|
}, $fb, " ", $zl);
|
|
742
628
|
}
|
|
743
|
-
|
|
744
629
|
renderImageComponent(com, i) {
|
|
745
630
|
let style = Object.assign({
|
|
746
631
|
pointer_events: 'none'
|
|
@@ -761,7 +646,6 @@ class Popup extends _common.Com {
|
|
|
761
646
|
})
|
|
762
647
|
}));
|
|
763
648
|
}
|
|
764
|
-
|
|
765
649
|
renderLineComponent(com) {
|
|
766
650
|
let style = this.props.mobile && com.mobile_style || com.style;
|
|
767
651
|
return (0, _preact.h)("div", {
|
|
@@ -769,10 +653,8 @@ class Popup extends _common.Com {
|
|
|
769
653
|
style: this.js2css(style)
|
|
770
654
|
});
|
|
771
655
|
}
|
|
772
|
-
|
|
773
656
|
renderTextComponent(com, isFirst) {
|
|
774
657
|
let popup = _index.default.get(this.props.plugin, 'popup', {});
|
|
775
|
-
|
|
776
658
|
let style = Object.assign({
|
|
777
659
|
color: popup.text_color,
|
|
778
660
|
font_family: popup.font_family,
|
|
@@ -787,40 +669,28 @@ class Popup extends _common.Com {
|
|
|
787
669
|
onClick: e => e.stopPropagation()
|
|
788
670
|
}, this.props.t.i18n(_index.default.get(com, 'text.i18n_html')) || _index.default.get(com, 'text.html'));
|
|
789
671
|
}
|
|
790
|
-
|
|
791
672
|
async refreshCSS() {
|
|
792
673
|
let plugins = this.props.store.matchPlugin();
|
|
793
|
-
|
|
794
674
|
let found = _index.default.find(plugins, plugin => plugin.id === this.props.plugin.id);
|
|
795
|
-
|
|
796
675
|
if (!found) return;
|
|
797
676
|
let css = (await popupCSS).default.default.toString();
|
|
798
|
-
|
|
799
677
|
var outcss = _index.default.replaceCssVariablePlugin(css, this.props.plugin.popup);
|
|
800
|
-
|
|
801
678
|
let extra_css = _index.default.get(this.props.plugin, `popup.pages.0.extra_css`, []);
|
|
802
|
-
|
|
803
679
|
let extra_css_string = _index.default.map(extra_css, css => `#sbz92 ${css.selector} { ${this.js2css(css.style)}}`).join('\n');
|
|
804
|
-
|
|
805
680
|
outcss += extra_css_string;
|
|
806
|
-
|
|
807
681
|
_index.default.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss);
|
|
808
682
|
}
|
|
809
|
-
|
|
810
683
|
componentWillUnmount() {
|
|
811
684
|
_index.default.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
812
685
|
}
|
|
813
|
-
|
|
814
686
|
async componentDidMount() {
|
|
815
687
|
this.$cssStyleDiv = document.getElementById('subiz-style-for-' + this.props.plugin.id);
|
|
816
|
-
|
|
817
688
|
if (!this.$cssStyleDiv) {
|
|
818
689
|
this.$cssStyleDiv = document.createElement('style');
|
|
819
690
|
document.head.appendChild(this.$cssStyleDiv);
|
|
820
691
|
this.$cssStyleDiv.type = 'text/css';
|
|
821
692
|
this.$cssStyleDiv.id = 'subiz-style-for-' + this.props.plugin.id;
|
|
822
693
|
}
|
|
823
|
-
|
|
824
694
|
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
825
695
|
await this.refreshCSS();
|
|
826
696
|
setTimeout(() => {
|
|
@@ -830,7 +700,6 @@ class Popup extends _common.Com {
|
|
|
830
700
|
this.setClose(false);
|
|
831
701
|
}, 50);
|
|
832
702
|
}
|
|
833
|
-
|
|
834
703
|
calculateContainerCss(popup, page) {
|
|
835
704
|
let pos = popup.position || 'center';
|
|
836
705
|
let pagestyle = Object.assign({
|
|
@@ -840,11 +709,9 @@ class Popup extends _common.Com {
|
|
|
840
709
|
max_height: '85%'
|
|
841
710
|
});
|
|
842
711
|
let containercss = {};
|
|
843
|
-
|
|
844
712
|
_index.default.map(['left', 'top', 'right', 'bottom', 'box_shadow', 'transform'], prop => {
|
|
845
713
|
containercss[prop] = pagestyle[prop];
|
|
846
714
|
});
|
|
847
|
-
|
|
848
715
|
containercss.position = 'absolute';
|
|
849
716
|
|
|
850
717
|
if (pos === 'center' || !pos) {
|
|
@@ -854,7 +721,6 @@ class Popup extends _common.Com {
|
|
|
854
721
|
delete containercss.right;
|
|
855
722
|
delete containercss.bottom;
|
|
856
723
|
}
|
|
857
|
-
|
|
858
724
|
if (pos === 'fullscreen') {
|
|
859
725
|
containercss.top = 0;
|
|
860
726
|
containercss.left = 0;
|
|
@@ -867,7 +733,6 @@ class Popup extends _common.Com {
|
|
|
867
733
|
delete containercss.height;
|
|
868
734
|
delete containercss.transform;
|
|
869
735
|
}
|
|
870
|
-
|
|
871
736
|
if (pos === 'top-left') {
|
|
872
737
|
containercss.top = containercss.top || '0px';
|
|
873
738
|
containercss.left = containercss.left || '0px';
|
|
@@ -875,7 +740,6 @@ class Popup extends _common.Com {
|
|
|
875
740
|
delete containercss.right;
|
|
876
741
|
delete containercss.bottom;
|
|
877
742
|
}
|
|
878
|
-
|
|
879
743
|
if (pos === 'top-right') {
|
|
880
744
|
containercss.top = containercss.top || '0px';
|
|
881
745
|
containercss.right = containercss.right || '0px';
|
|
@@ -883,7 +747,6 @@ class Popup extends _common.Com {
|
|
|
883
747
|
delete containercss.left;
|
|
884
748
|
delete containercss.bottom;
|
|
885
749
|
}
|
|
886
|
-
|
|
887
750
|
if (pos === 'top-center') {
|
|
888
751
|
containercss.transform = 'translateX(-50%)';
|
|
889
752
|
containercss.left = '50%';
|
|
@@ -891,7 +754,6 @@ class Popup extends _common.Com {
|
|
|
891
754
|
delete containercss.right;
|
|
892
755
|
delete containercss.bottom;
|
|
893
756
|
}
|
|
894
|
-
|
|
895
757
|
if (pos === 'middle-left') {
|
|
896
758
|
containercss.top = '50%';
|
|
897
759
|
containercss.transform = 'translateY(-50%)';
|
|
@@ -899,7 +761,6 @@ class Popup extends _common.Com {
|
|
|
899
761
|
delete containercss.right;
|
|
900
762
|
delete containercss.bottom;
|
|
901
763
|
}
|
|
902
|
-
|
|
903
764
|
if (pos === 'middle-right') {
|
|
904
765
|
containercss.top = '50%';
|
|
905
766
|
containercss.transform = 'translateY(-50%)';
|
|
@@ -907,7 +768,6 @@ class Popup extends _common.Com {
|
|
|
907
768
|
delete containercss.left;
|
|
908
769
|
delete containercss.bottom;
|
|
909
770
|
}
|
|
910
|
-
|
|
911
771
|
if (pos === 'bottom-left') {
|
|
912
772
|
containercss.bottom = containercss.bottom || '0px';
|
|
913
773
|
containercss.left = containercss.left || '0px';
|
|
@@ -915,7 +775,6 @@ class Popup extends _common.Com {
|
|
|
915
775
|
delete containercss.top;
|
|
916
776
|
delete containercss.right;
|
|
917
777
|
}
|
|
918
|
-
|
|
919
778
|
if (pos === 'bottom-right') {
|
|
920
779
|
containercss.bottom = containercss.bottom || '0px';
|
|
921
780
|
containercss.right = containercss.right || '0px';
|
|
@@ -923,7 +782,6 @@ class Popup extends _common.Com {
|
|
|
923
782
|
delete containercss.top;
|
|
924
783
|
delete containercss.left;
|
|
925
784
|
}
|
|
926
|
-
|
|
927
785
|
if (pos === 'bottom-center') {
|
|
928
786
|
containercss.bottom = containercss.bottom || '0px';
|
|
929
787
|
containercss.transform = 'translateX(-50%)';
|
|
@@ -931,7 +789,6 @@ class Popup extends _common.Com {
|
|
|
931
789
|
delete containercss.top;
|
|
932
790
|
delete containercss.right;
|
|
933
791
|
}
|
|
934
|
-
|
|
935
792
|
containercss.width = pagestyle.width;
|
|
936
793
|
containercss.height = pagestyle.height;
|
|
937
794
|
containercss.max_width = pagestyle.max_width;
|
|
@@ -940,59 +797,46 @@ class Popup extends _common.Com {
|
|
|
940
797
|
containercss.border_radius = pagestyle.border_radius;
|
|
941
798
|
containercss.overflow = pagestyle.overflow;
|
|
942
799
|
containercss.box_shadow = pagestyle.box_shadow;
|
|
943
|
-
|
|
944
800
|
if (!popup.type || popup.type === 'modal') {
|
|
945
801
|
containercss.max_width = '80%';
|
|
946
802
|
containercss.max_height = '95%';
|
|
947
803
|
}
|
|
948
|
-
|
|
949
804
|
if (pos === 'fullscreen') {
|
|
950
805
|
containercss.width = '100%';
|
|
951
806
|
containercss.height = '100%';
|
|
952
807
|
containercss.max_width = '100%';
|
|
953
808
|
containercss.max_height = '100%';
|
|
954
809
|
}
|
|
955
|
-
|
|
956
810
|
if (popup.type === 'bar') {
|
|
957
811
|
containercss.width = pagestyle.width || '100%';
|
|
958
812
|
containercss.max_width = '100%';
|
|
959
813
|
}
|
|
960
|
-
|
|
961
814
|
return containercss;
|
|
962
815
|
}
|
|
963
|
-
|
|
964
816
|
render() {
|
|
965
817
|
if (!this.props.t) return null;
|
|
966
818
|
if (!this.state.cssready) return null;
|
|
967
819
|
if (!this.state.imageReady) return null;
|
|
968
820
|
if (!this.state.fontReady) return null;
|
|
969
821
|
if (this.state.close) return null;
|
|
970
|
-
|
|
971
822
|
let popup = _index.default.get(this.props.plugin, 'popup', {});
|
|
972
|
-
|
|
973
823
|
let page = _index.default.get(popup, `pages.${this.getPageIndex()}`);
|
|
974
|
-
|
|
975
824
|
if (!page) return null;
|
|
976
825
|
let pagestyle = Object.assign({}, this.props.mobile && page.mobile_style || page.style);
|
|
977
826
|
let containercss = this.calculateContainerCss(popup, page);
|
|
978
827
|
let animation = '';
|
|
979
|
-
|
|
980
828
|
let pos = _index.default.get(this.props.plugin, 'popup.position', 'center');
|
|
981
|
-
|
|
982
829
|
if (pos === 'center' || !pos) {
|
|
983
830
|
animation = 'zoomInCenter';
|
|
984
831
|
if (this.state.closeAnimation) animation = 'zoomOutCenter';
|
|
985
832
|
}
|
|
986
|
-
|
|
987
833
|
if (pos === 'bottom-left' || pos === 'bottom-right') animation = 'fadeInUpBig';
|
|
988
834
|
if (pos === 'top-left' || pos === 'top-right') animation = 'fadeInDown';
|
|
989
835
|
if (pos === 'top-center') animation = 'fadeInDownCenter';
|
|
990
836
|
if (pos === 'middle-left') animation = 'fadeInLeftBig';
|
|
991
837
|
if (pos === 'middle-right') animation = 'fadeInRightBig';
|
|
992
838
|
if (pos === 'bottom-center') animation = 'fadeInUpCenter';
|
|
993
|
-
|
|
994
839
|
let layout = _index.default.get(page, 'layout');
|
|
995
|
-
|
|
996
840
|
if (this.props.mobile) layout = _index.default.get(page, 'mobile_layout');
|
|
997
841
|
let formcss = {
|
|
998
842
|
display: pagestyle.display,
|
|
@@ -1017,22 +861,18 @@ class Popup extends _common.Com {
|
|
|
1017
861
|
padding_right: pagestyle.margin_right,
|
|
1018
862
|
padding_bottom: pagestyle.margin_bottom
|
|
1019
863
|
};
|
|
1020
|
-
|
|
1021
864
|
if (this.props.highlight === 'padding') {
|
|
1022
865
|
bodycss.background = '#bad14a87';
|
|
1023
866
|
formcss.background = '#ff3d006e';
|
|
1024
867
|
}
|
|
1025
|
-
|
|
1026
868
|
let overlaystyle = 'position: fixed !important;';
|
|
1027
869
|
if (this.props.plugin._preview) overlaystyle = 'position: absolute !important;';
|
|
1028
870
|
if (popup.overlay) overlaystyle += ' background: #000c !important;';
|
|
1029
|
-
|
|
1030
871
|
let $imgs = _index.default.map(page.components, (com, i) => {
|
|
1031
872
|
if (com.type === 'image') return this.renderImageComponent(com, i);
|
|
1032
873
|
});
|
|
1033
874
|
|
|
1034
875
|
let formComponents = _index.default.filter(page.components, com => com.type !== 'image');
|
|
1035
|
-
|
|
1036
876
|
if (!formComponents.length) {
|
|
1037
877
|
formcss.background = 'transparent';
|
|
1038
878
|
formcss.padding_top = '0';
|
|
@@ -1040,7 +880,6 @@ class Popup extends _common.Com {
|
|
|
1040
880
|
formcss.padding_left = '0';
|
|
1041
881
|
formcss.padding_right = '0';
|
|
1042
882
|
}
|
|
1043
|
-
|
|
1044
883
|
return (0, _preact.h)("div", {
|
|
1045
884
|
class: "overlay",
|
|
1046
885
|
style: overlaystyle
|
|
@@ -1056,7 +895,5 @@ class Popup extends _common.Com {
|
|
|
1056
895
|
form: true
|
|
1057
896
|
}, this.renderComponents(page)))));
|
|
1058
897
|
}
|
|
1059
|
-
|
|
1060
898
|
}
|
|
1061
|
-
|
|
1062
899
|
exports.default = Popup;
|