mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Added comments
This commit is contained in:
15
src/index.js
15
src/index.js
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user