mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-29 19:25:37 +00:00
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>
This commit is contained in:
parent
8315a64201
commit
463177281c
@ -45,6 +45,7 @@ JSSRC= \
|
|||||||
form/ACME.js \
|
form/ACME.js \
|
||||||
form/UserSelector.js \
|
form/UserSelector.js \
|
||||||
button/Button.js \
|
button/Button.js \
|
||||||
|
button/AltText.js \
|
||||||
button/HelpButton.js \
|
button/HelpButton.js \
|
||||||
grid/ObjectGrid.js \
|
grid/ObjectGrid.js \
|
||||||
grid/PendingObjectGrid.js \
|
grid/PendingObjectGrid.js \
|
||||||
|
22
src/button/AltText.js
Normal file
22
src/button/AltText.js
Normal file
@ -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);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user