Compare commits
2 Commits
638e629cf1
...
be1f1ebd1d
Author | SHA1 | Date | |
---|---|---|---|
|
be1f1ebd1d | ||
|
e1cf723dee |
@ -90,8 +90,8 @@ bricks.widgetBuild = async function(desc, widget){
|
||||
console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw);
|
||||
return null;
|
||||
}
|
||||
desc.options.baseURI = base_url;
|
||||
var options = desc.options || {};
|
||||
options.baseURI = base_url;
|
||||
let w = new klass(options);
|
||||
if (desc.id){
|
||||
w.set_id(desc.id);
|
||||
|
@ -7,17 +7,16 @@ bricks.Layout = class extends bricks.JsWidget {
|
||||
}
|
||||
|
||||
add_widget(w, index){
|
||||
if (! index || index>=this.children.length){
|
||||
if (index >=0 && index < this.children.length){
|
||||
var pos_w = this.children[index];
|
||||
this.dom_element.insertBefore(w.dom_element, pos_w.dom_element);
|
||||
this.children.insert(index+1, w);
|
||||
} else {
|
||||
// append child at end
|
||||
w.parent = this;
|
||||
this.children.push(w);
|
||||
this.dom_element.appendChild(w.dom_element);
|
||||
return
|
||||
}
|
||||
// insert to where index point out
|
||||
var pos_w = this.children[index];
|
||||
this.dom_element.insertBefore(w.dom_element, pos_w.dom_element);
|
||||
this.children.insert(index+1, w);
|
||||
w.dispatch('on_parent', this);
|
||||
}
|
||||
remove_widgets_at_begin(cnt){
|
||||
|
67
examples/add_widget.ui
Normal file
67
examples/add_widget.ui
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"widgettype":"VBox",
|
||||
"options":{
|
||||
"width":"100%",
|
||||
"height":"100%"
|
||||
},
|
||||
"subwidgets":[
|
||||
{
|
||||
"widgettype":"HBox",
|
||||
"options":{
|
||||
"height":"40px"
|
||||
},
|
||||
"subwidgets":[
|
||||
{
|
||||
"id":"insert",
|
||||
"widgettype":"Button",
|
||||
"options":{
|
||||
"width":"80px",
|
||||
"i18n":true,
|
||||
"label":"insert"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"append",
|
||||
"widgettype":"Button",
|
||||
"options":{
|
||||
"width":"80px",
|
||||
"i18n":true,
|
||||
"label":"append"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id":"main",
|
||||
"widgettype":"Filler"
|
||||
}
|
||||
],
|
||||
"binds":[
|
||||
{
|
||||
"wid":"insert",
|
||||
"event":"click",
|
||||
"actiontype":"urlwidget",
|
||||
"target":"main",
|
||||
"options":{
|
||||
"url":"{{entire_url('subtext.ui')}}",
|
||||
"params":{
|
||||
"text":"Insert before"
|
||||
}
|
||||
},
|
||||
"mode":"insert"
|
||||
},
|
||||
{
|
||||
"wid":"append",
|
||||
"event":"click",
|
||||
"actiontype":"urlwidget",
|
||||
"target":"main",
|
||||
"options":{
|
||||
"url":"{{entire_url('subtext.ui')}}",
|
||||
"params":{
|
||||
"text":"Append After"
|
||||
}
|
||||
},
|
||||
"mode":"append"
|
||||
}
|
||||
]
|
||||
}
|
6
examples/subtext.ui
Normal file
6
examples/subtext.ui
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"widgettype":"Text",
|
||||
"options":{
|
||||
"text":"{{params_kw.get('text') or 'default text'}}"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user