Skip to content

Instantly share code, notes, and snippets.

@mynameispj
Created July 7, 2012 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mynameispj/3068049 to your computer and use it in GitHub Desktop.
Save mynameispj/3068049 to your computer and use it in GitHub Desktop.
Scrollable JS table fun time
<script type="text/javascript">
$(window).load(function () {
var isIE = $.browser.msie;
setTimeout(function () {
function sizeTableBrowser() {
$('.rgMasterTable.data').removeClass('data');
$('.rgMasterTable:visible').addClass('data');
var sitewidth = $('.ajax__tab_container:visible').width();
var tablewidth = $('table.data').width();
if (isIE == true) {
$('.ajax__tab_body').css('overflow-x', 'scroll');
} else {
$('table.data > tbody').insertBefore('table.data > tfoot');
$('table.data > thead').next().andSelf().wrapAll('<div class="tableOverflow">');
$('.tableOverflow').css('width', sitewidth + 'px');
if (sitewidth < tablewidth) {
$('.tableOverflow').addClass('overflow');
}
}
}
function reSizeTableBrowser(sitewidth, tablewidth) {
$('.rgMasterTable:visible').addClass('data');
var sitewidth = $('.ajax__tab_container:visible').width();
var tablewidth = $('table.data').width();
$('.tableOverflow').css("width", sitewidth + "px");
if (sitewidth < tablewidth) {
$('.tableOverflow').addClass('overflow');
} else if (sitewidth >= tablewidth) {
$('.tableOverflow').removeClass('overflow');
} else if (sitewidth == tablewidth) {
$('.tableOverflow').removeClass('overflow');
}
}
sizeTableBrowser();
$('a.ajax__tab_tab').click(sizeTableBrowser);
$(window).resize(function () {
reSizeTableBrowser();
});
}, 400);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment