Skip to content

Commit 18bdaa1

Browse files
[DEV] Cleaning up
1 parent ef17910 commit 18bdaa1

File tree

3 files changed

+19
-38
lines changed

3 files changed

+19
-38
lines changed

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import EasterEggTrigger from '@plugins/EasterEggTrigger'
1+
import EasterEggTrigger from '@plugins/EasterEggTrigger';
22

3-
export const version = '__VERSION__'
3+
export const version = '__VERSION__';
44

55
// Automatic installation if Vue has been added to the global scope.
66
if (typeof window !== 'undefined' && window.Vue) {
77
window.Vue.use(EasterEggTrigger);
88
}
99

10-
export default EasterEggTrigger
10+
export default EasterEggTrigger;

src/plugins/EasterEggTrigger.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ const EasterEggTrigger = {
1111

1212
// Add an instance methods //
1313
Vue.prototype.$easterEgg = function(eggOptions) {
14-
const pluginOptions = EasterEggTrigger.options;
15-
16-
EasterEggTriggerCore.init(Vue, pluginOptions, eggOptions);
14+
EasterEggTriggerCore.init(EasterEggTrigger.options, eggOptions);
1715
};
1816

1917
Vue.prototype.$easterEggTrigger = function(eggOptions) {
20-
const pluginOptions = EasterEggTrigger.options;
21-
EasterEggTriggerCore.init(Vue, pluginOptions, eggOptions);
22-
// plugin.setEggOptions(methodOptions);
23-
// plugin.callAddListener();
18+
EasterEggTriggerCore.init(EasterEggTrigger.options, eggOptions);
2419
};
2520
},
2621
options: {

src/plugins/EasterEggTriggerCore.js

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,23 @@ const EasterEggTrigger = {
1313
},
1414

1515
// Options //
16-
defaultOptions: {
17-
egg: {
18-
callback: null,
19-
destroyBus: false,
20-
keys: false,
21-
name: 'easter-egg',
22-
pattern: false,
23-
target: 'html',
24-
withBus: true,
25-
},
26-
plugin: {
27-
delay: 500,
28-
keys: ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'],
29-
mouseEvents: [
30-
'click', // Works with multiple single clicks pattern
31-
'dblclick', // Only works with single double click pattern set
32-
'mouseup', // Works with multiple mouseup clicks pattern
33-
'mousedown', // Works with multiple mousedown clicks pattern
34-
],
35-
pattern: [38, 38, 40, 40, 37, 39, 37, 39, 66, 65],
36-
type: 'keydown',
37-
},
16+
defaultEggOptions: {
17+
callback: null,
18+
destroyBus: false,
19+
keys: false,
20+
name: 'easter-egg',
21+
pattern: false,
22+
target: 'html',
23+
withBus: true,
3824
},
3925
eggOptions: {},
4026
pluginOptions: {},
4127

4228
// Initiate Eggs //
43-
init(vue, pluginOptions, eggOptions = {}) {
29+
init(pluginOptions = {}, eggOptions = {}) {
4430
// Set Options //
45-
this.pluginOptions = { ...this.defaultOptions.plugin, ...pluginOptions };
46-
this.eggOptions = { ...this.defaultOptions.egg, ...eggOptions };
31+
this.pluginOptions = pluginOptions;
32+
this.eggOptions = { ...this.defaultEggOptions, ...eggOptions };
4733

4834
this.layEggs();
4935
},
@@ -61,8 +47,8 @@ const EasterEggTrigger = {
6147
const newEgg = egg;
6248

6349
if (!newEgg.keys && !newEgg.pattern) {
64-
newEgg.keys = this.defaultOptions.plugin.keys;
65-
newEgg.pattern = this.defaultOptions.plugin.pattern;
50+
newEgg.keys = this.pluginOptions.keys;
51+
newEgg.pattern = this.pluginOptions.pattern;
6652
}
6753
});
6854

@@ -93,7 +79,7 @@ const EasterEggTrigger = {
9379
}
9480

9581
// -------------------- Mouse Events //
96-
if (_.includes(EasterEggTrigger.defaultOptions.plugin.mouseEvents, e.type)) {
82+
if (_.includes(EasterEggTrigger.pluginOptions.mouseEvents, e.type)) {
9783
key = e.type;
9884

9985
EasterEggTrigger.targets.nodes.push(e.target.nodeName.toLowerCase());

0 commit comments

Comments
 (0)