mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Added "installed" flag and removed Object.defineProperty
This commit is contained in:
1
dist/client.index.js
vendored
1
dist/client.index.js
vendored
File diff suppressed because one or more lines are too long
15
dist/index.js
vendored
15
dist/index.js
vendored
@@ -88,10 +88,13 @@ var Plugin = {
|
|||||||
install: function install(Vue) {
|
install: function install(Vue) {
|
||||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||||
|
|
||||||
if (!this.hasOwnProperty("event")) {
|
if (this.installed) {
|
||||||
this.event = new Vue();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.installed = true;
|
||||||
|
this.event = new Vue();
|
||||||
|
|
||||||
var $modal = {
|
var $modal = {
|
||||||
show: function show(name, params) {
|
show: function show(name, params) {
|
||||||
Plugin.event.$emit('toggle', name, true, params);
|
Plugin.event.$emit('toggle', name, true, params);
|
||||||
@@ -104,14 +107,8 @@ var Plugin = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(Vue.prototype, '$modal', {
|
Vue.prototype.$modal = $modal;
|
||||||
get: function get() {
|
|
||||||
return $modal;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Vue.component('modal', _Modal2.default);
|
Vue.component('modal', _Modal2.default);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
15
dist/ssr.index.js
vendored
15
dist/ssr.index.js
vendored
@@ -88,10 +88,13 @@ var Plugin = {
|
|||||||
install: function install(Vue) {
|
install: function install(Vue) {
|
||||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||||
|
|
||||||
if (!this.hasOwnProperty("event")) {
|
if (this.installed) {
|
||||||
this.event = new Vue();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.installed = true;
|
||||||
|
this.event = new Vue();
|
||||||
|
|
||||||
var $modal = {
|
var $modal = {
|
||||||
show: function show(name, params) {
|
show: function show(name, params) {
|
||||||
Plugin.event.$emit('toggle', name, true, params);
|
Plugin.event.$emit('toggle', name, true, params);
|
||||||
@@ -104,14 +107,8 @@ var Plugin = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(Vue.prototype, '$modal', {
|
Vue.prototype.$modal = $modal;
|
||||||
get: function get() {
|
|
||||||
return $modal;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Vue.component('modal', _Modal2.default);
|
Vue.component('modal', _Modal2.default);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
13
src/index.js
13
src/index.js
@@ -2,10 +2,13 @@ import Modal from './Modal.vue'
|
|||||||
|
|
||||||
const Plugin = {
|
const Plugin = {
|
||||||
install (Vue, options = {}) {
|
install (Vue, options = {}) {
|
||||||
if (!this.hasOwnProperty("event")) {
|
if (this.installed) {
|
||||||
this.event = new Vue()
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.installed = true
|
||||||
|
this.event = new Vue()
|
||||||
|
|
||||||
const $modal = {
|
const $modal = {
|
||||||
show (name, params) {
|
show (name, params) {
|
||||||
Plugin.event.$emit('toggle', name, true, params)
|
Plugin.event.$emit('toggle', name, true, params)
|
||||||
@@ -20,12 +23,8 @@ const Plugin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(Vue.prototype, '$modal', {
|
Vue.prototype.$modal = $modal
|
||||||
get: () => $modal
|
|
||||||
})
|
|
||||||
|
|
||||||
Vue.component('modal', Modal)
|
Vue.component('modal', Modal)
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user