From d04a91df0d94d7d8a6ca0d82022c069290cbf67a Mon Sep 17 00:00:00 2001 From: serapath Date: Tue, 10 Apr 2018 17:10:49 +0100 Subject: [PATCH] fix refactored tabbed menu --- src/app/panels/righthand-panel.js | 5 ++--- src/app/tabs/tabbed-menu.js | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/panels/righthand-panel.js b/src/app/panels/righthand-panel.js index 94e75752b7..84aff7cceb 100644 --- a/src/app/panels/righthand-panel.js +++ b/src/app/panels/righthand-panel.js @@ -37,9 +37,8 @@ function RighthandPanel (appAPI = {}, events = {}, opts = {}) { ` - appAPI.switchTab = (tabClass) => { - this.event.trigger('switchTab', [tabClass]) - } + // selectTabByClassName + appAPI.switchTab = tabClass => self._view.tabbedMenu.selectTabByClassName(tabClass) events.rhp = self.event diff --git a/src/app/tabs/tabbed-menu.js b/src/app/tabs/tabbed-menu.js index b0b03ea099..6378c3912d 100644 --- a/src/app/tabs/tabbed-menu.js +++ b/src/app/tabs/tabbed-menu.js @@ -2,6 +2,7 @@ var yo = require('yo-yo') var csjs = require('csjs-inject') var remixLib = require('remix-lib') +var helper = require('../../lib/helper') var styles = require('../ui/styles-guide/theme-chooser').chooser() var EventManager = remixLib.EventManager @@ -10,11 +11,10 @@ module.exports = class TabbedMenu { constructor (api = {}, events = {}, opts = {}) { const self = this self.event = new EventManager() + self._opts = opts self._api = api self._events = events self._view = { el: null, viewport: null, tabs: {}, contents: {} } - self.data = {} - self._components = {} } render () { const self = this @@ -33,6 +33,7 @@ module.exports = class TabbedMenu { } addTab (title, cssClass, content) { const self = this + if (helper.checkSpecialChars(title)) return if (self._view.contents[title] || self._view.tabs[title]) throw new Error('tab already exists') self._view.contents[title] = content self._view.tabs[title] = yo`
  • ${title}
  • ` @@ -43,7 +44,7 @@ module.exports = class TabbedMenu { const self = this self.selectTab(self._view.tabs[title]) } - switchTab (tabClass) { + selectTabByClassName (tabClass) { const self = this self.selectTab(self._view.el.querySelector(`li.${tabClass}`)) }