mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-08-12 07:22:02 +00:00
new helper Proxmox.Utils.compute_min_label_width()
This commit is contained in:
parent
211267b8cc
commit
28e54f37df
10
Utils.js
10
Utils.js
@ -79,6 +79,16 @@ Ext.define('Proxmox.Utils', { utilities: {
|
||||
return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
|
||||
},
|
||||
|
||||
compute_min_label_width: function(text, width) {
|
||||
|
||||
if (width === undefined) { width = 100; }
|
||||
|
||||
var tm = new Ext.util.TextMetrics();
|
||||
var min = tm.getWidth(text + ':');
|
||||
|
||||
return min < width ? width : min;
|
||||
},
|
||||
|
||||
authOK: function() {
|
||||
return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
|
||||
},
|
||||
|
@ -29,8 +29,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
var tm = new Ext.util.TextMetrics();
|
||||
|
||||
me.rows[name] = {
|
||||
required: true,
|
||||
defaultValue: opts.defaultValue || 0,
|
||||
@ -46,7 +44,8 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
||||
defaultValue: opts.defaultValue || 0,
|
||||
checked: opts.defaultValue ? true : false,
|
||||
deleteDefaultValue: opts.deleteDefaultValue ? true : false,
|
||||
labelWidth: opts.labelWidth || tm.getWidth(text + ':'),
|
||||
labelWidth: Proxmox.Utils.compute_min_label_width(
|
||||
text, opts.labelWidth),
|
||||
fieldLabel: text
|
||||
}
|
||||
}
|
||||
@ -58,8 +57,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
||||
|
||||
opts = opts || {}
|
||||
|
||||
var tm = new Ext.util.TextMetrics();
|
||||
|
||||
me.rows[name] = {
|
||||
required: true,
|
||||
defaultValue: opts.defaultValue,
|
||||
@ -75,7 +72,8 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
||||
emptyText: gettext('Default'),
|
||||
deleteEmpty: true,
|
||||
value: opts.defaultValue,
|
||||
labelWidth: opts.labelWidth || tm.getWidth(text + ':'),
|
||||
labelWidth: Proxmox.Utils.compute_min_label_width(
|
||||
text, opts.labelWidth),
|
||||
fieldLabel: text
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user