From 4108635b3420c063380db5549c6e6802d806d99b Mon Sep 17 00:00:00 2001 From: open-trade Date: Fri, 28 Jan 2022 17:48:49 +0800 Subject: [PATCH] refactor tab responsive size again --- src/ui/ab.tis | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ui/ab.tis b/src/ui/ab.tis index 60662e7de..bce1fe0c4 100644 --- a/src/ui/ab.tis +++ b/src/ui/ab.tis @@ -25,7 +25,7 @@ class SearchBar: Reactor.Component { function render() { var value = searchPatterns[this.type] || ""; var me = this; - self.timer(1ms, function() { me.search_id.value = value; }); + self.timer(1ms, function() { (me.search_id || {}).value = value; }); return
{search_icon} @@ -285,6 +285,7 @@ class MultipleSessions: Reactor.Component { self.timer(60ms, function() { me.hidden = false; me.update(); + self.timer(30ms, function() { me.onSize(); }); }); } @@ -300,16 +301,17 @@ class MultipleSessions: Reactor.Component { var w = this.$(.sessions-bar .sessions-tab).box(#width); var len = translate('Recent Sessions').length; var totalChars = 0; + var nEle = 0; + var padding = 12; for (var el in this.$$(#sessions-type span)) { + nEle += 1; var n = el.text.length; - if (n < 3) n = 3; + if (n > 6) padding = 8; totalChars += n; } for (var el in this.$$(#sessions-type span)) { var n = el.text.length; - if (n < 3) n = 3; - var padding = n > 8 ? 8 : 12; - var maxWidth = w * n / totalChars - 2 * padding; + var maxWidth = (w - nEle * 2 * padding) * n / totalChars; if (maxWidth < 0) maxWidth = 36; el.style.set{ "max-width": maxWidth + "px",