mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-20 18:54:15 +01:00
Dev: Trivial tidy up of _fnConvertToWidth
- Just 43 bytes saved, but tidier code and smaller size...
This commit is contained in:
parent
7c53a1824c
commit
a67ff2fadb
19
media/js/jquery.dataTables.js
vendored
19
media/js/jquery.dataTables.js
vendored
@ -3563,25 +3563,24 @@
|
||||
*/
|
||||
function _fnConvertToWidth ( sWidth, nParent )
|
||||
{
|
||||
if ( !sWidth || sWidth === null || sWidth === '' )
|
||||
if ( ! sWidth )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !nParent )
|
||||
if ( ! nParent )
|
||||
{
|
||||
nParent = document.body;
|
||||
}
|
||||
|
||||
var iWidth;
|
||||
var nTmp = document.createElement( "div" );
|
||||
nTmp.style.width = _fnStringToCss( sWidth );
|
||||
var n = $('<div/>')
|
||||
.css( 'width', _fnStringToCss( sWidth ) )
|
||||
.appendTo( nParent );
|
||||
|
||||
var width = n.offsetWidth;
|
||||
n.remove();
|
||||
|
||||
nParent.appendChild( nTmp );
|
||||
iWidth = nTmp.offsetWidth;
|
||||
nParent.removeChild( nTmp );
|
||||
|
||||
return ( iWidth );
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,25 +7,24 @@
|
||||
*/
|
||||
function _fnConvertToWidth ( sWidth, nParent )
|
||||
{
|
||||
if ( !sWidth || sWidth === null || sWidth === '' )
|
||||
if ( ! sWidth )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !nParent )
|
||||
if ( ! nParent )
|
||||
{
|
||||
nParent = document.body;
|
||||
}
|
||||
|
||||
var iWidth;
|
||||
var nTmp = document.createElement( "div" );
|
||||
nTmp.style.width = _fnStringToCss( sWidth );
|
||||
var n = $('<div/>')
|
||||
.css( 'width', _fnStringToCss( sWidth ) )
|
||||
.appendTo( nParent );
|
||||
|
||||
var width = n.offsetWidth;
|
||||
n.remove();
|
||||
|
||||
nParent.appendChild( nTmp );
|
||||
iWidth = nTmp.offsetWidth;
|
||||
nParent.removeChild( nTmp );
|
||||
|
||||
return ( iWidth );
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user