containers: modularize code
This commit is contained in:
parent
148714e17d
commit
f8857545f5
5 changed files with 113 additions and 81 deletions
|
|
@ -28,8 +28,8 @@ var widgets = {
|
|||
text: require('./widgets/plots/text'),
|
||||
|
||||
// containers
|
||||
strip: require('./widgets/strip'),
|
||||
panel: require('./widgets/panel'),
|
||||
strip: require('./widgets/containers/strip'),
|
||||
panel: require('./widgets/containers/panel'),
|
||||
}
|
||||
|
||||
module.exports.categories = {
|
||||
|
|
|
|||
58
src/browser/js/app/widgets/containers/panel.js
Normal file
58
src/browser/js/app/widgets/containers/panel.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
var _widgets_base = require('../common/_widgets_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'panel',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
scroll:true,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'chilren',
|
||||
|
||||
widgets:[],
|
||||
tabs:[]
|
||||
}
|
||||
|
||||
var Panel = module.exports.Panel = function(widgetData) {
|
||||
|
||||
_widgets_base.apply(this,arguments)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets,
|
||||
parsetabs = parsers.tabs
|
||||
|
||||
|
||||
this.widget = $(`
|
||||
<div class="panel">
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (!widgetData.scroll) this.widget.addClass('noscroll')
|
||||
|
||||
if (widgetData.tabs.length) {
|
||||
parsetabs(widgetData.tabs,this.widget)
|
||||
this.widget.addClass('has-tabs')
|
||||
} else {
|
||||
parsewidgets(widgetData.widgets,this.widget)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_widgets_base.apply(this,arguments)
|
||||
|
||||
Panel.prototype = Object.create(_widgets_base.prototype)
|
||||
|
||||
Panel.prototype.constructor = Panel
|
||||
|
||||
module.exports.create = function(widgetData) {
|
||||
var panel = new Panel(widgetData)
|
||||
return panel.widget
|
||||
}
|
||||
53
src/browser/js/app/widgets/containers/strip.js
Normal file
53
src/browser/js/app/widgets/containers/strip.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
var _widgets_base = require('../common/_widgets_base')
|
||||
|
||||
module.exports.options = {
|
||||
type:'strip',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'children',
|
||||
|
||||
widgets:[]
|
||||
}
|
||||
|
||||
var Strip = module.exports.Strip = function(widgetData, container) {
|
||||
|
||||
_widgets_base.apply(this,arguments)
|
||||
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
|
||||
this.widget = $(`
|
||||
<div class="strip">
|
||||
</div>
|
||||
`)
|
||||
if (widgetData.horizontal) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
}
|
||||
|
||||
parsewidgets(widgetData.widgets,this.widget)
|
||||
|
||||
|
||||
}
|
||||
|
||||
_widgets_base.apply(this,arguments)
|
||||
|
||||
Strip.prototype = Object.create(_widgets_base.prototype)
|
||||
|
||||
Strip.prototype.constructor = Strip
|
||||
|
||||
module.exports.create = function(widgetData, container) {
|
||||
var strip = new Strip(widgetData, container)
|
||||
return strip.widget
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
module.exports.options = {
|
||||
type:'panel',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
scroll:true,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'chilren',
|
||||
|
||||
widgets:[],
|
||||
tabs:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parser = require('../parser'),
|
||||
parsewidgets = parser.widgets,
|
||||
parsetabs = parser.tabs
|
||||
|
||||
var widget = $(`
|
||||
<div class="panel">
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (!widgetData.scroll) widget.addClass('noscroll')
|
||||
|
||||
if (widgetData.tabs.length) {
|
||||
parsetabs(widgetData.tabs,widget)
|
||||
widget.addClass('has-tabs')
|
||||
} else {
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
}
|
||||
return widget
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
|
||||
module.exports.options = {
|
||||
type:'strip',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'children',
|
||||
|
||||
widgets:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parsewidgets = require('../parser').widgets
|
||||
|
||||
var widget = $(`
|
||||
<div class="strip">
|
||||
</div>
|
||||
`)
|
||||
if (widgetData.horizontal) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
}
|
||||
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
|
||||
return widget
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue