testTab: refactor to prepare for class

pull/1/head
serapath 7 years ago
parent 252840fb72
commit 9f5e8f4840
  1. 30
      src/app/tabs/test-tab.js

@ -10,22 +10,27 @@ function append (container, txt) {
const prototype = { const prototype = {
constructor: function testTab (api = {}, events = {}, opts = {}) { constructor: function testTab (api = {}, events = {}, opts = {}) {
let el = prototype.render(api) const self = this
let gitterIsLoaded = false self._opts = opts
self._api = api
self._events = events
self._view = { el: null }
self._components = {}
self.data = {}
events.app.register('tabChanged', (tabName) => { self._view.el = prototype.render()
if (tabName !== 'test' || gitterIsLoaded) {
return
}
yo.update(el, prototype.render(api)) events.app.register('tabChanged', tabName => {
el.style.display = 'block' if (tabName !== 'test') return
gitterIsLoaded = true yo.update(self._view.el, prototype.render())
self._view.el.style.display = 'block'
}) })
return { render () { return el } } return { render () { return self._view.el } }
}, },
render: function render (api) { render: function render () {
const self = this
const api = self._api
var container = yo`<div class="tests" id="tests"></div>` var container = yo`<div class="tests" id="tests"></div>`
let testCallback = function (result) { let testCallback = function (result) {
@ -89,7 +94,7 @@ const prototype = {
}) })
} }
return yo` var el = yo`
<div class="${css.testTabView} "id="testView"> <div class="${css.testTabView} "id="testView">
<div> <div>
<div class="${css.infoBox}"> <div class="${css.infoBox}">
@ -101,6 +106,7 @@ const prototype = {
</div> </div>
</div> </div>
` `
return el
} }
} }
prototype.constructor.prototype = prototype prototype.constructor.prototype = prototype

Loading…
Cancel
Save