All files / src index.js

0% Statements 0/37
0% Branches 0/16
0% Functions 0/2
0% Lines 0/25
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                                                                                                 
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'
 
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('v-popover', 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