Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 022c42c

Browse files
author
Steffan
committed
v2.1.2
1 parent 65d91fa commit 022c42c

6 files changed

+161
-77
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ $ npm install vue-event-manager
1717
```
1818

1919
### CDN
20-
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-event-manager@2.1.1) or [unpkg](https://unpkg.com/vue-event-manager@2.1.1).
20+
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-event-manager@2.1.2) or [unpkg](https://unpkg.com/vue-event-manager@2.1.2).
2121
```html
22-
<script src="https://cdn.jsdelivr.net/npm/vue-event-manager@2.1.1"></script>
22+
<script src="https://cdn.jsdelivr.net/npm/vue-event-manager@2.1.2"></script>
2323
```
2424

2525
## Example

dist/vue-event-manager.common.js

+52-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v2.1.1
2+
* vue-event-manager v2.1.2
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -10,10 +10,26 @@
1010
* Utility functions.
1111
*/
1212

13+
var _config = {};
14+
1315
var assign = Object.assign || _assign;
1416

1517
var isArray = Array.isArray;
1618

19+
function Util (ref) {
20+
var config = ref.config;
21+
22+
_config = config;
23+
}
24+
25+
function log(message, color) {
26+
if ( color === void 0 ) color = '#41B883';
27+
28+
if (typeof console !== 'undefined' && _config.devtools) {
29+
console.log(("%c vue-event-manager %c " + message + " "), 'color: #fff; background: #35495E; padding: 1px; border-radius: 3px 0 0 3px;', ("color: #fff; background: " + color + "; padding: 1px; border-radius: 0 3px 3px 0;"));
30+
}
31+
}
32+
1733
function isObject(val) {
1834
return val !== null && typeof val === 'object';
1935
}
@@ -199,38 +215,46 @@ Event.prototype.isPropagationStopped = function isPropagationStopped () {
199215
};
200216

201217
/**
202-
* Install plugin.
218+
* Plugin class.
203219
*/
204220

205221
var Events = new EventManager();
206222

207-
Events.install = function (Vue, options) {
208-
if ( options === void 0 ) options = {};
209-
223+
var Plugin = {
210224

211-
if (this.installed) {
212-
return;
213-
}
225+
version: '2.1.2',
214226

215-
// add global instance/methods
216-
Vue.prototype.$events = Vue.events = assign(Events, options);
217-
Vue.prototype.$trigger = function (event, params, asynch) {
218-
if ( params === void 0 ) params = [];
219-
if ( asynch === void 0 ) asynch = false;
227+
install: function install(Vue, options) {
228+
if ( options === void 0 ) options = {};
220229

221230

222-
if (!isObject(event)) {
223-
event = {name: event, origin: this};
231+
if (this.installed) {
232+
return;
224233
}
225234

226-
return Events.trigger(event, params, asynch);
227-
};
235+
Util(Vue); log(this.version);
236+
237+
// add global instance/methods
238+
Vue.prototype.$events = Vue.events = assign(Events, options);
239+
Vue.prototype.$trigger = function (event, params, asynch) {
240+
if ( params === void 0 ) params = [];
241+
if ( asynch === void 0 ) asynch = false;
242+
243+
244+
if (!isObject(event)) {
245+
event = {name: event, origin: this};
246+
}
247+
248+
return Events.trigger(event, params, asynch);
249+
};
228250

229-
// add merge strategy for "events"
230-
Vue.config.optionMergeStrategies.events = mergeEvents;
251+
// add merge strategy for "events"
252+
Vue.config.optionMergeStrategies.events = mergeEvents;
253+
254+
// add mixin to parse "events" from component options
255+
Vue.mixin({beforeCreate: initEvents});
256+
}
231257

232-
// add mixin to parse "events" from component options
233-
Vue.mixin({beforeCreate: initEvents});
234258
};
235259

236260
function mergeEvents(parentVal, childVal) {
@@ -282,7 +306,7 @@ function initEvents() {
282306
listener = listener.handler;
283307
}
284308

285-
_events.push(Events.on(event, bindListener(listener, this$1), priority));
309+
_events.push(this$1.$events.on(event, bindListener(listener, this$1), priority));
286310
});
287311
});
288312

@@ -301,8 +325,12 @@ function bindListener(fn, vm) {
301325
return fn.bind(vm);
302326
}
303327

328+
/**
329+
* Install plugin.
330+
*/
331+
304332
if (typeof window !== 'undefined' && window.Vue) {
305-
window.Vue.use(Events);
333+
window.Vue.use(Plugin);
306334
}
307335

308-
module.exports = Events;
336+
module.exports = Plugin;

dist/vue-event-manager.esm.js

+52-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v2.1.1
2+
* vue-event-manager v2.1.2
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -8,10 +8,26 @@
88
* Utility functions.
99
*/
1010

11+
var _config = {};
12+
1113
var assign = Object.assign || _assign;
1214

1315
var isArray = Array.isArray;
1416

17+
function Util (ref) {
18+
var config = ref.config;
19+
20+
_config = config;
21+
}
22+
23+
function log(message, color) {
24+
if ( color === void 0 ) color = '#41B883';
25+
26+
if (typeof console !== 'undefined' && _config.devtools) {
27+
console.log(("%c vue-event-manager %c " + message + " "), 'color: #fff; background: #35495E; padding: 1px; border-radius: 3px 0 0 3px;', ("color: #fff; background: " + color + "; padding: 1px; border-radius: 0 3px 3px 0;"));
28+
}
29+
}
30+
1531
function isObject(val) {
1632
return val !== null && typeof val === 'object';
1733
}
@@ -197,38 +213,46 @@ Event.prototype.isPropagationStopped = function isPropagationStopped () {
197213
};
198214

199215
/**
200-
* Install plugin.
216+
* Plugin class.
201217
*/
202218

203219
var Events = new EventManager();
204220

205-
Events.install = function (Vue, options) {
206-
if ( options === void 0 ) options = {};
207-
221+
var Plugin = {
208222

209-
if (this.installed) {
210-
return;
211-
}
223+
version: '2.1.2',
212224

213-
// add global instance/methods
214-
Vue.prototype.$events = Vue.events = assign(Events, options);
215-
Vue.prototype.$trigger = function (event, params, asynch) {
216-
if ( params === void 0 ) params = [];
217-
if ( asynch === void 0 ) asynch = false;
225+
install: function install(Vue, options) {
226+
if ( options === void 0 ) options = {};
218227

219228

220-
if (!isObject(event)) {
221-
event = {name: event, origin: this};
229+
if (this.installed) {
230+
return;
222231
}
223232

224-
return Events.trigger(event, params, asynch);
225-
};
233+
Util(Vue); log(this.version);
234+
235+
// add global instance/methods
236+
Vue.prototype.$events = Vue.events = assign(Events, options);
237+
Vue.prototype.$trigger = function (event, params, asynch) {
238+
if ( params === void 0 ) params = [];
239+
if ( asynch === void 0 ) asynch = false;
240+
241+
242+
if (!isObject(event)) {
243+
event = {name: event, origin: this};
244+
}
245+
246+
return Events.trigger(event, params, asynch);
247+
};
226248

227-
// add merge strategy for "events"
228-
Vue.config.optionMergeStrategies.events = mergeEvents;
249+
// add merge strategy for "events"
250+
Vue.config.optionMergeStrategies.events = mergeEvents;
251+
252+
// add mixin to parse "events" from component options
253+
Vue.mixin({beforeCreate: initEvents});
254+
}
229255

230-
// add mixin to parse "events" from component options
231-
Vue.mixin({beforeCreate: initEvents});
232256
};
233257

234258
function mergeEvents(parentVal, childVal) {
@@ -280,7 +304,7 @@ function initEvents() {
280304
listener = listener.handler;
281305
}
282306

283-
_events.push(Events.on(event, bindListener(listener, this$1), priority));
307+
_events.push(this$1.$events.on(event, bindListener(listener, this$1), priority));
284308
});
285309
});
286310

@@ -299,8 +323,12 @@ function bindListener(fn, vm) {
299323
return fn.bind(vm);
300324
}
301325

326+
/**
327+
* Install plugin.
328+
*/
329+
302330
if (typeof window !== 'undefined' && window.Vue) {
303-
window.Vue.use(Events);
331+
window.Vue.use(Plugin);
304332
}
305333

306-
export default Events;
334+
export default Plugin;

dist/vue-event-manager.js

+52-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v2.1.1
2+
* vue-event-manager v2.1.2
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -14,10 +14,26 @@
1414
* Utility functions.
1515
*/
1616

17+
var _config = {};
18+
1719
var assign = Object.assign || _assign;
1820

1921
var isArray = Array.isArray;
2022

23+
function Util (ref) {
24+
var config = ref.config;
25+
26+
_config = config;
27+
}
28+
29+
function log(message, color) {
30+
if ( color === void 0 ) color = '#41B883';
31+
32+
if (typeof console !== 'undefined' && _config.devtools) {
33+
console.log(("%c vue-event-manager %c " + message + " "), 'color: #fff; background: #35495E; padding: 1px; border-radius: 3px 0 0 3px;', ("color: #fff; background: " + color + "; padding: 1px; border-radius: 0 3px 3px 0;"));
34+
}
35+
}
36+
2137
function isObject(val) {
2238
return val !== null && typeof val === 'object';
2339
}
@@ -203,38 +219,46 @@
203219
};
204220

205221
/**
206-
* Install plugin.
222+
* Plugin class.
207223
*/
208224

209225
var Events = new EventManager();
210226

211-
Events.install = function (Vue, options) {
212-
if ( options === void 0 ) options = {};
213-
227+
var Plugin = {
214228

215-
if (this.installed) {
216-
return;
217-
}
229+
version: '2.1.2',
218230

219-
// add global instance/methods
220-
Vue.prototype.$events = Vue.events = assign(Events, options);
221-
Vue.prototype.$trigger = function (event, params, asynch) {
222-
if ( params === void 0 ) params = [];
223-
if ( asynch === void 0 ) asynch = false;
231+
install: function install(Vue, options) {
232+
if ( options === void 0 ) options = {};
224233

225234

226-
if (!isObject(event)) {
227-
event = {name: event, origin: this};
235+
if (this.installed) {
236+
return;
228237
}
229238

230-
return Events.trigger(event, params, asynch);
231-
};
239+
Util(Vue); log(this.version);
240+
241+
// add global instance/methods
242+
Vue.prototype.$events = Vue.events = assign(Events, options);
243+
Vue.prototype.$trigger = function (event, params, asynch) {
244+
if ( params === void 0 ) params = [];
245+
if ( asynch === void 0 ) asynch = false;
246+
247+
248+
if (!isObject(event)) {
249+
event = {name: event, origin: this};
250+
}
251+
252+
return Events.trigger(event, params, asynch);
253+
};
232254

233-
// add merge strategy for "events"
234-
Vue.config.optionMergeStrategies.events = mergeEvents;
255+
// add merge strategy for "events"
256+
Vue.config.optionMergeStrategies.events = mergeEvents;
257+
258+
// add mixin to parse "events" from component options
259+
Vue.mixin({beforeCreate: initEvents});
260+
}
235261

236-
// add mixin to parse "events" from component options
237-
Vue.mixin({beforeCreate: initEvents});
238262
};
239263

240264
function mergeEvents(parentVal, childVal) {
@@ -286,7 +310,7 @@
286310
listener = listener.handler;
287311
}
288312

289-
_events.push(Events.on(event, bindListener(listener, this$1), priority));
313+
_events.push(this$1.$events.on(event, bindListener(listener, this$1), priority));
290314
});
291315
});
292316

@@ -305,10 +329,14 @@
305329
return fn.bind(vm);
306330
}
307331

332+
/**
333+
* Install plugin.
334+
*/
335+
308336
if (typeof window !== 'undefined' && window.Vue) {
309-
window.Vue.use(Events);
337+
window.Vue.use(Plugin);
310338
}
311339

312-
return Events;
340+
return Plugin;
313341

314342
})));

0 commit comments

Comments
 (0)