diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 4ff926dc..41a4fa32 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -3177,10 +3177,18 @@ nScrollBody = o.nTable.parentNode, i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis, nTheadSize, nTfootSize, - iWidth, aApplied=[], iSanityWidth, + iWidth, aApplied=[], aAppliedFooter=[], iSanityWidth, nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null, nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null, - ie67 = o.oBrowser.bScrollOversize; + ie67 = o.oBrowser.bScrollOversize, + zeroOut = function(nSizer, nToSize) { + oStyle = nSizer.style; + oStyle.paddingTop = "0"; + oStyle.paddingBottom = "0"; + oStyle.borderTopWidth = "0"; + oStyle.borderBottomWidth = "0"; + oStyle.height = 0; + }; /* * 1. Re-create the table inside the scrolling div @@ -3289,38 +3297,40 @@ anHeadToSize = o.nTHead.getElementsByTagName('tr'); anHeadSizers = nTheadSize.getElementsByTagName('tr'); + // Apply all styles in one pass. Invalidates layout only once because we don't read any + // DOM properties. + _fnApplyToChildren( zeroOut, anHeadSizers, anHeadToSize ); + + // Read all widths in next pass. Forces layout only once because we do not change + // any DOM properties. _fnApplyToChildren( function(nSizer, nToSize) { - oStyle = nSizer.style; - oStyle.paddingTop = "0"; - oStyle.paddingBottom = "0"; - oStyle.borderTopWidth = "0"; - oStyle.borderBottomWidth = "0"; - oStyle.height = 0; - - iWidth = $(nSizer).width(); - nToSize.style.width = _fnStringToCss( iWidth ); - aApplied.push( iWidth ); + aApplied.push( _fnStringToCss( $(nSizer).width() ) ); }, anHeadSizers, anHeadToSize ); + + // Apply all widths in final pass. Invalidates layout only once because we do not + // read any DOM properties. + _fnApplyToChildren( function(nSizer, nToSize, i) { + nToSize.style.width = aApplied[i]; + }, anHeadSizers, anHeadToSize ); + $(anHeadSizers).height(0); + /* Same again with the footer if we have one */ if ( o.nTFoot !== null ) { - /* Clone the current footer and then place it into the body table as a "hidden header" */ anFootSizers = nTfootSize.getElementsByTagName('tr'); anFootToSize = o.nTFoot.getElementsByTagName('tr'); + _fnApplyToChildren( zeroOut, anFootSizers, anFootToSize ); + _fnApplyToChildren( function(nSizer, nToSize) { - oStyle = nSizer.style; - oStyle.paddingTop = "0"; - oStyle.paddingBottom = "0"; - oStyle.borderTopWidth = "0"; - oStyle.borderBottomWidth = "0"; - oStyle.height = 0; - - iWidth = $(nSizer).width(); - nToSize.style.width = _fnStringToCss( iWidth ); - aApplied.push( iWidth ); + aAppliedFooter.push( _fnStringToCss( $(nSizer).width() ) ); }, anFootSizers, anFootToSize ); + + _fnApplyToChildren( function(nSizer, nToSize, i) { + nToSize.style.width = aAppliedFooter[i]; + }, anFootSizers, anFootToSize ); + $(anFootSizers).height(0); } @@ -3331,16 +3341,16 @@ /* "Hide" the header and footer that we used for the sizing. We want to also fix their width * to what they currently are */ - _fnApplyToChildren( function(nSizer) { + _fnApplyToChildren( function(nSizer, i) { nSizer.innerHTML = ""; - nSizer.style.width = _fnStringToCss( aApplied.shift() ); + nSizer.style.width = aApplied[i]; }, anHeadSizers ); if ( o.nTFoot !== null ) { - _fnApplyToChildren( function(nSizer) { + _fnApplyToChildren( function(nSizer, i) { nSizer.innerHTML = ""; - nSizer.style.width = _fnStringToCss( aApplied.shift() ); + nSizer.style.width = aAppliedFooter[i]; }, anFootSizers ); } @@ -3460,20 +3470,25 @@ */ function _fnApplyToChildren( fn, an1, an2 ) { - for ( var i=0, iLen=an1.length ; i