widgets: add new "modal" container
This commit is contained in:
parent
74741eed4e
commit
c39f42f28f
3 changed files with 135 additions and 22 deletions
|
|
@ -30,6 +30,7 @@ var widgets = {
|
|||
// containers
|
||||
strip: require('./widgets/containers/strip'),
|
||||
panel: require('./widgets/containers/panel'),
|
||||
modal: require('./widgets/containers/modal'),
|
||||
}
|
||||
|
||||
module.exports.categories = {
|
||||
|
|
@ -38,7 +39,7 @@ module.exports.categories = {
|
|||
'Pads':['xy','rgb','multixy'],
|
||||
'Matrices':['multifader','multitoggle','multipush', 'keyboard'],
|
||||
'Plots':['plot','eq','visualizer','led','meter','text'],
|
||||
'Containers':['panel','strip']
|
||||
'Containers':['panel','strip','modal']
|
||||
}
|
||||
|
||||
module.exports.widgetOptions = function(){
|
||||
|
|
|
|||
69
src/browser/js/app/widgets/containers/modal.js
Normal file
69
src/browser/js/app/widgets/containers/modal.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
var {Panel} = require('./panel')
|
||||
|
||||
module.exports.options = {
|
||||
type:'modal',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
scroll:true,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'chilren',
|
||||
|
||||
widgets:[],
|
||||
tabs:[]
|
||||
}
|
||||
|
||||
var Modal = module.exports.Modal = function(widgetData, container) {
|
||||
|
||||
Panel.apply(this,arguments)
|
||||
|
||||
this.container = container
|
||||
|
||||
container.append('<div class="light"></div>')
|
||||
this.light = container.find('.light').first()
|
||||
|
||||
this.modal = this.widget.detach()
|
||||
|
||||
this.value = false
|
||||
|
||||
this.light.on('fake-click',()=>{
|
||||
this.setValue(!this.value)
|
||||
})
|
||||
|
||||
this.widget.setValue = this.setValue.bind(this)
|
||||
this.widget.getValue = ()=>{
|
||||
return this.value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Modal.prototype = Object.create(Panel.prototype)
|
||||
|
||||
Modal.prototype.constructor = Modal
|
||||
|
||||
Modal.prototype.setValue = function(v) {
|
||||
if (v) {
|
||||
this.container.addClass('on')
|
||||
this.widget.addClass('on')
|
||||
this.light.addClass('on')
|
||||
this.value = true
|
||||
} else {
|
||||
this.container.removeClass('on')
|
||||
this.widget.removeClass('on')
|
||||
this.light.removeClass('on')
|
||||
this.value = false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.create = function(widgetData, container) {
|
||||
var modal = new Modal(widgetData, container)
|
||||
return modal.widget
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue