From e2702bd398ef50c86278fb8143cf9e9583419336 Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Thu, 14 Mar 2019 14:07:00 +0100 Subject: [PATCH] switch event to events --- src/app/components/swap-panel-api.js | 2 +- .../components/vertical-icons-component.js | 36 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/app/components/swap-panel-api.js b/src/app/components/swap-panel-api.js index 9b2f8cc3bf..3fa4e742b1 100644 --- a/src/app/components/swap-panel-api.js +++ b/src/app/components/swap-panel-api.js @@ -5,7 +5,7 @@ class SwapPanelApi { this.event = new EventEmmitter() this.component = swapPanelComponent this.currentContent - verticalIconsComponent.event.on('showContent', (moduleName) => { + verticalIconsComponent.events.on('showContent', (moduleName) => { if (!swapPanelComponent.contents[moduleName]) return if (this.currentContent === moduleName) { this.event.emit('toggle', moduleName) diff --git a/src/app/components/vertical-icons-component.js b/src/app/components/vertical-icons-component.js index ff2c3d5326..e81c34c068 100644 --- a/src/app/components/vertical-icons-component.js +++ b/src/app/components/vertical-icons-component.js @@ -1,14 +1,14 @@ var yo = require('yo-yo') var csjs = require('csjs-inject') -const EventEmmitter = require('events') +const EventEmitter = require('events') // Component class VerticalIconComponent { constructor (name, appStore) { this.store = appStore - this.event = new EventEmmitter() + this.events = new EventEmitter() this.icons = {} this.iconKind = {} this.name = name @@ -16,28 +16,34 @@ class VerticalIconComponent { this.store.event.on('activate', (name) => { const { profile } = this.store.getOne(name) if (!profile.icon) return - if (profile.prefferedLocation === this.name || !profile.prefferedLocation) { + if (profile.location === this.name || !profile.location) { this.addIcon(profile) } }) this.store.event.on('deactivate', (name) => { - const item = this.store.getOne(name) - if (item && this.icons[name]) this.removeIcon(item.profile) + const api = this.store.getOne(name) + if (api && this.icons[name]) this.removeIcon(api.profile) }) - this.store.event.on('add', (entity) => { }) - this.store.event.on('remove', (entity) => { }) + this.store.event.on('add', (api) => { }) + this.store.event.on('remove', (api) => { }) } - addIcon (mod) { - let kind = mod.kind || 'other' - this.icons[mod.name] = yo`
{ this._iconClick(mod.name) }} title=${mod.name} >${mod.name}
` + /** + * Add an icon to the map + * @param {ModuleProfile} profile The profile of the module + */ + addIcon ({kind, name, icon}) { + this.icons[name] = yo`
${name}
` - this.iconKind[kind].appendChild(this.icons[mod.name]) + this.iconKind[kind || 'other'].appendChild(this.icons[name]) } - removeIcon (mod) { - let kind = mod.kind || 'other' - if (this.icons[mod.name]) this.iconKind[kind].removeChild(this.icons[mod.name]) + /** + * Remove an icon from the map + * @param {ModuleProfile} profile The profile of the module + */ + removeIcon ({kind, name}) { + if (this.icons[name]) this.iconKind[kind || 'other'].removeChild(this.icons[name]) } select (name) { @@ -53,7 +59,7 @@ class VerticalIconComponent { let activate = this.view.querySelector(`[title="${name}"]`) if (activate) activate.classList.toggle(`${css.active}`) } - this.event.emit('showContent', name) + this.events.emit('showContent', name) } _iconClick (name) {