diff --git a/.datatables-commit-sync b/.datatables-commit-sync
index ee36ea58..d430ae49 100644
--- a/.datatables-commit-sync
+++ b/.datatables-commit-sync
@@ -1 +1 @@
-4daf47de0baf63177f503990d32aa32614968531
+a0417585115ca4bb8a6675eed7738724432ad032
diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js
index a486be66..531ad664 100644
--- a/media/js/jquery.dataTables.js
+++ b/media/js/jquery.dataTables.js
@@ -3414,34 +3414,9 @@
}
}
- /**
- * Convert a CSS unit width to pixels (e.g. 2em)
- * @param {string} sWidth width to be converted
- * @param {node} nParent parent to get the with for (required for relative widths) - optional
- * @returns {int} iWidth width in pixels
- * @memberof DataTable#oApi
- */
- function _fnConvertToWidth ( sWidth, nParent )
- {
- if ( ! sWidth )
- {
- return 0;
- }
- if ( ! nParent )
- {
- nParent = document.body;
- }
- var n = $('
')
- .css( 'width', _fnStringToCss( sWidth ) )
- .appendTo( nParent );
-
- var width = n[0].offsetWidth;
- n.remove();
-
- return width;
- }
+ var __re_html_remove = /<.*?>/g;
/**
@@ -3451,235 +3426,159 @@
*/
function _fnCalculateColumnWidths ( oSettings )
{
- var table = oSettings.nTable;
- var columns = oSettings.aoColumns;
- var column;
- var iTableWidth = table.offsetWidth;
- var iUserInputs = 0;
- var iTmpWidth;
- var iVisibleColumns = 0;
- var iColums = columns.length;
- var i, iIndex, iCorrector, iWidth;
- var oHeaders = $('th', oSettings.nTHead);
- var widthAttr = table.getAttribute('width');
- var nWrapper = table.parentNode;
+ var
+ table = oSettings.nTable,
+ columns = oSettings.aoColumns,
+ scroll = oSettings.oScroll,
+ scrollY = scroll.sY,
+ scrollX = scroll.sX,
+ scrollXInner = scroll.sXInner,
+ columnCount = columns.length,
+ visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
+ headerCells = $('th', oSettings.nTHead),
+ tableWidthAttr = table.getAttribute('width'),
+ tableContainer = table.parentNode,
+ userInputs = false,
+ i, column, columnIdx, width, outerWidth;
/* Convert any user input sizes into pixel sizes */
- for ( i=0 ; i
') );
- nCalcTmp.removeAttribute( "id" );
- nCalcTmp.appendChild( nTheadClone );
- if ( oSettings.nTFoot !== null )
- {
- nCalcTmp.appendChild( oSettings.nTFoot.cloneNode(true) );
- _fnApplyToChildren( function(n) {
- n.style.width = "";
- }, nCalcTmp.getElementsByTagName('tr') );
+ // Remove any assigned widths from the footer (from scrolling)
+ tmpTable.find('tfoot th, tfoot td').css('width', '');
+
+ var tr = tmpTable.find( 'tbody tr' );
+
+ // Apply custom sizing to the cloned header
+ headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
+
+ for ( i=0 ; itd', nCalcTmp);
- }
-
- /* Apply custom sizing to the cloned header */
- var nThs = _fnGetUniqueThs( oSettings, nTheadClone );
- iCorrector = 0;
- for ( i=0 ; i 0 )
- {
- column.sWidth = _fnStringToCss( iWidth );
- }
- iCorrector++;
- }
- }
-
- var cssWidth = $(nCalcTmp).css('width');
- table.style.width = (cssWidth.indexOf('%') !== -1) ?
- cssWidth : _fnStringToCss( $(nCalcTmp).outerWidth() );
- nCalcTmp.parentNode.removeChild( nCalcTmp );
+ // Finished with the table - ditch it
+ tmpTable.remove();
}
- if ( widthAttr )
- {
- table.style.width = _fnStringToCss( widthAttr );
+ // If there is a width attr, we want to attach an event listener which
+ // allows the table sizing to automatically adjust when the window is
+ // resized. Use the width attr rather than CSS, since we can't know if the
+ // CSS is a relative value or absolute - DOM read is always px.
+ if ( tableWidthAttr ) {
+ table.style.width = _fnStringToCss( tableWidthAttr );
- if ( ! oSettings._reszEvt )
- {
- $(window).bind('resize.DT-'+oSettings.sInstance, throttle( function () {
+ if ( ! oSettings._reszEvt ) {
+ $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
_fnAdjustColumnSizing( oSettings );
} ) );
@@ -3689,8 +3588,7 @@
}
- // @todo Move into a private functions file or make a proper DT function of it
- function throttle( fn ) {
+ function _fnThrottle( fn ) {
var
frequency = 200,
last,
@@ -3718,110 +3616,118 @@
/**
- * Adjust a table's width to take account of scrolling
+ * Convert a CSS unit width to pixels (e.g. 2em)
+ * @param {string} width width to be converted
+ * @param {node} parent parent to get the with for (required for relative widths) - optional
+ * @returns {int} width in pixels
+ * @memberof DataTable#oApi
+ */
+ function _fnConvertToWidth ( width, parent )
+ {
+ if ( ! width ) {
+ return 0;
+ }
+
+ var n = $('')
+ .css( 'width', _fnStringToCss( width ) )
+ .appendTo( parent || document.body );
+
+ var val = n[0].offsetWidth;
+ n.remove();
+
+ return val;
+ }
+
+
+ /**
+ * Adjust a table's width to take account of vertical scroll bar
* @param {object} oSettings dataTables settings object
* @param {node} n table node
* @memberof DataTable#oApi
*/
- function _fnScrollingWidthAdjust ( oSettings, n )
+
+ function _fnScrollingWidthAdjust ( settings, n )
{
- if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY !== "" )
- {
- /* When y-scrolling only, we want to remove the width of the scroll bar so the table
- * + scroll bar will fit into the area avaialble.
- */
- var iOrigWidth = $(n).width();
- n.style.width = _fnStringToCss( $(n).outerWidth()-oSettings.oScroll.iBarWidth );
- }
- else if ( oSettings.oScroll.sX !== "" )
- {
- /* When x-scrolling both ways, fix the table at it's current size, without adjusting */
- n.style.width = _fnStringToCss( $(n).outerWidth() );
+ var scroll = settings.oScroll;
+
+ if ( scroll.sX || scroll.sY ) {
+ // When y-scrolling only, we want to remove the width of the scroll bar
+ // so the table + scroll bar will fit into the area available, otherwise
+ // we fix the table at its current size with no adjustment
+ var correction = ! scroll.sX ? scroll.iBarWidth : 0;
+ n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
}
}
/**
* Get the widest node
- * @param {object} oSettings dataTables settings object
- * @param {int} iCol column of interest
+ * @param {object} settings dataTables settings object
+ * @param {int} colIdx column of interest
* @returns {node} widest table node
* @memberof DataTable#oApi
*/
- function _fnGetWidestNode( oSettings, iCol )
+ function _fnGetWidestNode( settings, colIdx )
{
- var iMaxIndex = _fnGetMaxLenString( oSettings, iCol );
- if ( iMaxIndex < 0 )
- {
+ var idx = _fnGetMaxLenString( settings, colIdx );
+ if ( idx < 0 ) {
return null;
}
- var data = oSettings.aoData[ iMaxIndex ];
- return data.nTr === null ? // Might not have been created when deferred rendering
- $(' | ').html( _fnGetCellData( oSettings, iMaxIndex, iCol, 'display' ) )[0] :
- data.anCells[ iCol ];
+ var data = settings.aoData[ idx ];
+ return ! data.nTr ? // Might not have been created when deferred rendering
+ $(' | ').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
+ data.anCells[ colIdx ];
}
- var __re_html_remove = /<.*?>/g;
-
/**
* Get the maximum strlen for each data column
- * @param {object} oSettings dataTables settings object
- * @param {int} iCol column of interest
+ * @param {object} settings dataTables settings object
+ * @param {int} colIdx column of interest
* @returns {string} max string length for each column
* @memberof DataTable#oApi
*/
- function _fnGetMaxLenString( oSettings, iCol )
+ function _fnGetMaxLenString( settings, colIdx )
{
- var s, iMax=-1, iMaxIndex = -1;
+ var s, max=-1, maxIdx = -1;
- for ( var i=0 ; i iMax )
- {
- iMax = s.length;
- iMaxIndex = i;
+ if ( s.length > max ) {
+ max = s.length;
+ maxIdx = i;
}
}
- return iMaxIndex;
+ return maxIdx;
}
/**
* Append a CSS unit (only if required) to a string
- * @param {array} aArray1 first array
- * @param {array} aArray2 second array
- * @returns {int} 0 if match, 1 if length is different, 2 if no match
+ * @param {string} value to css-ify
+ * @returns {string} value with css unit
* @memberof DataTable#oApi
*/
function _fnStringToCss( s )
{
- if ( s === null )
- {
- return "0px";
+ if ( s === null ) {
+ return '0px';
}
- if ( typeof s == 'number' )
- {
- if ( s < 0 )
- {
- return "0px";
- }
- return s+"px";
+ if ( typeof s == 'number' ) {
+ return s < 0 ?
+ '0px' :
+ s+'px';
}
- /* Check if the last character is not 0-9 */
- var c = s.charCodeAt( s.length-1 );
- if (c < 0x30 || c > 0x39)
- {
- return s;
- }
- return s+"px";
+ // Check it has a unit character already
+ return s.match(/\d$/) ?
+ s+'px' :
+ s;
}
@@ -3832,8 +3738,9 @@
*/
function _fnScrollBarWidth ()
{
- if ( ! DataTable.__scrollbarWidth )
- {
+ // On first run a static variable is set, since this is only needed once.
+ // Subsequent runs will just use the previously calculated value
+ if ( ! DataTable.__scrollbarWidth ) {
var inner = $('').css( {
width: '100%',
height: 200,
@@ -3857,8 +3764,8 @@
var w1 = inner.offsetWidth;
outer.css( 'overflow', 'scroll' );
var w2 = inner.offsetWidth;
- if ( w1 === w2 )
- {
+
+ if ( w1 === w2 ) {
w2 = outer[0].clientWidth;
}