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>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
form/ACME.js \
form/UserSelector.js \
button/Button.js \
+ button/AltText.js \
button/HelpButton.js \
grid/ObjectGrid.js \
grid/PendingObjectGrid.js \
--- /dev/null
+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);
+ },
+ },
+});