mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Cleaning in progress
This commit is contained in:
39
src/index.js
Normal file
39
src/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import Vue from 'vue';
|
||||
import Modal from './Modal';
|
||||
|
||||
const VueModal = {
|
||||
event: new Vue(),
|
||||
install(self, options = {}) {
|
||||
if (this.installed) {
|
||||
return console.log('Modal component is already installed.');
|
||||
}
|
||||
|
||||
this.installed = true;
|
||||
|
||||
const modal = {
|
||||
toggle(name, state, params) {
|
||||
const opts = typeof state === 'object' && typeof params === 'undefined'
|
||||
? state
|
||||
: params;
|
||||
VueModal.event.$emit('toggle', name, state);
|
||||
},
|
||||
show(name, params = {}) {
|
||||
VueModal.event.$emit('toggle', name, true);
|
||||
},
|
||||
hide(name, params = {}) {
|
||||
VueModal.event.$emit('toggle', name, false);
|
||||
},
|
||||
};
|
||||
|
||||
Object.defineProperty(Vue.prototype, '$modal', {
|
||||
get() {
|
||||
return modal;
|
||||
},
|
||||
});
|
||||
|
||||
Vue.component('modal', Modal);
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
export default VueModal;
|
||||
Reference in New Issue
Block a user