From 689f7ba01ac42734f306d28ea809e7981783b21b Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 15 Dec 2011 16:31:38 +0100 Subject: Better table column width computing Columns can have width set or not. Without setting the width it was computed based on tbody width and number of columns. This method is working well if no column has width set. The disadvantage of this approach is that all columns have the same width and so they are not reflecting their possible usage. Flag columns such as 'external' in rule association tables or various 'enable' flags in search facets can be narrower. If we set them fixed small width it will have different size because this width is not currently added to the computation. This is fixing this problem so dynamic and fixed width can be combined and the columns have desired width. https://fedorahosted.org/freeipa/ticket/2200 --- install/ui/widget.js | 63 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 21 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index ab39b24e..29c133c0 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1084,34 +1084,53 @@ IPA.table_widget = function (spec) { }); } } - var columns = that.columns.values; - for (var i=0; i').appendTo(tr); + var columns_without_width = 0; + var per_column_space = 16; //cell padding(2x6px), border (2x1px), spacing (2px) + var available_width = that.thead.width(); + available_width -= 2; //first cell spacing - var width; - var cell_spacing = 16; //cell padding(2x6px), border (2x1px), spacing (2px) + //subtract checkbox column + if(that.selectable) { + available_width -= IPA.checkbox_column_width; + available_width -= per_column_space; + } + + //subtract width of columns with their width set + for (i=0; i').appendTo(tr); + + th.css('width', column.width); + th.css('max-width', column.width); var label = column.label; @@ -1159,6 +1178,8 @@ IPA.table_widget = function (spec) { } } + var width; + for (/* var */ i=0; i