mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-19 12:52:11 +01:00
Dev: Tidying up scrollbar width calcuation function
- Using jQuery we can make the code a bit smaller. Not much, just a 97 byte saving, but every little helps, as they say....
This commit is contained in:
parent
4c4bfb04b8
commit
7c53a1824c
46
media/js/jquery.dataTables.js
vendored
46
media/js/jquery.dataTables.js
vendored
@ -3926,35 +3926,37 @@
|
||||
*/
|
||||
function _fnScrollBarWidth ()
|
||||
{
|
||||
var inner = document.createElement('p');
|
||||
var style = inner.style;
|
||||
style.width = "100%";
|
||||
style.height = "200px";
|
||||
style.padding = "0px";
|
||||
var inner = $('<p/>').css( {
|
||||
width: '100%',
|
||||
height: 200,
|
||||
padding: 0
|
||||
} )[0];
|
||||
|
||||
var outer = document.createElement('div');
|
||||
style = outer.style;
|
||||
style.position = "absolute";
|
||||
style.top = "0px";
|
||||
style.left = "0px";
|
||||
style.visibility = "hidden";
|
||||
style.width = "200px";
|
||||
style.height = "150px";
|
||||
style.padding = "0px";
|
||||
style.overflow = "hidden";
|
||||
outer.appendChild(inner);
|
||||
var outer = $('<div/>')
|
||||
.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 200,
|
||||
height: 150,
|
||||
padding: 0,
|
||||
overflow: 'hidden',
|
||||
visibility: 'hidden'
|
||||
} )
|
||||
.append( inner )
|
||||
.appendTo( 'body' );
|
||||
|
||||
document.body.appendChild(outer);
|
||||
var w1 = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
outer.css( 'overflow', 'scroll' );
|
||||
var w2 = inner.offsetWidth;
|
||||
if ( w1 == w2 )
|
||||
if ( w1 === w2 )
|
||||
{
|
||||
w2 = outer.clientWidth;
|
||||
w2 = outer[0].clientWidth;
|
||||
}
|
||||
|
||||
document.body.removeChild(outer);
|
||||
return (w1 - w2);
|
||||
outer.remove();
|
||||
|
||||
return w1 - w2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,34 +370,36 @@ function _fnStringToCss( s )
|
||||
*/
|
||||
function _fnScrollBarWidth ()
|
||||
{
|
||||
var inner = document.createElement('p');
|
||||
var style = inner.style;
|
||||
style.width = "100%";
|
||||
style.height = "200px";
|
||||
style.padding = "0px";
|
||||
var inner = $('<p/>').css( {
|
||||
width: '100%',
|
||||
height: 200,
|
||||
padding: 0
|
||||
} )[0];
|
||||
|
||||
var outer = document.createElement('div');
|
||||
style = outer.style;
|
||||
style.position = "absolute";
|
||||
style.top = "0px";
|
||||
style.left = "0px";
|
||||
style.visibility = "hidden";
|
||||
style.width = "200px";
|
||||
style.height = "150px";
|
||||
style.padding = "0px";
|
||||
style.overflow = "hidden";
|
||||
outer.appendChild(inner);
|
||||
var outer = $('<div/>')
|
||||
.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 200,
|
||||
height: 150,
|
||||
padding: 0,
|
||||
overflow: 'hidden',
|
||||
visibility: 'hidden'
|
||||
} )
|
||||
.append( inner )
|
||||
.appendTo( 'body' );
|
||||
|
||||
document.body.appendChild(outer);
|
||||
var w1 = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
outer.css( 'overflow', 'scroll' );
|
||||
var w2 = inner.offsetWidth;
|
||||
if ( w1 == w2 )
|
||||
if ( w1 === w2 )
|
||||
{
|
||||
w2 = outer.clientWidth;
|
||||
w2 = outer[0].clientWidth;
|
||||
}
|
||||
|
||||
document.body.removeChild(outer);
|
||||
return (w1 - w2);
|
||||
outer.remove();
|
||||
|
||||
return w1 - w2;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user