proxmox-widget-toolkit/src/button/AltText.js
Matthias Heiserer 463177281c Buttons: add AltText
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>
2022-04-27 14:29:54 +02:00

23 lines
552 B
JavaScript

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);
},
},
});