Compare commits

..

2 Commits

Author SHA1 Message Date
yumoqing
be1f1ebd1d bugfix 2024-02-28 14:12:01 +08:00
yumoqing
e1cf723dee bugfix 2024-02-28 14:11:42 +08:00
4 changed files with 79 additions and 7 deletions

View File

@ -90,8 +90,8 @@ bricks.widgetBuild = async function(desc, widget){
console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw); console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw);
return null; return null;
} }
desc.options.baseURI = base_url;
var options = desc.options || {}; var options = desc.options || {};
options.baseURI = base_url;
let w = new klass(options); let w = new klass(options);
if (desc.id){ if (desc.id){
w.set_id(desc.id); w.set_id(desc.id);

View File

@ -7,17 +7,16 @@ bricks.Layout = class extends bricks.JsWidget {
} }
add_widget(w, index){ 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 // append child at end
w.parent = this; w.parent = this;
this.children.push(w); this.children.push(w);
this.dom_element.appendChild(w.dom_element); 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); w.dispatch('on_parent', this);
} }
remove_widgets_at_begin(cnt){ remove_widgets_at_begin(cnt){

67
examples/add_widget.ui Normal file
View 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
View File

@ -0,0 +1,6 @@
{
"widgettype":"Text",
"options":{
"text":"{{params_kw.get('text') or 'default text'}}"
}
}