Created
July 7, 2012 20:58
-
-
Save mynameispj/3068049 to your computer and use it in GitHub Desktop.
Scrollable JS table fun time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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