Added comments

This commit is contained in:
euvl
2017-08-14 14:32:26 +01:00
parent c1f4d6f2e6
commit de592d27f4
3 changed files with 65 additions and 12 deletions

View File

@@ -5,13 +5,18 @@ const defaultComponentName = 'modal'
const Plugin = {
install (Vue, options = {}) {
/**
* Makes sure that plugin can be insstalled only once
*/
if (this.installed) {
return
}
this.installed = true
this.event = new Vue()
/**
* Plugin API
*/
Vue.prototype.$modal = {
show (name, params) {
Plugin.event.$emit('toggle', name, true, params)
@@ -25,10 +30,14 @@ const Plugin = {
Plugin.event.$emit('toggle', name, undefined, params)
}
}
/**
* Sets custom component name (if provided)
*/
const componentName = options.componentName || defaultComponentName
Vue.component(componentName, Modal)
/**
* Registration of <Dialog/> component
*/
if (options.dialog) {
Vue.component('v-dialog', Dialog)
}