props: store dynamic props as static variables
This commit is contained in:
parent
6b5cba80e1
commit
eec1901372
6 changed files with 55 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
osc = require('../../osc')
|
||||
|
||||
module.exports = class Push extends _widgets_base {
|
||||
class Push extends _widgets_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
|
|
@ -47,8 +47,6 @@ module.exports = class Push extends _widgets_base {
|
|||
this.active = 0
|
||||
this.lastChanged = 'state'
|
||||
|
||||
this.dynamicProps.push('on', 'off', 'norelease')
|
||||
|
||||
this.on('draginit',()=>{
|
||||
if (this.active) return
|
||||
this.setValuePrivate(this.getProp('on'),{send:true,sync:true})
|
||||
|
|
@ -136,3 +134,11 @@ module.exports = class Push extends _widgets_base {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
Push.dynamicProps = Push.prototype.dynamicProps.concat(
|
||||
'on',
|
||||
'off',
|
||||
'norelease'
|
||||
)
|
||||
|
||||
module.exports = Push
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
doubletab = require('../mixins/double_tap')
|
||||
|
||||
|
||||
module.exports = class Toggle extends _widgets_base {
|
||||
class Toggle extends _widgets_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
|
|
@ -48,8 +47,6 @@ module.exports = class Toggle extends _widgets_base {
|
|||
|
||||
this.state = 0
|
||||
this.active = false
|
||||
|
||||
this.dynamicProps.push('on', 'off')
|
||||
|
||||
if (this.getProp('led')) this.container.classList.add('led')
|
||||
|
||||
|
|
@ -100,3 +97,10 @@ module.exports = class Toggle extends _widgets_base {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
Toggle.dynamicProps = Toggle.prototype.dynamicProps.concat(
|
||||
'on',
|
||||
'off'
|
||||
)
|
||||
|
||||
module.exports = Toggle
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class CanvasQueue {
|
|||
var canvasQueue = new CanvasQueue()
|
||||
|
||||
|
||||
module.exports = class _canvas_base extends _widgets_base {
|
||||
class _canvas_base extends _widgets_base {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
|
|
@ -197,3 +197,10 @@ module.exports = class _canvas_base extends _widgets_base {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
_canvas_base.dynamicProps = _canvas_base.prototype.dynamicProps.concat(
|
||||
'on',
|
||||
'off'
|
||||
)
|
||||
|
||||
module.exports = _canvas_base
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ DOM.ready(()=>{
|
|||
fallbackContainer = DOM.create('<div></div>')
|
||||
})
|
||||
|
||||
module.exports = class _widgets_base extends EventEmitter {
|
||||
class _widgets_base extends EventEmitter {
|
||||
|
||||
static defaults() {
|
||||
|
||||
|
|
@ -27,7 +27,6 @@ module.exports = class _widgets_base extends EventEmitter {
|
|||
this.container = options.container || fallbackContainer
|
||||
this.widget = DOM.create(options.html)
|
||||
this.props = options.props
|
||||
this.dynamicProps = ['value', 'color', 'precision', 'address', 'preArgs', 'target', 'noSync']
|
||||
this.parent = options.root ? widgetManager : options.parent
|
||||
this.parentNode = options.parentNode
|
||||
this.hash = shortid.generate()
|
||||
|
|
@ -377,7 +376,7 @@ module.exports = class _widgets_base extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
return this.dynamicProps.indexOf(propName) == -1
|
||||
return this.constructor.dynamicProps.indexOf(propName) == -1
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -395,3 +394,15 @@ module.exports = class _widgets_base extends EventEmitter {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
_widgets_base.dynamicProps = [
|
||||
'value',
|
||||
'color',
|
||||
'precision',
|
||||
'address',
|
||||
'preArgs',
|
||||
'target',
|
||||
'noSync'
|
||||
]
|
||||
|
||||
module.exports = _widgets_base
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
parser = require('../../parser')
|
||||
|
||||
|
||||
|
||||
module.exports = class Panel extends _widgets_base {
|
||||
class Panel extends _widgets_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
|
|
@ -63,7 +62,6 @@ module.exports = class Panel extends _widgets_base {
|
|||
if (this.getProp('border') === false) this.container.classList.add('noborder')
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) this.widget.classList.add('has-tabs')
|
||||
|
||||
|
||||
this.value = -1
|
||||
this.tabs = []
|
||||
|
||||
|
|
@ -208,3 +206,9 @@ module.exports = class Panel extends _widgets_base {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
Panel.dynamicProps = Panel.prototype.dynamicProps.concat(
|
||||
'variables'
|
||||
)
|
||||
|
||||
module.exports = Panel
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ var {clip, mapToScale} = require('../utils'),
|
|||
doubletab = require('../mixins/double_tap'),
|
||||
Input = require('../inputs/input')
|
||||
|
||||
module.exports = class _sliders_base extends _canvas_base {
|
||||
|
||||
class _sliders_base extends _canvas_base {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
|
|
@ -227,3 +228,10 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
_sliders_base.dynamicProps = _sliders_base.prototype.dynamicProps.concat(
|
||||
'on',
|
||||
'off'
|
||||
)
|
||||
|
||||
module.exports = _sliders_base
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue