root: add onPreload scripting property
This commit is contained in:
parent
a04c658bb5
commit
86e819870c
5 changed files with 20 additions and 1 deletions
|
|
@ -142,7 +142,7 @@ class Widget extends EventEmitter {
|
|||
bypass: {type: 'boolean', value: false, help: 'Set to `true` to prevent the widget from sending any osc message'}
|
||||
},
|
||||
scripting: {
|
||||
onCreate: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget is created. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.']},
|
||||
onCreate: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget (and its children) is created. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.']},
|
||||
onValue: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget\'s value updates. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.']},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ var Container = require('../common/container'),
|
|||
setScrollbarColor = require('../../ui/scrollbar-color'),
|
||||
iOS13 = require('../../ui/ios') === 13,
|
||||
Fader = require('../sliders/fader'), faderDefaults,
|
||||
Script = require('../scripts/script'),
|
||||
resize = require('../../events/resize'),
|
||||
fastdom = require('fastdom')
|
||||
|
||||
|
|
@ -56,6 +57,16 @@ class Panel extends Container() {
|
|||
|
||||
this.childrenType = ''
|
||||
|
||||
if (options.root && this.getProp('onPreload')) {
|
||||
this.scripts.onPreload = new Script({
|
||||
widget: this,
|
||||
property: 'onPreload',
|
||||
code: this.getProp('onPreload'),
|
||||
context: {}
|
||||
})
|
||||
if (this.scripts.onPreload) this.scripts.onPreload.run({}, {})
|
||||
}
|
||||
|
||||
this.container.classList.toggle('no-inner-padding', !this.getProp('innerPadding'))
|
||||
this.container.classList.toggle('no-scroll', !this.getProp('scroll'))
|
||||
this.container.classList.add('layout-' + this.getProp('layout'))
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro
|
|||
_separator_root_style: 'Root style',
|
||||
hideMenu: {type: 'boolean', value: false, help: 'Set to `true` to hide the main menu button.'},
|
||||
|
||||
},
|
||||
scripting: {
|
||||
onPreload: {type: 'script', value: '', editor: 'javascript', help: ['Script executed before any other widget is created. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.']},
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue