On 24.03.22 12:33, Matthias Heiserer wrote:
> The same code is used once in widget toolkit and twice in PVE already,
> so it makes sense to add it as a separate function.
> 
> Signed-off-by: Matthias Heiserer <m.heise...@proxmox.com>
> ---
>  src/Utils.js | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/Utils.js b/src/Utils.js
> index 6a03057..27fcd1d 100644
> --- a/src/Utils.js
> +++ b/src/Utils.js
> @@ -1272,6 +1272,17 @@ utilities: {
>           .map(val => val.charCodeAt(0)),
>       );
>      },
> +
> +    calculateWidth: function(btn) {

way to general name for such a specific use case, NACK, rather:

maxAltTextButtonWidth

> +     // HACK: calculate the max button width on first render to avoid 
> toolbar glitches

comment could go in line above the function declaration.

> +     let defSize = btn.getSize().width;

now that we're not on a deeper indentation level we can also spell out the 
variable
names more nicely.

> +
> +     btn.setText(btn.altText);
> +     let altSize = btn.getSize().width;
> +
> +     btn.setText(btn.defaultText);
> +     btn.setWidth(altSize > defSize ? altSize : defSize);
> +    },
>  },
>  
>      singleton: true,



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to