mirror of
				https://github.com/KevinMidboe/vue-js-modal.git
				synced 2025-10-29 18:00:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			598 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			598 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import Vue from 'vue';
 | 
						|
import Modal from './Modal.vue';
 | 
						|
 | 
						|
const VueModal = {
 | 
						|
  install(Vue, options = {}) {
 | 
						|
    if (!this.hasOwnProperty("event")) {
 | 
						|
      this.event = new Vue();
 | 
						|
    }
 | 
						|
 | 
						|
    const $modal = {
 | 
						|
      show(name, params) {
 | 
						|
        VueModal.event.$emit('toggle', name, true, params);
 | 
						|
      },
 | 
						|
      hide(name, params) {
 | 
						|
        VueModal.event.$emit('toggle', name, false, params);
 | 
						|
      }
 | 
						|
    };
 | 
						|
 | 
						|
    Object.defineProperty(Vue.prototype, '$modal', {
 | 
						|
      get: () => $modal
 | 
						|
    });
 | 
						|
 | 
						|
    Vue.component('modal', Modal);
 | 
						|
    return null;
 | 
						|
  },
 | 
						|
};
 | 
						|
 | 
						|
Vue.use(VueModal);
 | 
						|
 | 
						|
export default VueModal;
 |