-
Notifications
You must be signed in to change notification settings - Fork 337
/
Copy pathindex.js
51 lines (40 loc) · 1.15 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
45
46
47
48
49
50
51
import vtooltip, { defaultOptions, state } from './directives/v-tooltip'
import vclosepopover from './directives/v-close-popover'
import Popover from './components/Popover.vue'
import merge from 'lodash/merge'
import 'vue-resize/dist/vue-resize.css'
export { createTooltip, destroyTooltip } from './directives/v-tooltip'
export function install (Vue, options = {}) {
if (install.installed) return
install.installed = true
const finalOptions = {}
merge(finalOptions, defaultOptions, options)
plugin.options = finalOptions
vtooltip.options = finalOptions
Vue.directive('tooltip', vtooltip)
Vue.directive('close-popover', vclosepopover)
Vue.component('VPopover', Popover)
}
export const VTooltip = vtooltip
export const VClosePopover = vclosepopover
export const VPopover = Popover
const plugin = {
install,
get enabled () {
return state.enabled
},
set enabled (value) {
state.enabled = value
},
}
// Auto-install
let GlobalVue = null
if (typeof window !== 'undefined') {
GlobalVue = window.Vue
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue
}
if (GlobalVue) {
GlobalVue.use(plugin)
}
export default plugin