From 7486a332211ed13318c0a689657cb4ff7e7d25a3 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Wed, 1 Jun 2011 12:14:53 -0400 Subject: scrollable content areas Turn off the side scroll bars for pages. Resizes the table when the browser resizes For stables, the rows scroll, but not the header. For details, the content area scrolls. Reserves 400 picesl for the header/ footer. Resize is only done on reload --- install/ui/widget.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index 1c12ac48..9cbd31f0 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -23,6 +23,8 @@ /* REQUIRES: ipa.js */ +IPA.checkbox_column_width = 22; + IPA.widget = function(spec) { spec = spec || {}; @@ -1141,13 +1143,22 @@ IPA.table_widget = function (spec) { th = $('').appendTo(tr); - if (that.scrollable && (i == columns.length-1)) { + if (that.scrollable ) { + var width; if (column.width) { - var width = parseInt( + width = parseInt( column.width.substring(0, column.width.length-2),10); width += 16; - th.css('width', width+'px'); + }else{ + /* don't use the checkbox column as part of the overall + calculation for column widths. It is so small + that it throws off the average. */ + width = (that.table.width() - IPA.checkbox_column_width) / + (columns.length); } + width += 'px'; + th.css('width', width); + column.width = width; } else { if (column.width) { th.css('width', column.width); @@ -1167,6 +1178,9 @@ IPA.table_widget = function (spec) { 'style': 'float: right;' }).appendTo(th); } + if (that.scrollable && !column.width){ + column.width = th.width() +'px'; + } } that.tbody = $('').appendTo(that.table); @@ -1178,7 +1192,7 @@ IPA.table_widget = function (spec) { that.row = $(''); var td = $('', { - 'style': 'width: 22px;' + 'style': 'width: '+ IPA.checkbox_column_width +'px;' }).appendTo(that.row); $('', { @@ -1268,6 +1282,7 @@ IPA.table_widget = function (spec) { name: 'total_pages' }).appendTo(that.pagination); } + that.resize(); }; that.select_changed = function(){ @@ -1282,6 +1297,16 @@ IPA.table_widget = function (spec) { that.tbody.empty(); }; + that.resize = function(){ + if (that.scrollable){ + that.tbody.attr('overflow-y', 'auto'); + that.tbody.height("auto"); + var table_max_height = $(window).height() - + IPA.reserved_screen_size; + that.tbody.height(table_max_height); + } + }; + that.load = function(result) { that.empty(); -- cgit