From ff954059cbf23e71356798f27d0150bf88027c24 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 22 Apr 2024 19:28:49 +0800 Subject: [PATCH] bugfix --- bricks/modal.js | 11 +++++++++++ examples/message.ui | 1 + examples/modal.json | 1 + 3 files changed, 13 insertions(+) diff --git a/bricks/modal.js b/bricks/modal.js index 9364ca1..1d1fdd1 100755 --- a/bricks/modal.js +++ b/bricks/modal.js @@ -14,6 +14,7 @@ bricks.BaseModal = class extends bricks.Layout { height: bgcolor: title: + timeout: archor: cc ( tl, tc, tr cl, cc, cr bl, bc, br ) @@ -24,6 +25,8 @@ bricks.BaseModal = class extends bricks.Layout { this.set_height('100%'); this.ancestor_add_widget = bricks.Layout.prototype.add_widget.bind(this); this.panel = new bricks.VBox({}); + this.timeout = options.timeout || 0; + this.timeout_task = null; this.ancestor_add_widget(this.panel); this.panel.set_width(this.opts.width); this.panel.set_height(this.opts.height); @@ -72,10 +75,18 @@ bricks.BaseModal = class extends bricks.Layout { } open(){ 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(){ this.dom_element.style.display = "none"; this.target_w.remove_widget(this); + if (this.timeout_task){ + this.timeout_task.cancel(); + this.timeout_task = null; + } } } bricks.Modal = class extends bricks.BaseModal { diff --git a/examples/message.ui b/examples/message.ui index e5ea83b..a5dc65a 100644 --- a/examples/message.ui +++ b/examples/message.ui @@ -7,6 +7,7 @@ "height":"40%", "archor":"cc", "title":"Test Title", + "timeout":2, "message":"This is a test message" } } diff --git a/examples/modal.json b/examples/modal.json index c72734a..ddd4b0a 100644 --- a/examples/modal.json +++ b/examples/modal.json @@ -6,6 +6,7 @@ "auto_close":true, "auto_open":true, "width":"700px", + "timeout":2, "height":"400px", "archor":"cc" },