-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
44 lines (39 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import log from './helpers-log'
import { getFbSdk, mountFbCustomerChat } from './helpers'
const VueFbCustomerChat = {
install: (Vue, options) => {
Vue.fbCustomerChat = {
setOptions(otherOptions) {
options = { ...options, ...otherOptions }
}
}
Object.defineProperties(Vue.prototype, {
$fbCustomerChat: {
get: () => {
return Vue.fbCustomerChat
}
}
})
Vue.mixin({
mounted() {
if (!this.$parent) {
getFbSdk(options).then(() => {
if (options.page_id) {
mountFbCustomerChat(options)
} else {
console.error(
'%cVueFbCustomerChat:: You have to specify `page_id`',
log.error
)
}
})
}
}
})
}
}
// register plugin if it is used via cdn or directly as a script tag
if (typeof window !== 'undefined' && window.Vue) {
window.VueFbCustomerChat = VueFbCustomerChat
}
export default VueFbCustomerChat