datatables.net-scroller
Advanced tools
Comparing version 1.5.1 to 2.0.0
@@ -1,2 +0,2 @@ | ||
/*! Scroller 1.5.1 | ||
/*! Scroller 2.0.0 | ||
* ©2011-2018 SpryMedia Ltd - datatables.net/license | ||
@@ -8,3 +8,3 @@ */ | ||
* @description Virtual rendering for DataTables | ||
* @version 1.5.1 | ||
* @version 2.0.0 | ||
* @file dataTables.scroller.js | ||
@@ -97,3 +97,3 @@ * @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
* "ajax": "media/dataset/large.txt", | ||
* "dom": "frtiS", | ||
* "scroller": true, | ||
* "deferRender": true | ||
@@ -128,3 +128,3 @@ * } ); | ||
*/ | ||
"dt": dtApi.settings()[0], | ||
dt: dtApi.settings()[0], | ||
@@ -135,3 +135,3 @@ /** | ||
*/ | ||
"dtApi": dtApi, | ||
dtApi: dtApi, | ||
@@ -143,3 +143,3 @@ /** | ||
*/ | ||
"tableTop": 0, | ||
tableTop: 0, | ||
@@ -151,3 +151,3 @@ /** | ||
*/ | ||
"tableBottom": 0, | ||
tableBottom: 0, | ||
@@ -161,3 +161,3 @@ /** | ||
*/ | ||
"redrawTop": 0, | ||
redrawTop: 0, | ||
@@ -172,3 +172,3 @@ /** | ||
*/ | ||
"redrawBottom": 0, | ||
redrawBottom: 0, | ||
@@ -180,3 +180,3 @@ /** | ||
*/ | ||
"autoHeight": true, | ||
autoHeight: true, | ||
@@ -188,3 +188,3 @@ /** | ||
*/ | ||
"viewportRows": 0, | ||
viewportRows: 0, | ||
@@ -198,3 +198,3 @@ /** | ||
*/ | ||
"stateTO": null, | ||
stateTO: null, | ||
@@ -207,3 +207,3 @@ /** | ||
*/ | ||
"drawTO": null, | ||
drawTO: null, | ||
@@ -228,3 +228,4 @@ heights: { | ||
*/ | ||
viewport: null | ||
viewport: null, | ||
labelFactor: 1 | ||
}, | ||
@@ -235,3 +236,7 @@ | ||
loaderVisible: false, | ||
forceReposition: false | ||
forceReposition: false, | ||
baseRowTop: 0, | ||
baseScrollTop: 0, | ||
mousedown: false, | ||
lastScrollTop: 0 | ||
}; | ||
@@ -254,2 +259,3 @@ | ||
"force": document.createElement('div'), | ||
"label": $('<div class="dts_label">0</div>'), | ||
"scroller": null, | ||
@@ -269,3 +275,3 @@ "table": null, | ||
/* Let's do it */ | ||
this._fnConstruct(); | ||
this.construct(); | ||
}; | ||
@@ -277,44 +283,70 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Public methods | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
* Public methods - to be exposed via the DataTables API | ||
*/ | ||
/** | ||
* Calculate the pixel position from the top of the scrolling container for | ||
* a given row | ||
* @param {int} iRow Row number to calculate the position of | ||
* @returns {int} Pixels | ||
* @example | ||
* $(document).ready(function() { | ||
* $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sAjaxSource": "media/dataset/large.txt", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "fnInitComplete": function (o) { | ||
* // Find where row 25 is | ||
* alert( o.oScroller.fnRowToPixels( 25 ) ); | ||
* } | ||
* } ); | ||
* } ); | ||
* Calculate and store information about how many rows are to be displayed | ||
* in the scrolling viewport, based on current dimensions in the browser's | ||
* rendering. This can be particularly useful if the table is initially | ||
* drawn in a hidden element - for example in a tab. | ||
* @param {bool} [redraw=true] Redraw the table automatically after the recalculation, with | ||
* the new dimensions forming the basis for the draw. | ||
* @returns {void} | ||
*/ | ||
"fnRowToPixels": function ( rowIdx, intParse, virtual ) | ||
measure: function ( redraw ) | ||
{ | ||
var pixels; | ||
var diff = rowIdx - this.s.baseRowTop; | ||
if ( this.s.autoHeight ) | ||
{ | ||
this._calcRowHeight(); | ||
} | ||
if ( virtual ) { | ||
pixels = this._domain( 'virtualToPhysical', this.s.baseScrollTop ); | ||
pixels += diff * this.s.heights.row; | ||
var heights = this.s.heights; | ||
if ( heights.row ) { | ||
heights.viewport = $.contains(document, this.dom.scroller) ? | ||
this.dom.scroller.clientHeight : | ||
this._parseHeight($(this.dom.scroller).css('height')); | ||
// If collapsed (no height) use the max-height parameter | ||
if ( ! heights.viewport ) { | ||
heights.viewport = this._parseHeight($(this.dom.scroller).css('max-height')); | ||
} | ||
this.s.viewportRows = parseInt( heights.viewport / heights.row, 10 )+1; | ||
this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer; | ||
} | ||
else { | ||
pixels = this.s.baseScrollTop; | ||
pixels += diff * this.s.heights.row; | ||
var label = this.dom.label.outerHeight(); | ||
heights.labelFactor = (heights.viewport-label) / heights.scroll; | ||
if ( redraw === undefined || redraw ) | ||
{ | ||
this.s.dt.oInstance.fnDraw( false ); | ||
} | ||
}, | ||
return intParse || intParse === undefined ? | ||
parseInt( pixels, 10 ) : | ||
pixels; | ||
/** | ||
* Get information about current displayed record range. This corresponds to | ||
* the information usually displayed in the "Info" block of the table. | ||
* | ||
* @returns {object} info as an object: | ||
* { | ||
* start: {int}, // the 0-indexed record at the top of the viewport | ||
* end: {int}, // the 0-indexed record at the bottom of the viewport | ||
* } | ||
*/ | ||
pageInfo: function() | ||
{ | ||
var | ||
dt = this.s.dt, | ||
iScrollTop = this.dom.scroller.scrollTop, | ||
iTotal = dt.fnRecordsDisplay(), | ||
iPossibleEnd = Math.ceil(this.pixelsToRow(iScrollTop + this.s.heights.viewport, false, this.s.ani)); | ||
return { | ||
start: Math.floor(this.pixelsToRow(iScrollTop, false, this.s.ani)), | ||
end: iTotal < iPossibleEnd ? iTotal-1 : iPossibleEnd-1 | ||
}; | ||
}, | ||
/** | ||
@@ -328,21 +360,8 @@ * Calculate the row number that will be found at the given pixel position | ||
* value (relative to the last non-linear positioning). | ||
* @param {int} iPixels Offset from top to calculate the row number of | ||
* @param {int} pixels Offset from top to calculate the row number of | ||
* @param {int} [intParse=true] If an integer value should be returned | ||
* @param {int} [virtual=false] Perform the calculations in the virtual domain | ||
* @returns {int} Row index | ||
* @example | ||
* $(document).ready(function() { | ||
* $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sAjaxSource": "media/dataset/large.txt", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "fnInitComplete": function (o) { | ||
* // Find what row number is at 500px | ||
* alert( o.oScroller.fnPixelsToRow( 500 ) ); | ||
* } | ||
* } ); | ||
* } ); | ||
*/ | ||
"fnPixelsToRow": function ( pixels, intParse, virtual ) | ||
pixelsToRow: function ( pixels, intParse, virtual ) | ||
{ | ||
@@ -359,31 +378,39 @@ var diff = pixels - this.s.baseScrollTop; | ||
/** | ||
* Calculate the pixel position from the top of the scrolling container for | ||
* a given row | ||
* @param {int} iRow Row number to calculate the position of | ||
* @returns {int} Pixels | ||
*/ | ||
rowToPixels: function ( rowIdx, intParse, virtual ) | ||
{ | ||
var pixels; | ||
var diff = rowIdx - this.s.baseRowTop; | ||
if ( virtual ) { | ||
pixels = this._domain( 'virtualToPhysical', this.s.baseScrollTop ); | ||
pixels += diff * this.s.heights.row; | ||
} | ||
else { | ||
pixels = this.s.baseScrollTop; | ||
pixels += diff * this.s.heights.row; | ||
} | ||
return intParse || intParse === undefined ? | ||
parseInt( pixels, 10 ) : | ||
pixels; | ||
}, | ||
/** | ||
* Calculate the row number that will be found at the given pixel position (y-scroll) | ||
* @param {int} iRow Row index to scroll to | ||
* @param {bool} [bAnimate=true] Animate the transition or not | ||
* @param {int} row Row index to scroll to | ||
* @param {bool} [animate=true] Animate the transition or not | ||
* @returns {void} | ||
* @example | ||
* $(document).ready(function() { | ||
* $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sAjaxSource": "media/dataset/large.txt", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "fnInitComplete": function (o) { | ||
* // Immediately scroll to row 1000 | ||
* o.oScroller.fnScrollToRow( 1000 ); | ||
* } | ||
* } ); | ||
* | ||
* // Sometime later on use the following to scroll to row 500... | ||
* var oSettings = $('#example').dataTable().fnSettings(); | ||
* oSettings.oScroller.fnScrollToRow( 500 ); | ||
* } ); | ||
*/ | ||
"fnScrollToRow": function ( iRow, bAnimate ) | ||
scrollToRow: function ( row, animate ) | ||
{ | ||
var that = this; | ||
var ani = false; | ||
var px = this.fnRowToPixels( iRow ); | ||
var px = this.rowToPixels( row ); | ||
@@ -396,3 +423,3 @@ // We need to know if the table will redraw or not before doing the | ||
var preRows = ((this.s.displayBuffer-1)/2) * this.s.viewportRows; | ||
var drawRow = iRow - preRows; | ||
var drawRow = row - preRows; | ||
if ( drawRow < 0 ) { | ||
@@ -404,3 +431,3 @@ drawRow = 0; | ||
ani = true; | ||
px = this._domain( 'virtualToPhysical', iRow * this.s.heights.row ); | ||
px = this._domain( 'virtualToPhysical', row * this.s.heights.row ); | ||
@@ -412,7 +439,7 @@ // If we need records outside the current draw region, but the new | ||
this.s.forceReposition = true; | ||
bAnimate = false; | ||
animate = false; | ||
} | ||
} | ||
if ( typeof bAnimate == 'undefined' || bAnimate ) | ||
if ( typeof animate == 'undefined' || animate ) | ||
{ | ||
@@ -437,91 +464,7 @@ this.s.ani = ani; | ||
/** | ||
* Calculate and store information about how many rows are to be displayed | ||
* in the scrolling viewport, based on current dimensions in the browser's | ||
* rendering. This can be particularly useful if the table is initially | ||
* drawn in a hidden element - for example in a tab. | ||
* @param {bool} [bRedraw=true] Redraw the table automatically after the recalculation, with | ||
* the new dimensions forming the basis for the draw. | ||
* @returns {void} | ||
* @example | ||
* $(document).ready(function() { | ||
* // Make the example container hidden to throw off the browser's sizing | ||
* document.getElementById('container').style.display = "none"; | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sAjaxSource": "media/dataset/large.txt", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "fnInitComplete": function (o) { | ||
* // Immediately scroll to row 1000 | ||
* o.oScroller.fnScrollToRow( 1000 ); | ||
* } | ||
* } ); | ||
* | ||
* setTimeout( function () { | ||
* // Make the example container visible and recalculate the scroller sizes | ||
* document.getElementById('container').style.display = "block"; | ||
* oTable.fnSettings().oScroller.fnMeasure(); | ||
* }, 3000 ); | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Constructor | ||
*/ | ||
"fnMeasure": function ( bRedraw ) | ||
{ | ||
if ( this.s.autoHeight ) | ||
{ | ||
this._fnCalcRowHeight(); | ||
} | ||
var heights = this.s.heights; | ||
if ( heights.row ) { | ||
heights.viewport = $.contains(document, this.dom.scroller) ? | ||
$(this.dom.scroller).height() : | ||
this._parseHeight($(this.dom.scroller).css('height')); | ||
// If collapsed (no height) use the max-height parameter | ||
if ( ! heights.viewport ) { | ||
heights.viewport = this._parseHeight($(this.dom.scroller).css('max-height')); | ||
} | ||
this.s.viewportRows = parseInt( heights.viewport / heights.row, 10 )+1; | ||
this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer; | ||
} | ||
if ( bRedraw === undefined || bRedraw ) | ||
{ | ||
this.s.dt.oInstance.fnDraw( false ); | ||
} | ||
}, | ||
/** | ||
* Get information about current displayed record range. This corresponds to | ||
* the information usually displayed in the "Info" block of the table. | ||
* | ||
* @returns {object} info as an object: | ||
* { | ||
* start: {int}, // the 0-indexed record at the top of the viewport | ||
* end: {int}, // the 0-indexed record at the bottom of the viewport | ||
* } | ||
*/ | ||
"fnPageInfo": function() | ||
{ | ||
var | ||
dt = this.s.dt, | ||
iScrollTop = this.dom.scroller.scrollTop, | ||
iTotal = dt.fnRecordsDisplay(), | ||
iPossibleEnd = Math.ceil(this.fnPixelsToRow(iScrollTop + this.s.heights.viewport, false, this.s.ani)); | ||
return { | ||
start: Math.floor(this.fnPixelsToRow(iScrollTop, false, this.s.ani)), | ||
end: iTotal < iPossibleEnd ? iTotal-1 : iPossibleEnd-1 | ||
}; | ||
}, | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Private methods (they are of course public in JS, but recommended as private) | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
/** | ||
* Initialisation for Scroller | ||
@@ -531,3 +474,3 @@ * @returns {void} | ||
*/ | ||
"_fnConstruct": function () | ||
construct: function () | ||
{ | ||
@@ -561,3 +504,3 @@ var that = this; | ||
// Add class to 'announce' that we are a Scroller table | ||
$(dt.table().container()).addClass('DTS'); | ||
$(dt.table().container()).addClass('dts DTS'); | ||
@@ -567,3 +510,3 @@ // Add a 'loading' indicator | ||
{ | ||
this.dom.loader = $('<div class="dataTables_processing DTS_Loading">'+this.s.dt.oLanguage.sLoadingRecords+'</div>') | ||
this.dom.loader = $('<div class="dataTables_processing dts_loading">'+this.s.dt.oLanguage.sLoadingRecords+'</div>') | ||
.css('display', 'none'); | ||
@@ -576,2 +519,4 @@ | ||
this.dom.label.appendTo(this.dom.scroller); | ||
/* Initial size calculations */ | ||
@@ -582,3 +527,3 @@ if ( this.s.heights.row && this.s.heights.row != 'auto' ) | ||
} | ||
this.fnMeasure( false ); | ||
this.measure( false ); | ||
@@ -593,3 +538,3 @@ // Scrolling callback to see if a page change is needed - use a throttled | ||
$(this.dom.scroller).on( 'scroll.dt-scroller', function (e) { | ||
that._fnScroll.call( that ); | ||
that._scroll.call( that ); | ||
} ); | ||
@@ -600,9 +545,18 @@ | ||
$(this.dom.scroller).on('touchstart.dt-scroller', function () { | ||
that._fnScroll.call( that ); | ||
that._scroll.call( that ); | ||
} ); | ||
$(this.dom.scroller) | ||
.on('mousedown.dt-scroller', function () { | ||
that.s.mousedown = true; | ||
}) | ||
.on('mouseup.dt-scroller', function () { | ||
that.s.mouseup = false; | ||
that.dom.label.css('display', 'none'); | ||
}); | ||
// On resize, update the information element, since the number of rows shown might change | ||
$(window).on( 'resize.dt-scroller', function () { | ||
that.fnMeasure( false ); | ||
that._fnInfo(); | ||
that.measure( false ); | ||
that._info(); | ||
} ); | ||
@@ -637,9 +591,9 @@ | ||
dt.on( 'init.scroller', function () { | ||
that.fnMeasure( false ); | ||
that.measure( false ); | ||
that._fnDrawCallback(); | ||
that._draw(); | ||
// Update the scroller when the DataTable is redrawn | ||
dt.on( 'draw.scroller', function () { | ||
that._fnDrawCallback(); | ||
that._draw(); | ||
}); | ||
@@ -651,3 +605,3 @@ } ); | ||
dt.on( 'preDraw.dt.scroller', function () { | ||
that._fnScrollForce(); | ||
that._scrollForce(); | ||
} ); | ||
@@ -671,214 +625,59 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Private methods | ||
*/ | ||
/** | ||
* Scrolling function - fired whenever the scrolling position is changed. | ||
* This method needs to use the stored values to see if the table should be | ||
* redrawn as we are moving towards the end of the information that is | ||
* currently drawn or not. If needed, then it will redraw the table based on | ||
* the new position. | ||
* Automatic calculation of table row height. This is just a little tricky here as using | ||
* initialisation DataTables has tale the table out of the document, so we need to create | ||
* a new table and insert it into the document, calculate the row height and then whip the | ||
* table out. | ||
* @returns {void} | ||
* @private | ||
*/ | ||
"_fnScroll": function () | ||
_calcRowHeight: function () | ||
{ | ||
var | ||
that = this, | ||
heights = this.s.heights, | ||
iScrollTop = this.dom.scroller.scrollTop, | ||
iTopRow; | ||
var dt = this.s.dt; | ||
var origTable = dt.nTable; | ||
var nTable = origTable.cloneNode( false ); | ||
var tbody = $('<tbody/>').appendTo( nTable ); | ||
var container = $( | ||
'<div class="'+dt.oClasses.sWrapper+' DTS">'+ | ||
'<div class="'+dt.oClasses.sScrollWrapper+'">'+ | ||
'<div class="'+dt.oClasses.sScrollBody+'"></div>'+ | ||
'</div>'+ | ||
'</div>' | ||
); | ||
if ( this.s.skip ) { | ||
return; | ||
} | ||
// Want 3 rows in the sizing table so :first-child and :last-child | ||
// CSS styles don't come into play - take the size of the middle row | ||
$('tbody tr:lt(4)', origTable).clone().appendTo( tbody ); | ||
var rowsCount = $('tr', tbody).length; | ||
if ( this.s.ingnoreScroll ) { | ||
return; | ||
if ( rowsCount === 1 ) { | ||
tbody.prepend('<tr><td> </td></tr>'); | ||
tbody.append('<tr><td> </td></tr>'); | ||
} | ||
/* If the table has been sorted or filtered, then we use the redraw that | ||
* DataTables as done, rather than performing our own | ||
*/ | ||
if ( this.s.dt.bFiltered || this.s.dt.bSorted ) { | ||
this.s.lastScrollTop = 0; | ||
return; | ||
} | ||
/* Update the table's information display for what is now in the viewport */ | ||
this._fnInfo(); | ||
/* We don't want to state save on every scroll event - that's heavy | ||
* handed, so use a timeout to update the state saving only when the | ||
* scrolling has finished | ||
*/ | ||
clearTimeout( this.s.stateTO ); | ||
this.s.stateTO = setTimeout( function () { | ||
that.s.dtApi.state.save(); | ||
}, 250 ); | ||
/* Check if the scroll point is outside the trigger boundary which would required | ||
* a DataTables redraw | ||
*/ | ||
if ( this.s.forceReposition || iScrollTop < this.s.redrawTop || iScrollTop > this.s.redrawBottom ) { | ||
var preRows = Math.ceil( ((this.s.displayBuffer-1)/2) * this.s.viewportRows ); | ||
iTopRow = parseInt(this._domain( 'physicalToVirtual', iScrollTop ) / heights.row, 10) - preRows; | ||
this.s.topRowFloat = this._domain( 'physicalToVirtual', iScrollTop ) / heights.row; | ||
this.s.forceReposition = false; | ||
if ( iTopRow <= 0 ) { | ||
/* At the start of the table */ | ||
iTopRow = 0; | ||
} | ||
else if ( iTopRow + this.s.dt._iDisplayLength > this.s.dt.fnRecordsDisplay() ) { | ||
/* At the end of the table */ | ||
iTopRow = this.s.dt.fnRecordsDisplay() - this.s.dt._iDisplayLength; | ||
if ( iTopRow < 0 ) { | ||
iTopRow = 0; | ||
} | ||
} | ||
else if ( iTopRow % 2 !== 0 ) { | ||
// For the row-striping classes (odd/even) we want only to start | ||
// on evens otherwise the stripes will change between draws and | ||
// look rubbish | ||
iTopRow++; | ||
} | ||
if ( iTopRow != this.s.dt._iDisplayStart ) { | ||
/* Cache the new table position for quick lookups */ | ||
this.s.tableTop = $(this.s.dt.nTable).offset().top; | ||
this.s.tableBottom = $(this.s.dt.nTable).height() + this.s.tableTop; | ||
var draw = function () { | ||
if ( that.s.scrollDrawReq === null ) { | ||
that.s.scrollDrawReq = iScrollTop; | ||
} | ||
that.s.dt._iDisplayStart = iTopRow; | ||
that.s.dt.oApi._fnDraw( that.s.dt ); | ||
}; | ||
/* Do the DataTables redraw based on the calculated start point - note that when | ||
* using server-side processing we introduce a small delay to not DoS the server... | ||
*/ | ||
if ( this.s.dt.oFeatures.bServerSide ) { | ||
clearTimeout( this.s.drawTO ); | ||
this.s.drawTO = setTimeout( draw, this.s.serverWait ); | ||
} | ||
else { | ||
draw(); | ||
} | ||
if ( this.dom.loader && ! this.s.loaderVisible ) { | ||
this.dom.loader.css( 'display', 'block' ); | ||
this.s.loaderVisible = true; | ||
} | ||
} | ||
} | ||
else { | ||
this.s.topRowFloat = this.fnPixelsToRow( iScrollTop, false, true ); | ||
for (; rowsCount < 3; rowsCount++) { | ||
tbody.append('<tr><td> </td></tr>'); | ||
} | ||
} | ||
$('div.'+dt.oClasses.sScrollBody, container).append( nTable ); | ||
this.s.lastScrollTop = iScrollTop; | ||
this.s.stateSaveThrottle(); | ||
}, | ||
// If initialised using `dom`, use the holding element as the insert point | ||
var insertEl = this.s.dt.nHolding || origTable.parentNode; | ||
/** | ||
* Convert from one domain to another. The physical domain is the actual | ||
* pixel count on the screen, while the virtual is if we had browsers which | ||
* had scrolling containers of infinite height (i.e. the absolute value) | ||
* | ||
* @param {string} dir Domain transform direction, `virtualToPhysical` or | ||
* `physicalToVirtual` | ||
* @returns {number} Calculated transform | ||
* @private | ||
*/ | ||
_domain: function ( dir, val ) | ||
{ | ||
var heights = this.s.heights; | ||
var coeff; | ||
// If the virtual and physical height match, then we use a linear | ||
// transform between the two, allowing the scrollbar to be linear | ||
if ( heights.virtual === heights.scroll ) { | ||
return val; | ||
if ( ! $(insertEl).is(':visible') ) { | ||
insertEl = 'body'; | ||
} | ||
// Otherwise, we want a non-linear scrollbar to take account of the | ||
// redrawing regions at the start and end of the table, otherwise these | ||
// can stutter badly - on large tables 30px (for example) scroll might | ||
// be hundreds of rows, so the table would be redrawing every few px at | ||
// the start and end. Use a simple quadratic to stop this. It does mean | ||
// the scrollbar is non-linear, but with such massive data sets, the | ||
// scrollbar is going to be a best guess anyway | ||
var xMax = (heights.scroll - heights.viewport) / 2; | ||
var yMax = (heights.virtual - heights.viewport) / 2; | ||
container.appendTo( insertEl ); | ||
this.s.heights.row = $('tr', tbody).eq(1).outerHeight(); | ||
coeff = yMax / ( xMax * xMax ); | ||
if ( dir === 'virtualToPhysical' ) { | ||
if ( val < yMax ) { | ||
return Math.pow(val / coeff, 0.5); | ||
} | ||
else { | ||
val = (yMax*2) - val; | ||
return val < 0 ? | ||
heights.scroll : | ||
(xMax*2) - Math.pow(val / coeff, 0.5); | ||
} | ||
} | ||
else if ( dir === 'physicalToVirtual' ) { | ||
if ( val < xMax ) { | ||
return val * val * coeff; | ||
} | ||
else { | ||
val = (xMax*2) - val; | ||
return val < 0 ? | ||
heights.virtual : | ||
(yMax*2) - (val * val * coeff); | ||
} | ||
} | ||
container.remove(); | ||
}, | ||
/** | ||
* Parse CSS height property string as number | ||
* | ||
* An attempt is made to parse the string as a number. Currently supported units are 'px', | ||
* 'vh', and 'rem'. 'em' is partially supported; it works as long as the parent element's | ||
* font size matches the body element. Zero is returned for unrecognized strings. | ||
* @param {string} cssHeight CSS height property string | ||
* @returns {number} height | ||
* @private | ||
*/ | ||
_parseHeight: function(cssHeight) { | ||
var height; | ||
var matches = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(cssHeight); | ||
if (matches === null) { | ||
return 0; | ||
} | ||
var value = parseFloat(matches[1]); | ||
var unit = matches[2]; | ||
if ( unit === 'px' ) { | ||
height = value; | ||
} | ||
else if ( unit === 'vh' ) { | ||
height = ( value / 100 ) * $(window).height(); | ||
} | ||
else if ( unit === 'rem' ) { | ||
height = value * parseFloat($(':root').css('font-size')); | ||
} | ||
else if ( unit === 'em' ) { | ||
height = value * parseFloat($('body').css('font-size')); | ||
} | ||
return height ? | ||
height : | ||
0; | ||
}, | ||
/** | ||
* Draw callback function which is fired when the DataTable is redrawn. The main function of | ||
@@ -890,3 +689,3 @@ * this method is to position the drawn table correctly the scrolling container for the rows | ||
*/ | ||
"_fnDrawCallback": function () | ||
_draw: function () | ||
{ | ||
@@ -908,21 +707,12 @@ var | ||
// If paging is reset | ||
if ( (this.s.dt.bSorted || this.s.dt.bFiltered) && displayStart === 0 ) { | ||
if ( (this.s.dt.bSorted || this.s.dt.bFiltered) && displayStart === 0 && !this.s.dt._drawHold ) { | ||
this.s.topRowFloat = 0; | ||
} | ||
// Reposition the scrolling for the updated virtual position if needed | ||
if ( displayStart === 0 ) { | ||
// Linear calculation at the top of the table | ||
iScrollTop = this.s.topRowFloat * heights.row; | ||
} | ||
else if ( displayStart + displayLen >= displayEnd ) { | ||
// Linear calculation that the bottom as well | ||
iScrollTop = heights.scroll - ((displayEnd - this.s.topRowFloat) * heights.row); | ||
} | ||
else { | ||
// Domain scaled in the middle | ||
iScrollTop = this._domain( 'virtualToPhysical', this.s.topRowFloat * heights.row ); | ||
} | ||
iScrollTop = this.scrollType === 'jump' ? | ||
this._domain( 'physicalToVirtual', this.s.topRowFloat * heights.row ) : | ||
iScrollTop; | ||
this.dom.scroller.scrollTop = iScrollTop; | ||
// This doesn't work when scrolling with the mouse wheel | ||
$(that.dom.scroller).scrollTop(iScrollTop); | ||
@@ -995,3 +785,3 @@ // Store positional information so positional calculations can be based | ||
setTimeout( function () { | ||
that._fnInfo.call( that ); | ||
that._info.call( that ); | ||
}, 0 ); | ||
@@ -1007,79 +797,60 @@ } | ||
/** | ||
* Force the scrolling container to have height beyond that of just the | ||
* table that has been drawn so the user can scroll the whole data set. | ||
* Convert from one domain to another. The physical domain is the actual | ||
* pixel count on the screen, while the virtual is if we had browsers which | ||
* had scrolling containers of infinite height (i.e. the absolute value) | ||
* | ||
* Note that if the calculated required scrolling height exceeds a maximum | ||
* value (1 million pixels - hard-coded) the forcing element will be set | ||
* only to that maximum value and virtual / physical domain transforms will | ||
* be used to allow Scroller to display tables of any number of records. | ||
* @returns {void} | ||
* @param {string} dir Domain transform direction, `virtualToPhysical` or | ||
* `physicalToVirtual` | ||
* @returns {number} Calculated transform | ||
* @private | ||
*/ | ||
_fnScrollForce: function () | ||
_domain: function ( dir, val ) | ||
{ | ||
var heights = this.s.heights; | ||
var max = 1000000; | ||
var diff; | ||
var magic = 10000; // the point at which the non-linear calculations start to happen | ||
heights.virtual = heights.row * this.s.dt.fnRecordsDisplay(); | ||
heights.scroll = heights.virtual; | ||
if ( heights.scroll > max ) { | ||
heights.scroll = max; | ||
// If the virtual and physical height match, then we use a linear | ||
// transform between the two, allowing the scrollbar to be linear | ||
if ( heights.virtual === heights.scroll ) { | ||
return val; | ||
} | ||
// Minimum height so there is always a row visible (the 'no rows found' | ||
// if reduced to zero filtering) | ||
this.dom.force.style.height = heights.scroll > this.s.heights.row ? | ||
heights.scroll+'px' : | ||
this.s.heights.row+'px'; | ||
}, | ||
/** | ||
* Automatic calculation of table row height. This is just a little tricky here as using | ||
* initialisation DataTables has tale the table out of the document, so we need to create | ||
* a new table and insert it into the document, calculate the row height and then whip the | ||
* table out. | ||
* @returns {void} | ||
* @private | ||
*/ | ||
"_fnCalcRowHeight": function () | ||
{ | ||
var dt = this.s.dt; | ||
var origTable = dt.nTable; | ||
var nTable = origTable.cloneNode( false ); | ||
var tbody = $('<tbody/>').appendTo( nTable ); | ||
var container = $( | ||
'<div class="'+dt.oClasses.sWrapper+' DTS">'+ | ||
'<div class="'+dt.oClasses.sScrollWrapper+'">'+ | ||
'<div class="'+dt.oClasses.sScrollBody+'"></div>'+ | ||
'</div>'+ | ||
'</div>' | ||
); | ||
// Want 3 rows in the sizing table so :first-child and :last-child | ||
// CSS styles don't come into play - take the size of the middle row | ||
$('tbody tr:lt(4)', origTable).clone().appendTo( tbody ); | ||
while( $('tr', tbody).length < 3 ) { | ||
tbody.append( '<tr><td> </td></tr>' ); | ||
// In the first 10k pixels and the last 10k pixels, we want the scrolling | ||
// to be linear. After that it can be non-linear. It would be unusual for | ||
// anyone to mouse wheel through that much. | ||
if ( val < magic ) { | ||
return val; | ||
} | ||
else if ( dir === 'virtualToPhysical' && val > heights.virtual - magic ) { | ||
diff = heights.virtual - val; | ||
return heights.scroll - diff; | ||
} | ||
else if ( dir === 'physicalToVirtual' && val > heights.scroll - magic ) { | ||
diff = heights.scroll - val; | ||
return heights.virtual - diff; | ||
} | ||
$('div.'+dt.oClasses.sScrollBody, container).append( nTable ); | ||
// Otherwise, we want a non-linear scrollbar to take account of the | ||
// redrawing regions at the start and end of the table, otherwise these | ||
// can stutter badly - on large tables 30px (for example) scroll might | ||
// be hundreds of rows, so the table would be redrawing every few px at | ||
// the start and end. Use a simple linear eq. to stop this, effectively | ||
// causing a kink in the scrolling ratio. It does mean the scrollbar is | ||
// non-linear, but with such massive data sets, the scrollbar is going | ||
// to be a best guess anyway | ||
var xMax = dir === 'virtualToPhysical' ? | ||
heights.virtual : | ||
heights.scroll; | ||
var yMax = dir === 'virtualToPhysical' ? | ||
heights.scroll : | ||
heights.virtual; | ||
// If initialised using `dom`, use the holding element as the insert point | ||
var insertEl = this.s.dt.nHolding || origTable.parentNode; | ||
var m = (yMax - magic) / (xMax - magic); | ||
var c = magic - (m*magic); | ||
if ( ! $(insertEl).is(':visible') ) { | ||
insertEl = 'body'; | ||
} | ||
container.appendTo( insertEl ); | ||
this.s.heights.row = $('tr', tbody).eq(1).outerHeight(); | ||
container.remove(); | ||
return (m*val) + c; | ||
}, | ||
/** | ||
@@ -1092,3 +863,3 @@ * Update any information elements that are controlled by the DataTable based on the scrolling | ||
*/ | ||
"_fnInfo": function () | ||
_info: function () | ||
{ | ||
@@ -1104,6 +875,6 @@ if ( !this.s.dt.oFeatures.bInfo ) | ||
iScrollTop = this.dom.scroller.scrollTop, | ||
iStart = Math.floor( this.fnPixelsToRow(iScrollTop, false, this.s.ani)+1 ), | ||
iStart = Math.floor( this.pixelsToRow(iScrollTop, false, this.s.ani)+1 ), | ||
iMax = dt.fnRecordsTotal(), | ||
iTotal = dt.fnRecordsDisplay(), | ||
iPossibleEnd = Math.ceil( this.fnPixelsToRow(iScrollTop+this.s.heights.viewport, false, this.s.ani) ), | ||
iPossibleEnd = Math.ceil( this.pixelsToRow(iScrollTop+this.s.heights.viewport, false, this.s.ani) ), | ||
iEnd = iTotal < iPossibleEnd ? iTotal : iPossibleEnd, | ||
@@ -1172,2 +943,206 @@ sStart = dt.fnFormatNumber( iStart ), | ||
$(dt.nTable).triggerHandler( 'info.dt' ); | ||
}, | ||
/** | ||
* Parse CSS height property string as number | ||
* | ||
* An attempt is made to parse the string as a number. Currently supported units are 'px', | ||
* 'vh', and 'rem'. 'em' is partially supported; it works as long as the parent element's | ||
* font size matches the body element. Zero is returned for unrecognized strings. | ||
* @param {string} cssHeight CSS height property string | ||
* @returns {number} height | ||
* @private | ||
*/ | ||
_parseHeight: function(cssHeight) { | ||
var height; | ||
var matches = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(cssHeight); | ||
if (matches === null) { | ||
return 0; | ||
} | ||
var value = parseFloat(matches[1]); | ||
var unit = matches[2]; | ||
if ( unit === 'px' ) { | ||
height = value; | ||
} | ||
else if ( unit === 'vh' ) { | ||
height = ( value / 100 ) * $(window).height(); | ||
} | ||
else if ( unit === 'rem' ) { | ||
height = value * parseFloat($(':root').css('font-size')); | ||
} | ||
else if ( unit === 'em' ) { | ||
height = value * parseFloat($('body').css('font-size')); | ||
} | ||
return height ? | ||
height : | ||
0; | ||
}, | ||
/** | ||
* Scrolling function - fired whenever the scrolling position is changed. | ||
* This method needs to use the stored values to see if the table should be | ||
* redrawn as we are moving towards the end of the information that is | ||
* currently drawn or not. If needed, then it will redraw the table based on | ||
* the new position. | ||
* @returns {void} | ||
* @private | ||
*/ | ||
_scroll: function () | ||
{ | ||
var | ||
that = this, | ||
heights = this.s.heights, | ||
iScrollTop = this.dom.scroller.scrollTop, | ||
iTopRow; | ||
if ( this.s.skip ) { | ||
return; | ||
} | ||
if ( this.s.ingnoreScroll ) { | ||
return; | ||
} | ||
if ( iScrollTop === this.s.lastScrollTop ) { | ||
return; | ||
} | ||
/* If the table has been sorted or filtered, then we use the redraw that | ||
* DataTables as done, rather than performing our own | ||
*/ | ||
if ( this.s.dt.bFiltered || this.s.dt.bSorted ) { | ||
this.s.lastScrollTop = 0; | ||
return; | ||
} | ||
/* Update the table's information display for what is now in the viewport */ | ||
this._info(); | ||
/* We don't want to state save on every scroll event - that's heavy | ||
* handed, so use a timeout to update the state saving only when the | ||
* scrolling has finished | ||
*/ | ||
clearTimeout( this.s.stateTO ); | ||
this.s.stateTO = setTimeout( function () { | ||
that.s.dtApi.state.save(); | ||
}, 250 ); | ||
this.s.scrollType = Math.abs(iScrollTop - this.s.lastScrollTop) > heights.viewport ? | ||
'jump' : | ||
'cont'; | ||
this.s.topRowFloat = this.s.scrollType === 'cont' ? | ||
this.pixelsToRow( iScrollTop, false, false ) : | ||
this._domain( 'physicalToVirtual', iScrollTop ) / heights.row; | ||
if ( this.s.topRowFloat < 0 ) { | ||
this.s.topRowFloat = 0; | ||
} | ||
/* Check if the scroll point is outside the trigger boundary which would required | ||
* a DataTables redraw | ||
*/ | ||
if ( this.s.forceReposition || iScrollTop < this.s.redrawTop || iScrollTop > this.s.redrawBottom ) { | ||
var preRows = Math.ceil( ((this.s.displayBuffer-1)/2) * this.s.viewportRows ); | ||
iTopRow = parseInt(this.s.topRowFloat, 10) - preRows; | ||
this.s.forceReposition = false; | ||
if ( iTopRow <= 0 ) { | ||
/* At the start of the table */ | ||
iTopRow = 0; | ||
} | ||
else if ( iTopRow + this.s.dt._iDisplayLength > this.s.dt.fnRecordsDisplay() ) { | ||
/* At the end of the table */ | ||
iTopRow = this.s.dt.fnRecordsDisplay() - this.s.dt._iDisplayLength; | ||
if ( iTopRow < 0 ) { | ||
iTopRow = 0; | ||
} | ||
} | ||
else if ( iTopRow % 2 !== 0 ) { | ||
// For the row-striping classes (odd/even) we want only to start | ||
// on evens otherwise the stripes will change between draws and | ||
// look rubbish | ||
iTopRow++; | ||
} | ||
if ( iTopRow != this.s.dt._iDisplayStart ) { | ||
/* Cache the new table position for quick lookups */ | ||
this.s.tableTop = $(this.s.dt.nTable).offset().top; | ||
this.s.tableBottom = $(this.s.dt.nTable).height() + this.s.tableTop; | ||
var draw = function () { | ||
if ( that.s.scrollDrawReq === null ) { | ||
that.s.scrollDrawReq = iScrollTop; | ||
} | ||
that.s.dt._iDisplayStart = iTopRow; | ||
that.s.dt.oApi._fnDraw( that.s.dt ); | ||
}; | ||
/* Do the DataTables redraw based on the calculated start point - note that when | ||
* using server-side processing we introduce a small delay to not DoS the server... | ||
*/ | ||
if ( this.s.dt.oFeatures.bServerSide ) { | ||
clearTimeout( this.s.drawTO ); | ||
this.s.drawTO = setTimeout( draw, this.s.serverWait ); | ||
} | ||
else { | ||
draw(); | ||
} | ||
if ( this.dom.loader && ! this.s.loaderVisible ) { | ||
this.dom.loader.css( 'display', 'block' ); | ||
this.s.loaderVisible = true; | ||
} | ||
} | ||
} | ||
else { | ||
this.s.topRowFloat = this.pixelsToRow( iScrollTop, false, true ); | ||
} | ||
this.s.lastScrollTop = iScrollTop; | ||
this.s.stateSaveThrottle(); | ||
if ( this.s.scrollType === 'jump' && this.s.mousedown ) { | ||
this.dom.label | ||
.html( this.s.dt.fnFormatNumber( parseInt( this.s.topRowFloat, 10 )+1 ) ) | ||
.css( 'top', iScrollTop + (iScrollTop * heights.labelFactor ) ) | ||
.css( 'display', 'block' ); | ||
} | ||
}, | ||
/** | ||
* Force the scrolling container to have height beyond that of just the | ||
* table that has been drawn so the user can scroll the whole data set. | ||
* | ||
* Note that if the calculated required scrolling height exceeds a maximum | ||
* value (1 million pixels - hard-coded) the forcing element will be set | ||
* only to that maximum value and virtual / physical domain transforms will | ||
* be used to allow Scroller to display tables of any number of records. | ||
* @returns {void} | ||
* @private | ||
*/ | ||
_scrollForce: function () | ||
{ | ||
var heights = this.s.heights; | ||
var max = 1000000; | ||
heights.virtual = heights.row * this.s.dt.fnRecordsDisplay(); | ||
heights.scroll = heights.virtual; | ||
if ( heights.scroll > max ) { | ||
heights.scroll = max; | ||
} | ||
// Minimum height so there is always a row visible (the 'no rows found' | ||
// if reduced to zero filtering) | ||
this.dom.force.style.height = heights.scroll > this.s.heights.row ? | ||
heights.scroll+'px' : | ||
this.s.heights.row+'px'; | ||
} | ||
@@ -1189,60 +1164,17 @@ } ); | ||
*/ | ||
Scroller.defaults = /** @lends Scroller.defaults */{ | ||
Scroller.defaults = { | ||
/** | ||
* Indicate if Scroller show show trace information on the console or not. This can be | ||
* useful when debugging Scroller or if just curious as to what it is doing, but should | ||
* be turned off for production. | ||
* @type bool | ||
* @default false | ||
* Scroller uses the boundary scaling factor to decide when to redraw the table - which it | ||
* typically does before you reach the end of the currently loaded data set (in order to | ||
* allow the data to look continuous to a user scrolling through the data). If given as 0 | ||
* then the table will be redrawn whenever the viewport is scrolled, while 1 would not | ||
* redraw the table until the currently loaded data has all been shown. You will want | ||
* something in the middle - the default factor of 0.5 is usually suitable. | ||
* @type float | ||
* @default 0.5 | ||
* @static | ||
* @example | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "oScroller": { | ||
* "trace": true | ||
* } | ||
* } ); | ||
*/ | ||
"trace": false, | ||
boundaryScale: 0.5, | ||
/** | ||
* Scroller will attempt to automatically calculate the height of rows for it's internal | ||
* calculations. However the height that is used can be overridden using this parameter. | ||
* @type int|string | ||
* @default auto | ||
* @static | ||
* @example | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "oScroller": { | ||
* "rowHeight": 30 | ||
* } | ||
* } ); | ||
*/ | ||
"rowHeight": "auto", | ||
/** | ||
* When using server-side processing, Scroller will wait a small amount of time to allow | ||
* the scrolling to finish before requesting more data from the server. This prevents | ||
* you from DoSing your own server! The wait time can be configured by this parameter. | ||
* @type int | ||
* @default 200 | ||
* @static | ||
* @example | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "oScroller": { | ||
* "serverWait": 100 | ||
* } | ||
* } ); | ||
*/ | ||
"serverWait": 200, | ||
/** | ||
* The display buffer is what Scroller uses to calculate how many rows it should pre-fetch | ||
@@ -1260,37 +1192,6 @@ * for scrolling. Scroller automatically adjusts DataTables' display length to pre-fetch | ||
* @static | ||
* @example | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "oScroller": { | ||
* "displayBuffer": 10 | ||
* } | ||
* } ); | ||
*/ | ||
"displayBuffer": 9, | ||
displayBuffer: 9, | ||
/** | ||
* Scroller uses the boundary scaling factor to decide when to redraw the table - which it | ||
* typically does before you reach the end of the currently loaded data set (in order to | ||
* allow the data to look continuous to a user scrolling through the data). If given as 0 | ||
* then the table will be redrawn whenever the viewport is scrolled, while 1 would not | ||
* redraw the table until the currently loaded data has all been shown. You will want | ||
* something in the middle - the default factor of 0.5 is usually suitable. | ||
* @type float | ||
* @default 0.5 | ||
* @static | ||
* @example | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "oScroller": { | ||
* "boundaryScale": 0.75 | ||
* } | ||
* } ); | ||
*/ | ||
"boundaryScale": 0.5, | ||
/** | ||
* Show (or not) the loading element in the background of the table. Note that you should | ||
@@ -1301,13 +1202,23 @@ * include the dataTables.scroller.css file for this to be displayed correctly. | ||
* @static | ||
* @example | ||
* var oTable = $('#example').dataTable( { | ||
* "sScrollY": "200px", | ||
* "sDom": "frtiS", | ||
* "bDeferRender": true, | ||
* "oScroller": { | ||
* "loadingIndicator": true | ||
* } | ||
* } ); | ||
*/ | ||
"loadingIndicator": false | ||
loadingIndicator: false, | ||
/** | ||
* Scroller will attempt to automatically calculate the height of rows for it's internal | ||
* calculations. However the height that is used can be overridden using this parameter. | ||
* @type int|string | ||
* @default auto | ||
* @static | ||
*/ | ||
rowHeight: "auto", | ||
/** | ||
* When using server-side processing, Scroller will wait a small amount of time to allow | ||
* the scrolling to finish before requesting more data from the server. This prevents | ||
* you from DoSing your own server! The wait time can be configured by this parameter. | ||
* @type int | ||
* @default 200 | ||
* @static | ||
*/ | ||
serverWait: 200 | ||
}; | ||
@@ -1330,3 +1241,3 @@ | ||
*/ | ||
Scroller.version = "1.5.1"; | ||
Scroller.version = "2.0.0"; | ||
@@ -1339,23 +1250,2 @@ | ||
// Legacy `dom` parameter initialisation support | ||
if ( typeof $.fn.dataTable == "function" && | ||
typeof $.fn.dataTableExt.fnVersionCheck == "function" && | ||
$.fn.dataTableExt.fnVersionCheck('1.10.0') ) | ||
{ | ||
$.fn.dataTableExt.aoFeatures.push( { | ||
"fnInit": function( oDTSettings ) { | ||
var init = oDTSettings.oInit; | ||
var opts = init.scroller || init.oScroller || {}; | ||
new Scroller( oDTSettings, opts ); | ||
}, | ||
"cFeature": "S", | ||
"sFeature": "Scroller" | ||
} ); | ||
} | ||
else | ||
{ | ||
alert( "Warning: Scroller requires DataTables 1.10.0 or greater - www.datatables.net/download"); | ||
} | ||
// Attach a listener to the document which listens for DataTables initialisation | ||
@@ -1398,3 +1288,3 @@ // events so we can automatically initialise | ||
if ( ctx.length && ctx[0].oScroller ) { | ||
return ctx[0].oScroller.fnRowToPixels( rowIdx, intParse, virtual ); | ||
return ctx[0].oScroller.rowToPixels( rowIdx, intParse, virtual ); | ||
} | ||
@@ -1409,3 +1299,3 @@ // undefined | ||
if ( ctx.length && ctx[0].oScroller ) { | ||
return ctx[0].oScroller.fnPixelsToRow( pixels, intParse, virtual ); | ||
return ctx[0].oScroller.pixelsToRow( pixels, intParse, virtual ); | ||
} | ||
@@ -1419,3 +1309,3 @@ // undefined | ||
if ( ctx.oScroller ) { | ||
ctx.oScroller.fnScrollToRow( idx, ani ); | ||
ctx.oScroller.scrollToRow( idx, ani ); | ||
} | ||
@@ -1437,3 +1327,3 @@ } ); | ||
ctx.oScroller.fnScrollToRow( displayIdx, ani ); | ||
ctx.oScroller.scrollToRow( displayIdx, ani ); | ||
} | ||
@@ -1448,3 +1338,3 @@ } ); | ||
if ( ctx.oScroller ) { | ||
ctx.oScroller.fnMeasure( redraw ); | ||
ctx.oScroller.measure( redraw ); | ||
} | ||
@@ -1460,3 +1350,3 @@ } ); | ||
if ( ctx.length && ctx[0].oScroller ) { | ||
return ctx[0].oScroller.fnPageInfo(); | ||
return ctx[0].oScroller.pageInfo(); | ||
} | ||
@@ -1463,0 +1353,0 @@ // undefined |
/*! | ||
Scroller 1.5.1 | ||
Scroller 2.0.0 | ||
©2011-2018 SpryMedia Ltd - datatables.net/license | ||
*/ | ||
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(h){return e(h,window,document)}):"object"===typeof exports?module.exports=function(h,i){h||(h=window);if(!i||!i.fn.dataTable)i=require("datatables.net")(h,i).$;return e(i,h,h.document)}:e(jQuery,window,document)})(function(e,h,i,l){var m=e.fn.dataTable,g=function(a,b){if(this instanceof g){b===l&&(b={});var c=e.fn.dataTable.Api(a);this.s={dt:c.settings()[0],dtApi:c,tableTop:0,tableBottom:0,redrawTop:0, | ||
redrawBottom:0,autoHeight:!0,viewportRows:0,stateTO:null,drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1,forceReposition:!1};this.s=e.extend(this.s,g.oDefaults,b);this.s.heights.row=this.s.rowHeight;this.dom={force:i.createElement("div"),scroller:null,table:null,loader:null};this.s.dt.oScroller||(this.s.dt.oScroller=this,this._fnConstruct())}else alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")}; | ||
e.extend(g.prototype,{fnRowToPixels:function(a,b,c){a-=this.s.baseRowTop;c=c?this._domain("virtualToPhysical",this.s.baseScrollTop):this.s.baseScrollTop;c+=a*this.s.heights.row;return b||b===l?parseInt(c,10):c},fnPixelsToRow:function(a,b,c){a-=this.s.baseScrollTop;c=c?(this._domain("physicalToVirtual",this.s.baseScrollTop)+a)/this.s.heights.row:a/this.s.heights.row+this.s.baseRowTop;return b||b===l?parseInt(c,10):c},fnScrollToRow:function(a,b){var c=this,d=!1,f=this.fnRowToPixels(a),j=a-(this.s.displayBuffer- | ||
1)/2*this.s.viewportRows;0>j&&(j=0);if((f>this.s.redrawBottom||f<this.s.redrawTop)&&this.s.dt._iDisplayStart!==j)d=!0,f=this._domain("virtualToPhysical",a*this.s.heights.row),this.s.redrawTop<f&&f<this.s.redrawBottom&&(this.s.forceReposition=!0,b=!1);"undefined"==typeof b||b?(this.s.ani=d,e(this.dom.scroller).animate({scrollTop:f},function(){setTimeout(function(){c.s.ani=!1},25)})):e(this.dom.scroller).scrollTop(f)},fnMeasure:function(a){this.s.autoHeight&&this._fnCalcRowHeight();var b=this.s.heights; | ||
b.row&&(b.viewport=e.contains(i,this.dom.scroller)?e(this.dom.scroller).height():this._parseHeight(e(this.dom.scroller).css("height")),b.viewport||(b.viewport=this._parseHeight(e(this.dom.scroller).css("max-height"))),this.s.viewportRows=parseInt(b.viewport/b.row,10)+1,this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer);(a===l||a)&&this.s.dt.oInstance.fnDraw(!1)},fnPageInfo:function(){var a=this.dom.scroller.scrollTop,b=this.s.dt.fnRecordsDisplay(),c=Math.ceil(this.fnPixelsToRow(a+ | ||
this.s.heights.viewport,!1,this.s.ani));return{start:Math.floor(this.fnPixelsToRow(a,!1,this.s.ani)),end:b<c?b-1:c-1}},_fnConstruct:function(){var a=this,b=this.s.dtApi;if(this.s.dt.oFeatures.bPaginate){this.dom.force.style.position="relative";this.dom.force.style.top="0px";this.dom.force.style.left="0px";this.dom.force.style.width="1px";this.dom.scroller=e("div."+this.s.dt.oClasses.sScrollBody,this.s.dt.nTableWrapper)[0];this.dom.scroller.appendChild(this.dom.force);this.dom.scroller.style.position= | ||
"relative";this.dom.table=e(">table",this.dom.scroller)[0];this.dom.table.style.position="absolute";this.dom.table.style.top="0px";this.dom.table.style.left="0px";e(b.table().container()).addClass("DTS");this.s.loadingIndicator&&(this.dom.loader=e('<div class="dataTables_processing DTS_Loading">'+this.s.dt.oLanguage.sLoadingRecords+"</div>").css("display","none"),e(this.dom.scroller.parentNode).css("position","relative").append(this.dom.loader));this.s.heights.row&&"auto"!=this.s.heights.row&&(this.s.autoHeight= | ||
!1);this.fnMeasure(!1);this.s.ingnoreScroll=!0;this.s.stateSaveThrottle=this.s.dt.oApi._fnThrottle(function(){a.s.dtApi.state.save()},500);e(this.dom.scroller).on("scroll.dt-scroller",function(){a._fnScroll.call(a)});e(this.dom.scroller).on("touchstart.dt-scroller",function(){a._fnScroll.call(a)});e(h).on("resize.dt-scroller",function(){a.fnMeasure(false);a._fnInfo()});var c=!0,d=b.state.loaded();b.on("stateSaveParams.scroller",function(b,e,g){g.scroller={topRow:c&&d&&d.scroller?d.scroller.topRow: | ||
a.s.topRowFloat,baseScrollTop:a.s.baseScrollTop,baseRowTop:a.s.baseRowTop};c=false});d&&d.scroller&&(this.s.topRowFloat=d.scroller.topRow,this.s.baseScrollTop=d.scroller.baseScrollTop,this.s.baseRowTop=d.scroller.baseRowTop);b.on("init.scroller",function(){a.fnMeasure(false);a._fnDrawCallback();b.on("draw.scroller",function(){a._fnDrawCallback()})});b.on("preDraw.dt.scroller",function(){a._fnScrollForce()});b.on("destroy.scroller",function(){e(h).off("resize.dt-scroller");e(a.dom.scroller).off(".dt-scroller"); | ||
e(a.s.dt.nTable).off(".scroller");e(a.s.dt.nTableWrapper).removeClass("DTS");e("div.DTS_Loading",a.dom.scroller.parentNode).remove();a.dom.table.style.position="";a.dom.table.style.top="";a.dom.table.style.left=""})}else this.s.dt.oApi._fnLog(this.s.dt,0,"Pagination must be enabled for Scroller")},_fnScroll:function(){var a=this,b=this.s.heights,c=this.dom.scroller.scrollTop,d;if(!this.s.skip&&!this.s.ingnoreScroll)if(this.s.dt.bFiltered||this.s.dt.bSorted)this.s.lastScrollTop=0;else{this._fnInfo(); | ||
clearTimeout(this.s.stateTO);this.s.stateTO=setTimeout(function(){a.s.dtApi.state.save()},250);if(this.s.forceReposition||c<this.s.redrawTop||c>this.s.redrawBottom){var f=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows);d=parseInt(this._domain("physicalToVirtual",c)/b.row,10)-f;this.s.topRowFloat=this._domain("physicalToVirtual",c)/b.row;this.s.forceReposition=!1;0>=d?d=0:d+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(d=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength,0> | ||
d&&(d=0)):0!==d%2&&d++;if(d!=this.s.dt._iDisplayStart&&(this.s.tableTop=e(this.s.dt.nTable).offset().top,this.s.tableBottom=e(this.s.dt.nTable).height()+this.s.tableTop,b=function(){if(a.s.scrollDrawReq===null)a.s.scrollDrawReq=c;a.s.dt._iDisplayStart=d;a.s.dt.oApi._fnDraw(a.s.dt)},this.s.dt.oFeatures.bServerSide?(clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(b,this.s.serverWait)):b(),this.dom.loader&&!this.s.loaderVisible))this.dom.loader.css("display","block"),this.s.loaderVisible=!0}else this.s.topRowFloat= | ||
this.fnPixelsToRow(c,!1,!0);this.s.lastScrollTop=c;this.s.stateSaveThrottle()}},_domain:function(a,b){var c=this.s.heights,d;if(c.virtual===c.scroll)return b;var e=(c.scroll-c.viewport)/2,j=(c.virtual-c.viewport)/2;d=j/(e*e);if("virtualToPhysical"===a){if(b<j)return Math.pow(b/d,0.5);b=2*j-b;return 0>b?c.scroll:2*e-Math.pow(b/d,0.5)}if("physicalToVirtual"===a){if(b<e)return b*b*d;b=2*e-b;return 0>b?c.virtual:2*j-b*b*d}},_parseHeight:function(a){var b,c=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(a); | ||
if(null===c)return 0;a=parseFloat(c[1]);c=c[2];"px"===c?b=a:"vh"===c?b=a/100*e(h).height():"rem"===c?b=a*parseFloat(e(":root").css("font-size")):"em"===c&&(b=a*parseFloat(e("body").css("font-size")));return b?b:0},_fnDrawCallback:function(){var a=this,b=this.s.heights,c=this.dom.scroller.scrollTop,d=e(this.s.dt.nTable).height(),f=this.s.dt._iDisplayStart,j=this.s.dt._iDisplayLength,g=this.s.dt.fnRecordsDisplay();this.s.skip=!0;if((this.s.dt.bSorted||this.s.dt.bFiltered)&&0===f)this.s.topRowFloat= | ||
0;c=0===f?this.s.topRowFloat*b.row:f+j>=g?b.scroll-(g-this.s.topRowFloat)*b.row:this._domain("virtualToPhysical",this.s.topRowFloat*b.row);this.dom.scroller.scrollTop=c;this.s.baseScrollTop=c;this.s.baseRowTop=this.s.topRowFloat;var h=c-(this.s.topRowFloat-f)*b.row;0===f?h=0:f+j>=g&&(h=b.scroll-d);this.dom.table.style.top=h+"px";this.s.tableTop=h;this.s.tableBottom=d+this.s.tableTop;d=(c-this.s.tableTop)*this.s.boundaryScale;this.s.redrawTop=c-d;this.s.redrawBottom=c+d>b.scroll-b.viewport-b.row?b.scroll- | ||
b.viewport-b.row:c+d;this.s.skip=!1;this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&"undefined"!=typeof this.s.dt.oLoadedState.iScroller?((c=(this.s.dt.sAjaxSource||a.s.dt.ajax)&&!this.s.dt.oFeatures.bServerSide?!0:!1)&&2==this.s.dt.iDraw||!c&&1==this.s.dt.iDraw)&&setTimeout(function(){e(a.dom.scroller).scrollTop(a.s.dt.oLoadedState.iScroller);a.s.redrawTop=a.s.dt.oLoadedState.iScroller-b.viewport/2;setTimeout(function(){a.s.ingnoreScroll=!1},0)},0):a.s.ingnoreScroll=!1;this.s.dt.oFeatures.bInfo&& | ||
setTimeout(function(){a._fnInfo.call(a)},0);this.dom.loader&&this.s.loaderVisible&&(this.dom.loader.css("display","none"),this.s.loaderVisible=!1)},_fnScrollForce:function(){var a=this.s.heights;a.virtual=a.row*this.s.dt.fnRecordsDisplay();a.scroll=a.virtual;1E6<a.scroll&&(a.scroll=1E6);this.dom.force.style.height=a.scroll>this.s.heights.row?a.scroll+"px":this.s.heights.row+"px"},_fnCalcRowHeight:function(){var a=this.s.dt,b=a.nTable,c=b.cloneNode(!1),d=e("<tbody/>").appendTo(c),f=e('<div class="'+ | ||
a.oClasses.sWrapper+' DTS"><div class="'+a.oClasses.sScrollWrapper+'"><div class="'+a.oClasses.sScrollBody+'"></div></div></div>');for(e("tbody tr:lt(4)",b).clone().appendTo(d);3>e("tr",d).length;)d.append("<tr><td> </td></tr>");e("div."+a.oClasses.sScrollBody,f).append(c);a=this.s.dt.nHolding||b.parentNode;e(a).is(":visible")||(a="body");f.appendTo(a);this.s.heights.row=e("tr",d).eq(1).outerHeight();f.remove()},_fnInfo:function(){if(this.s.dt.oFeatures.bInfo){var a=this.s.dt,b=a.oLanguage,c= | ||
this.dom.scroller.scrollTop,d=Math.floor(this.fnPixelsToRow(c,!1,this.s.ani)+1),f=a.fnRecordsTotal(),g=a.fnRecordsDisplay(),c=Math.ceil(this.fnPixelsToRow(c+this.s.heights.viewport,!1,this.s.ani)),c=g<c?g:c,h=a.fnFormatNumber(d),i=a.fnFormatNumber(c),k=a.fnFormatNumber(f),l=a.fnFormatNumber(g),h=0===a.fnRecordsDisplay()&&a.fnRecordsDisplay()==a.fnRecordsTotal()?b.sInfoEmpty+b.sInfoPostFix:0===a.fnRecordsDisplay()?b.sInfoEmpty+" "+b.sInfoFiltered.replace("_MAX_",k)+b.sInfoPostFix:a.fnRecordsDisplay()== | ||
a.fnRecordsTotal()?b.sInfo.replace("_START_",h).replace("_END_",i).replace("_MAX_",k).replace("_TOTAL_",l)+b.sInfoPostFix:b.sInfo.replace("_START_",h).replace("_END_",i).replace("_MAX_",k).replace("_TOTAL_",l)+" "+b.sInfoFiltered.replace("_MAX_",a.fnFormatNumber(a.fnRecordsTotal()))+b.sInfoPostFix;(b=b.fnInfoCallback)&&(h=b.call(a.oInstance,a,d,c,f,g,h));d=a.aanFeatures.i;if("undefined"!=typeof d){f=0;for(g=d.length;f<g;f++)e(d[f]).html(h)}e(a.nTable).triggerHandler("info.dt")}}});g.defaults={trace:!1, | ||
rowHeight:"auto",serverWait:200,displayBuffer:9,boundaryScale:0.5,loadingIndicator:!1};g.oDefaults=g.defaults;g.version="1.5.1";"function"==typeof e.fn.dataTable&&"function"==typeof e.fn.dataTableExt.fnVersionCheck&&e.fn.dataTableExt.fnVersionCheck("1.10.0")?e.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var b=a.oInit;new g(a,b.scroller||b.oScroller||{})},cFeature:"S",sFeature:"Scroller"}):alert("Warning: Scroller requires DataTables 1.10.0 or greater - www.datatables.net/download");e(i).on("preInit.dt.dtscroller", | ||
function(a,b){if("dt"===a.namespace){var c=b.oInit.scroller,d=m.defaults.scroller;if(c||d)d=e.extend({},c,d),!1!==c&&new g(b,d)}});e.fn.dataTable.Scroller=g;e.fn.DataTable.Scroller=g;var k=e.fn.dataTable.Api;k.register("scroller()",function(){return this});k.register("scroller().rowToPixels()",function(a,b,c){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.fnRowToPixels(a,b,c)});k.register("scroller().pixelsToRow()",function(a,b,c){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.fnPixelsToRow(a, | ||
b,c)});k.register(["scroller().scrollToRow()","scroller.toPosition()"],function(a,b){this.iterator("table",function(c){c.oScroller&&c.oScroller.fnScrollToRow(a,b)});return this});k.register("row().scrollTo()",function(a){var b=this;this.iterator("row",function(c,d){if(c.oScroller){var e=b.rows({order:"applied",search:"applied"}).indexes().indexOf(d);c.oScroller.fnScrollToRow(e,a)}});return this});k.register("scroller.measure()",function(a){this.iterator("table",function(b){b.oScroller&&b.oScroller.fnMeasure(a)}); | ||
return this});k.register("scroller.page()",function(){var a=this.context;if(a.length&&a[0].oScroller)return a[0].oScroller.fnPageInfo()});return g}); | ||
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(h){return e(h,window,document)}):"object"===typeof exports?module.exports=function(h,i){h||(h=window);if(!i||!i.fn.dataTable)i=require("datatables.net")(h,i).$;return e(i,h,h.document)}:e(jQuery,window,document)})(function(e,h,i,l){var m=e.fn.dataTable,g=function(a,c){if(this instanceof g){c===l&&(c={});var b=e.fn.dataTable.Api(a);this.s={dt:b.settings()[0],dtApi:b,tableTop:0,tableBottom:0,redrawTop:0, | ||
redrawBottom:0,autoHeight:!0,viewportRows:0,stateTO:null,drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null,labelFactor:1},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1,forceReposition:!1,baseRowTop:0,baseScrollTop:0,mousedown:!1,lastScrollTop:0};this.s=e.extend(this.s,g.oDefaults,c);this.s.heights.row=this.s.rowHeight;this.dom={force:i.createElement("div"),label:e('<div class="dts_label">0</div>'),scroller:null,table:null,loader:null};this.s.dt.oScroller|| | ||
(this.s.dt.oScroller=this,this.construct())}else alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")};e.extend(g.prototype,{measure:function(a){this.s.autoHeight&&this._calcRowHeight();var c=this.s.heights;c.row&&(c.viewport=e.contains(i,this.dom.scroller)?this.dom.scroller.clientHeight:this._parseHeight(e(this.dom.scroller).css("height")),c.viewport||(c.viewport=this._parseHeight(e(this.dom.scroller).css("max-height"))),this.s.viewportRows=parseInt(c.viewport/c.row,10)+ | ||
1,this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer);var b=this.dom.label.outerHeight();c.labelFactor=(c.viewport-b)/c.scroll;(a===l||a)&&this.s.dt.oInstance.fnDraw(!1)},pageInfo:function(){var a=this.dom.scroller.scrollTop,c=this.s.dt.fnRecordsDisplay(),b=Math.ceil(this.pixelsToRow(a+this.s.heights.viewport,!1,this.s.ani));return{start:Math.floor(this.pixelsToRow(a,!1,this.s.ani)),end:c<b?c-1:b-1}},pixelsToRow:function(a,c,b){a-=this.s.baseScrollTop;b=b?(this._domain("physicalToVirtual", | ||
this.s.baseScrollTop)+a)/this.s.heights.row:a/this.s.heights.row+this.s.baseRowTop;return c||c===l?parseInt(b,10):b},rowToPixels:function(a,c,b){a-=this.s.baseRowTop;b=b?this._domain("virtualToPhysical",this.s.baseScrollTop):this.s.baseScrollTop;b+=a*this.s.heights.row;return c||c===l?parseInt(b,10):b},scrollToRow:function(a,c){var b=this,d=!1,f=this.rowToPixels(a),k=a-(this.s.displayBuffer-1)/2*this.s.viewportRows;0>k&&(k=0);if((f>this.s.redrawBottom||f<this.s.redrawTop)&&this.s.dt._iDisplayStart!== | ||
k)d=!0,f=this._domain("virtualToPhysical",a*this.s.heights.row),this.s.redrawTop<f&&f<this.s.redrawBottom&&(this.s.forceReposition=!0,c=!1);"undefined"==typeof c||c?(this.s.ani=d,e(this.dom.scroller).animate({scrollTop:f},function(){setTimeout(function(){b.s.ani=!1},25)})):e(this.dom.scroller).scrollTop(f)},construct:function(){var a=this,c=this.s.dtApi;if(this.s.dt.oFeatures.bPaginate){this.dom.force.style.position="relative";this.dom.force.style.top="0px";this.dom.force.style.left="0px";this.dom.force.style.width= | ||
"1px";this.dom.scroller=e("div."+this.s.dt.oClasses.sScrollBody,this.s.dt.nTableWrapper)[0];this.dom.scroller.appendChild(this.dom.force);this.dom.scroller.style.position="relative";this.dom.table=e(">table",this.dom.scroller)[0];this.dom.table.style.position="absolute";this.dom.table.style.top="0px";this.dom.table.style.left="0px";e(c.table().container()).addClass("dts DTS");this.s.loadingIndicator&&(this.dom.loader=e('<div class="dataTables_processing dts_loading">'+this.s.dt.oLanguage.sLoadingRecords+ | ||
"</div>").css("display","none"),e(this.dom.scroller.parentNode).css("position","relative").append(this.dom.loader));this.dom.label.appendTo(this.dom.scroller);this.s.heights.row&&"auto"!=this.s.heights.row&&(this.s.autoHeight=!1);this.measure(!1);this.s.ingnoreScroll=!0;this.s.stateSaveThrottle=this.s.dt.oApi._fnThrottle(function(){a.s.dtApi.state.save()},500);e(this.dom.scroller).on("scroll.dt-scroller",function(){a._scroll.call(a)});e(this.dom.scroller).on("touchstart.dt-scroller",function(){a._scroll.call(a)}); | ||
e(this.dom.scroller).on("mousedown.dt-scroller",function(){a.s.mousedown=true}).on("mouseup.dt-scroller",function(){a.s.mouseup=false;a.dom.label.css("display","none")});e(h).on("resize.dt-scroller",function(){a.measure(false);a._info()});var b=!0,d=c.state.loaded();c.on("stateSaveParams.scroller",function(c,e,h){h.scroller={topRow:b&&d&&d.scroller?d.scroller.topRow:a.s.topRowFloat,baseScrollTop:a.s.baseScrollTop,baseRowTop:a.s.baseRowTop};b=false});d&&d.scroller&&(this.s.topRowFloat=d.scroller.topRow, | ||
this.s.baseScrollTop=d.scroller.baseScrollTop,this.s.baseRowTop=d.scroller.baseRowTop);c.on("init.scroller",function(){a.measure(false);a._draw();c.on("draw.scroller",function(){a._draw()})});c.on("preDraw.dt.scroller",function(){a._scrollForce()});c.on("destroy.scroller",function(){e(h).off("resize.dt-scroller");e(a.dom.scroller).off(".dt-scroller");e(a.s.dt.nTable).off(".scroller");e(a.s.dt.nTableWrapper).removeClass("DTS");e("div.DTS_Loading",a.dom.scroller.parentNode).remove();a.dom.table.style.position= | ||
"";a.dom.table.style.top="";a.dom.table.style.left=""})}else this.s.dt.oApi._fnLog(this.s.dt,0,"Pagination must be enabled for Scroller")},_calcRowHeight:function(){var a=this.s.dt,c=a.nTable,b=c.cloneNode(!1),d=e("<tbody/>").appendTo(b),f=e('<div class="'+a.oClasses.sWrapper+' DTS"><div class="'+a.oClasses.sScrollWrapper+'"><div class="'+a.oClasses.sScrollBody+'"></div></div></div>');e("tbody tr:lt(4)",c).clone().appendTo(d);var k=e("tr",d).length;if(1===k)d.prepend("<tr><td> </td></tr>"),d.append("<tr><td> </td></tr>"); | ||
else for(;3>k;k++)d.append("<tr><td> </td></tr>");e("div."+a.oClasses.sScrollBody,f).append(b);a=this.s.dt.nHolding||c.parentNode;e(a).is(":visible")||(a="body");f.appendTo(a);this.s.heights.row=e("tr",d).eq(1).outerHeight();f.remove()},_draw:function(){var a=this,c=this.s.heights,b=this.dom.scroller.scrollTop,d=e(this.s.dt.nTable).height(),f=this.s.dt._iDisplayStart,k=this.s.dt._iDisplayLength,h=this.s.dt.fnRecordsDisplay();this.s.skip=!0;if((this.s.dt.bSorted||this.s.dt.bFiltered)&&0===f&& | ||
!this.s.dt._drawHold)this.s.topRowFloat=0;b="jump"===this.scrollType?this._domain("physicalToVirtual",this.s.topRowFloat*c.row):b;e(a.dom.scroller).scrollTop(b);this.s.baseScrollTop=b;this.s.baseRowTop=this.s.topRowFloat;var g=b-(this.s.topRowFloat-f)*c.row;0===f?g=0:f+k>=h&&(g=c.scroll-d);this.dom.table.style.top=g+"px";this.s.tableTop=g;this.s.tableBottom=d+this.s.tableTop;d=(b-this.s.tableTop)*this.s.boundaryScale;this.s.redrawTop=b-d;this.s.redrawBottom=b+d>c.scroll-c.viewport-c.row?c.scroll- | ||
c.viewport-c.row:b+d;this.s.skip=!1;this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&"undefined"!=typeof this.s.dt.oLoadedState.iScroller?((b=(this.s.dt.sAjaxSource||a.s.dt.ajax)&&!this.s.dt.oFeatures.bServerSide?!0:!1)&&2==this.s.dt.iDraw||!b&&1==this.s.dt.iDraw)&&setTimeout(function(){e(a.dom.scroller).scrollTop(a.s.dt.oLoadedState.iScroller);a.s.redrawTop=a.s.dt.oLoadedState.iScroller-c.viewport/2;setTimeout(function(){a.s.ingnoreScroll=!1},0)},0):a.s.ingnoreScroll=!1;this.s.dt.oFeatures.bInfo&& | ||
setTimeout(function(){a._info.call(a)},0);this.dom.loader&&this.s.loaderVisible&&(this.dom.loader.css("display","none"),this.s.loaderVisible=!1)},_domain:function(a,c){var b=this.s.heights,d;if(b.virtual===b.scroll||1E4>c)return c;if("virtualToPhysical"===a&&c>b.virtual-1E4)return d=b.virtual-c,b.scroll-d;if("physicalToVirtual"===a&&c>b.scroll-1E4)return d=b.scroll-c,b.virtual-d;b=(("virtualToPhysical"===a?b.scroll:b.virtual)-1E4)/(("virtualToPhysical"===a?b.virtual:b.scroll)-1E4);return b*c+(1E4- | ||
1E4*b)},_info:function(){if(this.s.dt.oFeatures.bInfo){var a=this.s.dt,c=a.oLanguage,b=this.dom.scroller.scrollTop,d=Math.floor(this.pixelsToRow(b,!1,this.s.ani)+1),f=a.fnRecordsTotal(),g=a.fnRecordsDisplay(),b=Math.ceil(this.pixelsToRow(b+this.s.heights.viewport,!1,this.s.ani)),b=g<b?g:b,h=a.fnFormatNumber(d),i=a.fnFormatNumber(b),j=a.fnFormatNumber(f),l=a.fnFormatNumber(g),h=0===a.fnRecordsDisplay()&&a.fnRecordsDisplay()==a.fnRecordsTotal()?c.sInfoEmpty+c.sInfoPostFix:0===a.fnRecordsDisplay()?c.sInfoEmpty+ | ||
" "+c.sInfoFiltered.replace("_MAX_",j)+c.sInfoPostFix:a.fnRecordsDisplay()==a.fnRecordsTotal()?c.sInfo.replace("_START_",h).replace("_END_",i).replace("_MAX_",j).replace("_TOTAL_",l)+c.sInfoPostFix:c.sInfo.replace("_START_",h).replace("_END_",i).replace("_MAX_",j).replace("_TOTAL_",l)+" "+c.sInfoFiltered.replace("_MAX_",a.fnFormatNumber(a.fnRecordsTotal()))+c.sInfoPostFix;(c=c.fnInfoCallback)&&(h=c.call(a.oInstance,a,d,b,f,g,h));d=a.aanFeatures.i;if("undefined"!=typeof d){f=0;for(g=d.length;f<g;f++)e(d[f]).html(h)}e(a.nTable).triggerHandler("info.dt")}}, | ||
_parseHeight:function(a){var c,b=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(a);if(null===b)return 0;a=parseFloat(b[1]);b=b[2];"px"===b?c=a:"vh"===b?c=a/100*e(h).height():"rem"===b?c=a*parseFloat(e(":root").css("font-size")):"em"===b&&(c=a*parseFloat(e("body").css("font-size")));return c?c:0},_scroll:function(){var a=this,c=this.s.heights,b=this.dom.scroller.scrollTop,d;if(!this.s.skip&&!this.s.ingnoreScroll&&b!==this.s.lastScrollTop)if(this.s.dt.bFiltered||this.s.dt.bSorted)this.s.lastScrollTop= | ||
0;else{this._info();clearTimeout(this.s.stateTO);this.s.stateTO=setTimeout(function(){a.s.dtApi.state.save()},250);this.s.scrollType=Math.abs(b-this.s.lastScrollTop)>c.viewport?"jump":"cont";this.s.topRowFloat="cont"===this.s.scrollType?this.pixelsToRow(b,!1,!1):this._domain("physicalToVirtual",b)/c.row;0>this.s.topRowFloat&&(this.s.topRowFloat=0);if(this.s.forceReposition||b<this.s.redrawTop||b>this.s.redrawBottom){var f=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows);d=parseInt(this.s.topRowFloat, | ||
10)-f;this.s.forceReposition=!1;0>=d?d=0:d+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(d=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength,0>d&&(d=0)):0!==d%2&&d++;if(d!=this.s.dt._iDisplayStart&&(this.s.tableTop=e(this.s.dt.nTable).offset().top,this.s.tableBottom=e(this.s.dt.nTable).height()+this.s.tableTop,f=function(){if(a.s.scrollDrawReq===null)a.s.scrollDrawReq=b;a.s.dt._iDisplayStart=d;a.s.dt.oApi._fnDraw(a.s.dt)},this.s.dt.oFeatures.bServerSide?(clearTimeout(this.s.drawTO), | ||
this.s.drawTO=setTimeout(f,this.s.serverWait)):f(),this.dom.loader&&!this.s.loaderVisible))this.dom.loader.css("display","block"),this.s.loaderVisible=!0}else this.s.topRowFloat=this.pixelsToRow(b,!1,!0);this.s.lastScrollTop=b;this.s.stateSaveThrottle();"jump"===this.s.scrollType&&this.s.mousedown&&this.dom.label.html(this.s.dt.fnFormatNumber(parseInt(this.s.topRowFloat,10)+1)).css("top",b+b*c.labelFactor).css("display","block")}},_scrollForce:function(){var a=this.s.heights;a.virtual=a.row*this.s.dt.fnRecordsDisplay(); | ||
a.scroll=a.virtual;1E6<a.scroll&&(a.scroll=1E6);this.dom.force.style.height=a.scroll>this.s.heights.row?a.scroll+"px":this.s.heights.row+"px"}});g.defaults={boundaryScale:0.5,displayBuffer:9,loadingIndicator:!1,rowHeight:"auto",serverWait:200};g.oDefaults=g.defaults;g.version="2.0.0";e(i).on("preInit.dt.dtscroller",function(a,c){if("dt"===a.namespace){var b=c.oInit.scroller,d=m.defaults.scroller;if(b||d)d=e.extend({},b,d),!1!==b&&new g(c,d)}});e.fn.dataTable.Scroller=g;e.fn.DataTable.Scroller=g;var j= | ||
e.fn.dataTable.Api;j.register("scroller()",function(){return this});j.register("scroller().rowToPixels()",function(a,c,b){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.rowToPixels(a,c,b)});j.register("scroller().pixelsToRow()",function(a,c,b){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.pixelsToRow(a,c,b)});j.register(["scroller().scrollToRow()","scroller.toPosition()"],function(a,c){this.iterator("table",function(b){b.oScroller&&b.oScroller.scrollToRow(a, | ||
c)});return this});j.register("row().scrollTo()",function(a){var c=this;this.iterator("row",function(b,d){if(b.oScroller){var e=c.rows({order:"applied",search:"applied"}).indexes().indexOf(d);b.oScroller.scrollToRow(e,a)}});return this});j.register("scroller.measure()",function(a){this.iterator("table",function(c){c.oScroller&&c.oScroller.measure(a)});return this});j.register("scroller.page()",function(){var a=this.context;if(a.length&&a[0].oScroller)return a[0].oScroller.pageInfo()});return g}); |
{ | ||
"name": "datatables.net-scroller", | ||
"version": "1.5.1", | ||
"version": "2.0.0", | ||
"description": "Scroller for DataTables ", | ||
@@ -5,0 +5,0 @@ "files": [ |
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
55675
1179