Move js
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
9645462348
commit
27e545f7b7
29 changed files with 4 additions and 4 deletions
30
src/plugins/plugin.js
Normal file
30
src/plugins/plugin.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* jshint esversion: 6 */
|
||||
// we need our modal component
|
||||
import ModalDialog from './modalDialog.vue'
|
||||
|
||||
const Modal = {
|
||||
// every plugin for Vue.js needs install method
|
||||
// this method will run after Vue.use(<your-plugin-here>) is executed
|
||||
install(Vue, options) {
|
||||
// We must create new Eventbus
|
||||
// which is just another Vue instance that will be listening for and emiting events from our main instance
|
||||
// this EventBus will be available as Modal.EventBus
|
||||
this.EventBus = new Vue()
|
||||
|
||||
// making our modal component global
|
||||
Vue.component('modal-dialog', ModalDialog)
|
||||
|
||||
// exposing global $modal object with method show()
|
||||
// method show() takes object params as argument
|
||||
// inside this object we can have modal title, text, styles... and also our callback confirm function
|
||||
Vue.prototype.$modal = {
|
||||
show(params) {
|
||||
// if we use this.$modal.show(params) inside our original Vue instance
|
||||
// we will emit 'show' event with parameters 'params'
|
||||
Modal.EventBus.$emit('show', params)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Modal
|
||||
Loading…
Add table
Add a link
Reference in a new issue