@subiz/widget-v4 4.1.44 → 4.1.46
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/less/message.less +6 -0
- package/compiled_src/call/css.js +2 -1
- package/compiled_src/chatbox/ImageAttachments.js +89 -13
- package/compiled_src/chatbox/css.js +2 -1
- package/compiled_src/common.js +2 -1
- package/compiled_src/contact/contact.js +3 -2
- package/compiled_src/contact/css.js +2 -1
- package/compiled_src/lib.js +2 -1
- package/compiled_src/notif/css.js +2 -1
- package/compiled_src/popup/css.js +2 -1
- package/compiled_src/popup/popup.js +5 -7
- package/compiled_src/popup/tick.core.commonjs.js +2 -1
- package/compiled_src/store/api.js +1 -1
- package/compiled_src/store/store.js +18 -2
- package/compiled_src/util/campaign.js +6 -2
- package/compiled_src/util/common.js +26 -12
- package/compiled_src/util/index.js +2 -1
- package/compiled_src/util/order.js +4 -2
- package/compiled_src/util/pubsub.js +6 -3
- package/dist/{841.js → 132.js} +612 -528
- package/dist/18a02a9c54e.132.js +1 -0
- package/dist/18a02a9c54e.213.js +1 -0
- package/dist/18a02a9c54e.335.js +1 -0
- package/dist/{18b1ceaf2e0.362.js → 18a02a9c54e.362.js} +1 -1
- package/dist/18a02a9c54e.441.js +1 -0
- package/dist/18a02a9c54e.605.js +1 -0
- package/dist/{18b1ceaf2e0.782.js → 18a02a9c54e.782.js} +1 -1
- package/dist/18a02a9c54e.app.js +1 -0
- package/dist/{18b1ceaf2e0.index.html → 18a02a9c54e.index.html} +4 -4
- package/dist/{18b1ceaf2e0.library.html → 18a02a9c54e.library.html} +4 -4
- package/dist/18a02a9c54e.library.js +1 -0
- package/dist/{18b1ceaf2e0.preview.html → 18a02a9c54e.preview.html} +1 -1
- package/dist/18a02a9c54e.preview.js +1 -0
- package/dist/18a02a9c54e.screenshoot.js +1 -0
- package/dist/18a02a9c54e.webview.js +1 -0
- package/dist/213.js +100 -118
- package/dist/335.js +25 -25
- package/dist/362.js +1 -1
- package/dist/441.js +2855 -0
- package/dist/605.js +50 -50
- package/dist/782.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +426 -430
- package/package.json +1 -1
- package/src/chatbox/ImageAttachments.js +93 -15
- package/src/popup/popup.js +8 -7
- package/src/store/api.js +1 -1
- package/src/store/store.js +15 -2
- package/dist/18b1ceaf2e0.213.js +0 -1
- package/dist/18b1ceaf2e0.335.js +0 -1
- package/dist/18b1ceaf2e0.605.js +0 -1
- package/dist/18b1ceaf2e0.841.js +0 -1
- package/dist/18b1ceaf2e0.app.js +0 -1
- package/dist/18b1ceaf2e0.library.js +0 -1
- package/dist/18b1ceaf2e0.preview.js +0 -1
- package/dist/18b1ceaf2e0.screenshoot.js +0 -1
- package/dist/18b1ceaf2e0.webview.js +0 -1
- /package/dist/{18b1ceaf2e0.178.js → 18a02a9c54e.178.js} +0 -0
- /package/dist/{18b1ceaf2e0.678.js → 18a02a9c54e.678.js} +0 -0
package/assets/less/message.less
CHANGED
package/compiled_src/call/css.js
CHANGED
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default =
|
|
7
|
+
var _default = require('css-loader!less-loader!../../assets/less/notif.less');
|
|
8
|
+
exports.default = _default;
|
|
@@ -8,9 +8,93 @@ var _index = _interopRequireDefault(require("../util/index.js"));
|
|
|
8
8
|
var _common = require("../common.js");
|
|
9
9
|
var _preact = require("preact");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
14
|
class ImageAttachment extends _common.Com {
|
|
12
15
|
constructor(props) {
|
|
13
16
|
super(props);
|
|
17
|
+
_defineProperty(this, "containerRef", (0, _preact.createRef)());
|
|
18
|
+
this.setState({
|
|
19
|
+
ready: false
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
this.setImageFrameDimension();
|
|
24
|
+
}
|
|
25
|
+
setImageFrameDimension() {
|
|
26
|
+
const MAX_HEIGHT = 240;
|
|
27
|
+
const DEFAULT_MAX_WIDTH = 267;
|
|
28
|
+
let $container = this.containerRef.current;
|
|
29
|
+
this.frameWidth = $container ? $container.offsetWidth : DEFAULT_MAX_WIDTH;
|
|
30
|
+
this.frameHeight = MAX_HEIGHT;
|
|
31
|
+
this.setState({
|
|
32
|
+
ready: true
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
calculateImageDimension(image) {
|
|
36
|
+
if (!image.width || !image.height) return {
|
|
37
|
+
width: this.frameWidth,
|
|
38
|
+
height: this.frameHeight
|
|
39
|
+
};
|
|
40
|
+
let ratio = image.width / image.height - this.frameWidth / this.frameHeight;
|
|
41
|
+
if (ratio >= 0) {
|
|
42
|
+
let width = this.frameWidth;
|
|
43
|
+
let height = image.height * this.frameWidth / image.width;
|
|
44
|
+
height = Math.round(height);
|
|
45
|
+
return {
|
|
46
|
+
width,
|
|
47
|
+
height
|
|
48
|
+
};
|
|
49
|
+
} else {
|
|
50
|
+
let height = this.frameHeight;
|
|
51
|
+
let width = image.width * this.frameHeight / image.height;
|
|
52
|
+
width = Math.round(width);
|
|
53
|
+
return {
|
|
54
|
+
width,
|
|
55
|
+
height
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
renderImage(image, index) {
|
|
60
|
+
if (!this.state.ready) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let byType = _index.default.get(this.props.ev, 'by.type');
|
|
64
|
+
if (!image.width || !image.height) {
|
|
65
|
+
return (0, _preact.h)("div", {
|
|
66
|
+
class: `image-attachment image-attachment--${byType}`
|
|
67
|
+
}, (0, _preact.h)("a", {
|
|
68
|
+
href: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
69
|
+
target: "_blank"
|
|
70
|
+
}, (0, _preact.h)("img", {
|
|
71
|
+
alt: true,
|
|
72
|
+
class: "image-attachment__img",
|
|
73
|
+
src: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
74
|
+
onload: e => this.props.onLoad && this.props.onLoad()
|
|
75
|
+
})));
|
|
76
|
+
}
|
|
77
|
+
let {
|
|
78
|
+
width,
|
|
79
|
+
height
|
|
80
|
+
} = this.calculateImageDimension(image);
|
|
81
|
+
return (0, _preact.h)("div", {
|
|
82
|
+
class: `image-attachment image-attachment--${byType}`
|
|
83
|
+
}, (0, _preact.h)("a", {
|
|
84
|
+
href: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
85
|
+
target: "_blank"
|
|
86
|
+
}, (0, _preact.h)("img", {
|
|
87
|
+
alt: true,
|
|
88
|
+
ref: el => {
|
|
89
|
+
if (el) {
|
|
90
|
+
el.style.setProperty('width', `${width}px`, 'important');
|
|
91
|
+
el.style.setProperty('height', `${height}px`, 'important');
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
class: "image-attachment__img",
|
|
95
|
+
src: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
96
|
+
onload: e => this.props.onLoad && this.props.onLoad()
|
|
97
|
+
})));
|
|
14
98
|
}
|
|
15
99
|
render() {
|
|
16
100
|
var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
|
|
@@ -27,24 +111,16 @@ class ImageAttachment extends _common.Com {
|
|
|
27
111
|
images.push(att);
|
|
28
112
|
});
|
|
29
113
|
if (images.length === 0) return null;
|
|
30
|
-
|
|
31
|
-
class: `image-attachment image-attachment--${byType}`
|
|
32
|
-
}, (0, _preact.h)("a", {
|
|
33
|
-
href: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
34
|
-
target: "_blank"
|
|
35
|
-
}, (0, _preact.h)("img", {
|
|
36
|
-
alt: true,
|
|
37
|
-
class: "image-attachment__img",
|
|
38
|
-
src: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
39
|
-
onload: e => this.props.onLoad && this.props.onLoad()
|
|
40
|
-
}))));
|
|
114
|
+
let $images = _index.default.map(images, (image, index) => this.renderImage(image, index));
|
|
41
115
|
if (byType === 'agent') {
|
|
42
116
|
return (0, _preact.h)("div", {
|
|
43
|
-
class: "message-agent"
|
|
117
|
+
class: "message-agent",
|
|
118
|
+
ref: this.containerRef
|
|
44
119
|
}, $images);
|
|
45
120
|
} else {
|
|
46
121
|
return (0, _preact.h)("div", {
|
|
47
|
-
class: "message-user"
|
|
122
|
+
class: "message-user message-user-images-container",
|
|
123
|
+
ref: this.containerRef
|
|
48
124
|
}, $images);
|
|
49
125
|
}
|
|
50
126
|
}
|
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default =
|
|
7
|
+
var _default = require('css-loader!less-loader!../../assets/less/chatbox.less');
|
|
8
|
+
exports.default = _default;
|
package/compiled_src/common.js
CHANGED
|
@@ -65,7 +65,8 @@ const getLocale = (plugin, loc) => {
|
|
|
65
65
|
return plugin.locale || 'en-US';
|
|
66
66
|
};
|
|
67
67
|
exports.getLocale = getLocale;
|
|
68
|
-
let langMessages =
|
|
68
|
+
let langMessages = {};
|
|
69
|
+
exports.langMessages = langMessages;
|
|
69
70
|
let downloadLock = false;
|
|
70
71
|
function downloadLanguage(store, locale, force) {
|
|
71
72
|
if (downloadLock) return new Promise(resolve => _index.default.setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100));
|
|
@@ -356,9 +356,10 @@ function replaceCssVariable(css, setting) {
|
|
|
356
356
|
}
|
|
357
357
|
return ret.join('');
|
|
358
358
|
}
|
|
359
|
-
const DEFVAL =
|
|
359
|
+
const DEFVAL = {
|
|
360
360
|
font_size: '16px',
|
|
361
361
|
font_family: 'roboto',
|
|
362
362
|
text_color: '#333',
|
|
363
363
|
primary_color: '#333'
|
|
364
|
-
};
|
|
364
|
+
};
|
|
365
|
+
exports.DEFVAL = DEFVAL;
|
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default =
|
|
7
|
+
var _default = require('css-loader!less-loader!../../assets/less/contact.less');
|
|
8
|
+
exports.default = _default;
|
package/compiled_src/lib.js
CHANGED
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default =
|
|
7
|
+
var _default = require('css-loader!less-loader!../../assets/less/notif.less');
|
|
8
|
+
exports.default = _default;
|
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default =
|
|
7
|
+
var _default = require('css-loader!less-loader!../../assets/less/popup.less');
|
|
8
|
+
exports.default = _default;
|
|
@@ -211,7 +211,7 @@ class Popup extends _common.Com {
|
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
onButtonClick(e, buttontype) {
|
|
214
|
+
async onButtonClick(e, buttontype) {
|
|
215
215
|
e.stopPropagation();
|
|
216
216
|
let popup = _index.default.get(this.props.plugin, 'popup', {});
|
|
217
217
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
@@ -235,14 +235,13 @@ class Popup extends _common.Com {
|
|
|
235
235
|
if (a.action === 'submit' || a.action === 'conversion') hasConversion = true;
|
|
236
236
|
}
|
|
237
237
|
if (hasConversion) {
|
|
238
|
+
if (this.isSubmitting) return;
|
|
238
239
|
var formData = this._formRef.current ? new FormData(this._formRef.current) : new FormData();
|
|
239
240
|
var summitFields = [];
|
|
240
241
|
let user = _index.default.cloneDeep(this.props.store.matchUser());
|
|
241
242
|
let is_lead = false;
|
|
242
243
|
let modifiedPairs = {};
|
|
243
|
-
console.log('333333333333');
|
|
244
244
|
for (var pair of formData.entries()) {
|
|
245
|
-
console.log('44444444444444444');
|
|
246
245
|
if (modifiedPairs[pair[0]]) {
|
|
247
246
|
let currentValue = _index.default.get(modifiedPairs, `${pair[0]}.1`, '');
|
|
248
247
|
currentValue += `,${pair[1]}`;
|
|
@@ -251,9 +250,7 @@ class Popup extends _common.Com {
|
|
|
251
250
|
modifiedPairs[pair[0]] = [pair[0], pair[1]];
|
|
252
251
|
}
|
|
253
252
|
}
|
|
254
|
-
console.log('1111111111111', Object.entries(modifiedPairs));
|
|
255
253
|
for (const [_, pair] of Object.entries(modifiedPairs)) {
|
|
256
|
-
console.log('2222222222222', pair);
|
|
257
254
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
258
255
|
let form = _index.default.find(page.components, com => com.type === 'form');
|
|
259
256
|
let fields = _index.default.get(form, 'form.fields', []);
|
|
@@ -277,8 +274,9 @@ class Popup extends _common.Com {
|
|
|
277
274
|
key: 'lead_source',
|
|
278
275
|
text: 'plugin.' + this.props.plugin.id
|
|
279
276
|
});
|
|
280
|
-
this.
|
|
281
|
-
this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
|
|
277
|
+
this.isSubmitting = true;
|
|
278
|
+
await Promise.all([this.props.store.setUser(user), this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken)]);
|
|
279
|
+
this.isSubmitting = false;
|
|
282
280
|
}
|
|
283
281
|
for (let a of actions) {
|
|
284
282
|
if (a.action === 'open_widget') this.props.showWidget('list');
|
|
@@ -760,7 +760,14 @@ class Store {
|
|
|
760
760
|
if (!att._file) return;
|
|
761
761
|
files.push(att);
|
|
762
762
|
if (ImageTypes.includes(att._file.type)) {
|
|
763
|
-
|
|
763
|
+
let {
|
|
764
|
+
width,
|
|
765
|
+
height,
|
|
766
|
+
url
|
|
767
|
+
} = await loadImage(att._file);
|
|
768
|
+
att.url = url;
|
|
769
|
+
att.width = width;
|
|
770
|
+
att.height = height;
|
|
764
771
|
}
|
|
765
772
|
});
|
|
766
773
|
}
|
|
@@ -973,7 +980,16 @@ function loadImage(file) {
|
|
|
973
980
|
return new Promise(rs => {
|
|
974
981
|
var reader = new window.FileReader();
|
|
975
982
|
reader.onload = e => {
|
|
976
|
-
|
|
983
|
+
let src = e.target.result;
|
|
984
|
+
let img = new Image();
|
|
985
|
+
img.onload = () => {
|
|
986
|
+
rs({
|
|
987
|
+
url: src,
|
|
988
|
+
width: img.width,
|
|
989
|
+
height: img.height
|
|
990
|
+
});
|
|
991
|
+
};
|
|
992
|
+
img.src = src;
|
|
977
993
|
};
|
|
978
994
|
reader.readAsDataURL(file);
|
|
979
995
|
});
|
|
@@ -37,7 +37,9 @@ function trackAreaClicked(selector, cb) {
|
|
|
37
37
|
on('click', selector, cb);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function trackInactivity(
|
|
40
|
+
function trackInactivity() {
|
|
41
|
+
let seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
42
|
+
let cb = arguments.length > 1 ? arguments[1] : undefined;
|
|
41
43
|
let events = ['scroll', 'keyup', 'keydown', 'mousemove', 'mousewheel', 'mouseenter', 'mouseover', 'mousedown', 'touchstart', 'touchmove', 'touchenter'];
|
|
42
44
|
let inactiveSeconds = 0;
|
|
43
45
|
let resetTime = () => {
|
|
@@ -60,7 +62,9 @@ let timeOnPage = 0;
|
|
|
60
62
|
common.setInterval(() => {
|
|
61
63
|
timeOnPage += 5;
|
|
62
64
|
}, 5000);
|
|
63
|
-
function trackTimeOnPage(
|
|
65
|
+
function trackTimeOnPage() {
|
|
66
|
+
let seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
67
|
+
let cb = arguments.length > 1 ? arguments[1] : undefined;
|
|
64
68
|
if (seconds < 1) {
|
|
65
69
|
return common.setTimeout(function () {
|
|
66
70
|
cb(seconds);
|
|
@@ -75,15 +75,23 @@ function parseJSON(str) {
|
|
|
75
75
|
var f = document.createElement('iframe');
|
|
76
76
|
f.style.display = 'none';
|
|
77
77
|
document.documentElement.appendChild(f);
|
|
78
|
-
var stringify =
|
|
78
|
+
var stringify = f.contentWindow.JSON.stringify;
|
|
79
|
+
exports.stringify = stringify;
|
|
79
80
|
var parse = f.contentWindow.JSON.parse;
|
|
80
|
-
var Date =
|
|
81
|
-
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
var
|
|
81
|
+
var Date = f.contentWindow.Date;
|
|
82
|
+
exports.Date = Date;
|
|
83
|
+
var requestAnimationFrame = f.contentWindow.requestAnimationFrame;
|
|
84
|
+
exports.requestAnimationFrame = requestAnimationFrame;
|
|
85
|
+
var setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow);
|
|
86
|
+
exports.setTimeout = setTimeout;
|
|
87
|
+
var setInterval = f.contentWindow.setInterval.bind(f.contentWindow);
|
|
88
|
+
exports.setInterval = setInterval;
|
|
89
|
+
var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow);
|
|
90
|
+
exports.clearInterval = clearInterval;
|
|
91
|
+
var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow);
|
|
92
|
+
exports.clearTimeout = clearTimeout;
|
|
93
|
+
var XMLHttpRequest = f.contentWindow.XMLHttpRequest;
|
|
94
|
+
exports.XMLHttpRequest = XMLHttpRequest;
|
|
87
95
|
function convoOfEv(ev) {
|
|
88
96
|
if (!ev) return '';
|
|
89
97
|
switch (ev.type) {
|
|
@@ -151,7 +159,10 @@ function getMsgField(ev, fieldName) {
|
|
|
151
159
|
function isObject(item) {
|
|
152
160
|
return item && typeof item === 'object' && !Array.isArray(item);
|
|
153
161
|
}
|
|
154
|
-
function merge(target
|
|
162
|
+
function merge(target) {
|
|
163
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
164
|
+
sources[_key - 1] = arguments[_key];
|
|
165
|
+
}
|
|
155
166
|
if (!sources.length) return target;
|
|
156
167
|
const source = sources.shift();
|
|
157
168
|
if (isObject(target) && isObject(source)) {
|
|
@@ -544,8 +555,9 @@ function setCss(id, $css, css) {
|
|
|
544
555
|
$css.appendChild(document.createTextNode(css));
|
|
545
556
|
}
|
|
546
557
|
}
|
|
547
|
-
const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL =
|
|
548
|
-
|
|
558
|
+
const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5';
|
|
559
|
+
exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL;
|
|
560
|
+
const DEFVAL = {
|
|
549
561
|
primary_color: '#0265FF',
|
|
550
562
|
secondary_color: '#555555',
|
|
551
563
|
background: 'linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)',
|
|
@@ -572,6 +584,7 @@ const DEFVAL = exports.DEFVAL = {
|
|
|
572
584
|
widget_position: 'fixed',
|
|
573
585
|
z_index: 2000000000
|
|
574
586
|
};
|
|
587
|
+
exports.DEFVAL = DEFVAL;
|
|
575
588
|
function js2css(js, onlyprops, variables) {
|
|
576
589
|
var newjs = {};
|
|
577
590
|
for (var prop in js) {
|
|
@@ -950,7 +963,8 @@ function getUrlParameter() {
|
|
|
950
963
|
}
|
|
951
964
|
var sleep = ms => new Promise(res => setTimeout(res, ms));
|
|
952
965
|
exports.sleep = sleep;
|
|
953
|
-
function formatCurrency(val
|
|
966
|
+
function formatCurrency(val) {
|
|
967
|
+
let currency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'VND';
|
|
954
968
|
let currencyObj = ALL_CURRENCIES.find(cur => cur.code === currency) || {
|
|
955
969
|
name: 'Dong',
|
|
956
970
|
code: 'VND',
|
|
@@ -14,7 +14,8 @@ op.map = common.map;
|
|
|
14
14
|
op.each = common.each;
|
|
15
15
|
op.size = common.size;
|
|
16
16
|
op.find = common.find;
|
|
17
|
-
function getProductPropName(product
|
|
17
|
+
function getProductPropName(product) {
|
|
18
|
+
let seperator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' - ';
|
|
18
19
|
let options = op.get(product, 'options', []);
|
|
19
20
|
let props = op.get(product, 'props', []);
|
|
20
21
|
let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
|
|
@@ -25,7 +26,8 @@ function getProductPropName(product, seperator = ' - ') {
|
|
|
25
26
|
});
|
|
26
27
|
return names.join(seperator);
|
|
27
28
|
}
|
|
28
|
-
function getOrderDisplayName(
|
|
29
|
+
function getOrderDisplayName() {
|
|
30
|
+
let order = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
29
31
|
return order.number || order.id || '';
|
|
30
32
|
}
|
|
31
33
|
function displayOrderShippingAddress(order, isShorten) {
|
|
@@ -14,9 +14,12 @@ class Pubsub {
|
|
|
14
14
|
}
|
|
15
15
|
publish(topic, payload, payload2, payload3) {
|
|
16
16
|
this.listeners[topic] = filter(this.listeners[topic], sub => sub.obj._isMounted);
|
|
17
|
-
map(this.listeners[topic],
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
map(this.listeners[topic], _ref => {
|
|
18
|
+
let {
|
|
19
|
+
cb
|
|
20
|
+
} = _ref;
|
|
21
|
+
return cb(payload, payload2, payload3);
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
on2(obj, topic, cb) {
|
|
22
25
|
if (!this.listeners[topic]) this.listeners[topic] = [];
|