From: Matthias Heiserer <m.heiserer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 widget-toolkit 1/3] Buttons: add AltText
Date: Mon, 28 Mar 2022 15:07:34 +0200 [thread overview]
Message-ID: <20220328130737.2961451-1-m.heiserer@proxmox.com> (raw)
The same code is used once in widget toolkit and twice in PVE already,
so it makes sense to add it as a separate button.
Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
changes from v1:
move into separate class
rename vars to something a little bit nicer
move comment above function
reorder some statements
Note: Because it's now guaranteed that the function is called at render time,
I think we can leave out the extra logic to test which text is currently set.
src/button/AltText.js | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 src/button/AltText.js
diff --git a/src/button/AltText.js b/src/button/AltText.js
new file mode 100644
index 0000000..e74d042
--- /dev/null
+++ b/src/button/AltText.js
@@ -0,0 +1,22 @@
+Ext.define('Proxmox.button.AltText', {
+ extend: 'Proxmox.button.Button',
+ xtype: 'proxmoxAltTextButton',
+
+ defaultText: "",
+ altText: "",
+
+ listeners: {
+ // HACK: calculate the max button width on first render to avoid toolbar glitches
+ render: function(button) {
+ let me = this;
+
+ button.setText(me.altText);
+ let altWidth = button.getSize().width;
+
+ button.setText(me.defaultText);
+ let defaultWidth = button.getSize().width;
+
+ button.setWidth(defaultWidth > altWidth ? defaultWidth : altWidth);
+ },
+ },
+});
--
2.30.2
next reply other threads:[~2022-03-28 13:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 13:07 Matthias Heiserer [this message]
2022-03-28 13:07 ` [pve-devel] [PATCH v2 widget-toolkit 2/3] Makefile: " Matthias Heiserer
2022-03-28 13:07 ` [pve-devel] [PATCH v2 widget-toolkit 3/3] apt repos: use new AltText button Matthias Heiserer
2022-03-28 13:07 ` [pve-devel] [PATCH v2 manager] ui: tree-wide: " Matthias Heiserer
2022-04-07 10:46 ` [pve-devel] [PATCH v2 widget-toolkit 1/3] Buttons: add AltText Dominik Csapak
2022-04-07 10:50 ` Dominik Csapak
2022-04-27 16:55 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220328130737.2961451-1-m.heiserer@proxmox.com \
--to=m.heiserer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox