This commit is contained in:
yumoqing 2024-04-22 19:28:49 +08:00
parent d573fa40f7
commit ff954059cb
3 changed files with 13 additions and 0 deletions

View File

@ -14,6 +14,7 @@ bricks.BaseModal = class extends bricks.Layout {
height: height:
bgcolor: bgcolor:
title: title:
timeout:
archor: cc ( tl, tc, tr archor: cc ( tl, tc, tr
cl, cc, cr cl, cc, cr
bl, bc, br ) bl, bc, br )
@ -24,6 +25,8 @@ bricks.BaseModal = class extends bricks.Layout {
this.set_height('100%'); this.set_height('100%');
this.ancestor_add_widget = bricks.Layout.prototype.add_widget.bind(this); this.ancestor_add_widget = bricks.Layout.prototype.add_widget.bind(this);
this.panel = new bricks.VBox({}); this.panel = new bricks.VBox({});
this.timeout = options.timeout || 0;
this.timeout_task = null;
this.ancestor_add_widget(this.panel); this.ancestor_add_widget(this.panel);
this.panel.set_width(this.opts.width); this.panel.set_width(this.opts.width);
this.panel.set_height(this.opts.height); this.panel.set_height(this.opts.height);
@ -72,10 +75,18 @@ bricks.BaseModal = class extends bricks.Layout {
} }
open(){ open(){
this.dom_element.style.display = ""; this.dom_element.style.display = "";
console.log('this.timeout=', this.timeout);
if (this.timeout > 0){
this.timeout_task = schedule_once(this.dismiss.bind(this), this.timeout);
}
} }
dismiss(){ dismiss(){
this.dom_element.style.display = "none"; this.dom_element.style.display = "none";
this.target_w.remove_widget(this); this.target_w.remove_widget(this);
if (this.timeout_task){
this.timeout_task.cancel();
this.timeout_task = null;
}
} }
} }
bricks.Modal = class extends bricks.BaseModal { bricks.Modal = class extends bricks.BaseModal {

View File

@ -7,6 +7,7 @@
"height":"40%", "height":"40%",
"archor":"cc", "archor":"cc",
"title":"Test Title", "title":"Test Title",
"timeout":2,
"message":"This is a test message" "message":"This is a test message"
} }
} }

View File

@ -6,6 +6,7 @@
"auto_close":true, "auto_close":true,
"auto_open":true, "auto_open":true,
"width":"700px", "width":"700px",
"timeout":2,
"height":"400px", "height":"400px",
"archor":"cc" "archor":"cc"
}, },