mirror of
https://github.com/DataTables/DataTables.git
synced 2025-03-14 15:29:14 +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
17
media/js/jquery.dataTables.js
vendored
17
media/js/jquery.dataTables.js
vendored
@ -3563,25 +3563,24 @@
|
|||||||
*/
|
*/
|
||||||
function _fnConvertToWidth ( sWidth, nParent )
|
function _fnConvertToWidth ( sWidth, nParent )
|
||||||
{
|
{
|
||||||
if ( !sWidth || sWidth === null || sWidth === '' )
|
if ( ! sWidth )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !nParent )
|
if ( ! nParent )
|
||||||
{
|
{
|
||||||
nParent = document.body;
|
nParent = document.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iWidth;
|
var n = $('<div/>')
|
||||||
var nTmp = document.createElement( "div" );
|
.css( 'width', _fnStringToCss( sWidth ) )
|
||||||
nTmp.style.width = _fnStringToCss( sWidth );
|
.appendTo( nParent );
|
||||||
|
|
||||||
nParent.appendChild( nTmp );
|
var width = n.offsetWidth;
|
||||||
iWidth = nTmp.offsetWidth;
|
n.remove();
|
||||||
nParent.removeChild( nTmp );
|
|
||||||
|
|
||||||
return ( iWidth );
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,25 +7,24 @@
|
|||||||
*/
|
*/
|
||||||
function _fnConvertToWidth ( sWidth, nParent )
|
function _fnConvertToWidth ( sWidth, nParent )
|
||||||
{
|
{
|
||||||
if ( !sWidth || sWidth === null || sWidth === '' )
|
if ( ! sWidth )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !nParent )
|
if ( ! nParent )
|
||||||
{
|
{
|
||||||
nParent = document.body;
|
nParent = document.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iWidth;
|
var n = $('<div/>')
|
||||||
var nTmp = document.createElement( "div" );
|
.css( 'width', _fnStringToCss( sWidth ) )
|
||||||
nTmp.style.width = _fnStringToCss( sWidth );
|
.appendTo( nParent );
|
||||||
|
|
||||||
nParent.appendChild( nTmp );
|
var width = n.offsetWidth;
|
||||||
iWidth = nTmp.offsetWidth;
|
n.remove();
|
||||||
nParent.removeChild( nTmp );
|
|
||||||
|
|
||||||
return ( iWidth );
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user