mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
NPM libs: Update embedded package to avoid their dependencies to be retrieved as they are already their
This commit is contained in:
247
node_modules/datatables.net-scroller/js/dataTables.scroller.js
generated
vendored
247
node_modules/datatables.net-scroller/js/dataTables.scroller.js
generated
vendored
@@ -1,15 +1,15 @@
|
||||
/*! Scroller 1.4.2
|
||||
* ©2011-2016 SpryMedia Ltd - datatables.net/license
|
||||
/*! Scroller 1.5.1
|
||||
* ©2011-2018 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary Scroller
|
||||
* @description Virtual rendering for DataTables
|
||||
* @version 1.4.2
|
||||
* @version 1.5.1
|
||||
* @file dataTables.scroller.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
* @copyright Copyright 2011-2016 SpryMedia Ltd.
|
||||
* @copyright Copyright 2011-2018 SpryMedia Ltd.
|
||||
*
|
||||
* This source file is free software, available under the following license:
|
||||
* MIT license - http://datatables.net/license/mit
|
||||
@@ -109,6 +109,8 @@ var Scroller = function ( dt, opts ) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
var dtApi = $.fn.dataTable.Api( dt );
|
||||
|
||||
/**
|
||||
* Settings object which contains customisable information for the Scroller instance
|
||||
* @namespace
|
||||
@@ -121,7 +123,13 @@ var Scroller = function ( dt, opts ) {
|
||||
* @type object
|
||||
* @default Passed in as first parameter to constructor
|
||||
*/
|
||||
"dt": $.fn.dataTable.Api( dt ).settings()[0],
|
||||
"dt": dtApi.settings()[0],
|
||||
|
||||
/**
|
||||
* DataTables API instance
|
||||
* @type DataTable.Api
|
||||
*/
|
||||
"dtApi": dtApi,
|
||||
|
||||
/**
|
||||
* Pixel location of the top of the drawn table in the viewport
|
||||
@@ -210,7 +218,8 @@ var Scroller = function ( dt, opts ) {
|
||||
|
||||
topRowFloat: 0,
|
||||
scrollDrawDiff: null,
|
||||
loaderVisible: false
|
||||
loaderVisible: false,
|
||||
forceReposition: false
|
||||
};
|
||||
|
||||
// @todo The defaults should extend a `c` property and the internal settings
|
||||
@@ -274,13 +283,15 @@ $.extend( Scroller.prototype, {
|
||||
"fnRowToPixels": function ( rowIdx, intParse, virtual )
|
||||
{
|
||||
var pixels;
|
||||
var diff = rowIdx - this.s.baseRowTop;
|
||||
|
||||
if ( virtual ) {
|
||||
pixels = this._domain( 'virtualToPhysical', rowIdx * this.s.heights.row );
|
||||
pixels = this._domain( 'virtualToPhysical', this.s.baseScrollTop );
|
||||
pixels += diff * this.s.heights.row;
|
||||
}
|
||||
else {
|
||||
var diff = rowIdx - this.s.baseRowTop;
|
||||
pixels = this.s.baseScrollTop + (diff * this.s.heights.row);
|
||||
pixels = this.s.baseScrollTop;
|
||||
pixels += diff * this.s.heights.row;
|
||||
}
|
||||
|
||||
return intParse || intParse === undefined ?
|
||||
@@ -319,7 +330,7 @@ $.extend( Scroller.prototype, {
|
||||
{
|
||||
var diff = pixels - this.s.baseScrollTop;
|
||||
var row = virtual ?
|
||||
this._domain( 'physicalToVirtual', pixels ) / this.s.heights.row :
|
||||
(this._domain( 'physicalToVirtual', this.s.baseScrollTop ) + diff) / this.s.heights.row :
|
||||
( diff / this.s.heights.row ) + this.s.baseRowTop;
|
||||
|
||||
return intParse || intParse === undefined ?
|
||||
@@ -370,7 +381,15 @@ $.extend( Scroller.prototype, {
|
||||
|
||||
if ( (px > this.s.redrawBottom || px < this.s.redrawTop) && this.s.dt._iDisplayStart !== drawRow ) {
|
||||
ani = true;
|
||||
px = this.fnRowToPixels( iRow, false, true );
|
||||
px = this._domain( 'virtualToPhysical', iRow * this.s.heights.row );
|
||||
|
||||
// If we need records outside the current draw region, but the new
|
||||
// scrolling position is inside that (due to the non-linear nature
|
||||
// for larger numbers of records), we need to force position update.
|
||||
if ( this.s.redrawTop < px && px < this.s.redrawBottom ) {
|
||||
this.s.forceReposition = true;
|
||||
bAnimate = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( typeof bAnimate == 'undefined' || bAnimate )
|
||||
@@ -432,7 +451,15 @@ $.extend( Scroller.prototype, {
|
||||
var heights = this.s.heights;
|
||||
|
||||
if ( heights.row ) {
|
||||
heights.viewport = $(this.dom.scroller).height();
|
||||
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;
|
||||
}
|
||||
@@ -481,6 +508,7 @@ $.extend( Scroller.prototype, {
|
||||
"_fnConstruct": function ()
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dtApi;
|
||||
|
||||
/* Sanity check */
|
||||
if ( !this.s.dt.oFeatures.bPaginate ) {
|
||||
@@ -506,7 +534,7 @@ $.extend( Scroller.prototype, {
|
||||
this.dom.table.style.left = "0px";
|
||||
|
||||
// Add class to 'announce' that we are a Scroller table
|
||||
$(this.s.dt.nTableWrapper).addClass('DTS');
|
||||
$(dt.table().container()).addClass('DTS');
|
||||
|
||||
// Add a 'loading' indicator
|
||||
if ( this.s.loadingIndicator )
|
||||
@@ -526,84 +554,84 @@ $.extend( Scroller.prototype, {
|
||||
}
|
||||
this.fnMeasure( false );
|
||||
|
||||
/* Scrolling callback to see if a page change is needed - use a throttled
|
||||
* function for the save save callback so we aren't hitting it on every
|
||||
* scroll
|
||||
*/
|
||||
// Scrolling callback to see if a page change is needed - use a throttled
|
||||
// function for the save save callback so we aren't hitting it on every
|
||||
// scroll
|
||||
this.s.ingnoreScroll = true;
|
||||
this.s.stateSaveThrottle = this.s.dt.oApi._fnThrottle( function () {
|
||||
that.s.dt.oApi._fnSaveState( that.s.dt );
|
||||
that.s.dtApi.state.save();
|
||||
}, 500 );
|
||||
$(this.dom.scroller).on( 'scroll.DTS', function (e) {
|
||||
$(this.dom.scroller).on( 'scroll.dt-scroller', function (e) {
|
||||
that._fnScroll.call( that );
|
||||
} );
|
||||
|
||||
/* In iOS we catch the touchstart event in case the user tries to scroll
|
||||
* while the display is already scrolling
|
||||
*/
|
||||
$(this.dom.scroller).on('touchstart.DTS', function () {
|
||||
// In iOS we catch the touchstart event in case the user tries to scroll
|
||||
// while the display is already scrolling
|
||||
$(this.dom.scroller).on('touchstart.dt-scroller', function () {
|
||||
that._fnScroll.call( that );
|
||||
} );
|
||||
|
||||
/* Update the scroller when the DataTable is redrawn */
|
||||
this.s.dt.aoDrawCallback.push( {
|
||||
"fn": function () {
|
||||
if ( that.s.dt.bInitialised ) {
|
||||
that._fnDrawCallback.call( that );
|
||||
}
|
||||
},
|
||||
"sName": "Scroller"
|
||||
} );
|
||||
|
||||
/* On resize, update the information element, since the number of rows shown might change */
|
||||
$(window).on( 'resize.DTS', function () {
|
||||
// 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();
|
||||
} );
|
||||
|
||||
/* Add a state saving parameter to the DT state saving so we can restore the exact
|
||||
* position of the scrolling
|
||||
*/
|
||||
// Add a state saving parameter to the DT state saving so we can restore the exact
|
||||
// position of the scrolling. Slightly surprisingly the scroll position isn't actually
|
||||
// stored, but rather tha base units which are needed to calculate it. This allows for
|
||||
// virtual scrolling as well.
|
||||
var initialStateSave = true;
|
||||
this.s.dt.oApi._fnCallbackReg( this.s.dt, 'aoStateSaveParams', function (oS, oData) {
|
||||
/* Set iScroller to saved scroll position on initialization.
|
||||
*/
|
||||
if(initialStateSave && that.s.dt.oLoadedState){
|
||||
oData.iScroller = that.s.dt.oLoadedState.iScroller;
|
||||
oData.iScrollerTopRow = that.s.dt.oLoadedState.iScrollerTopRow;
|
||||
initialStateSave = false;
|
||||
} else {
|
||||
oData.iScroller = that.dom.scroller.scrollTop;
|
||||
oData.iScrollerTopRow = that.s.topRowFloat;
|
||||
}
|
||||
}, "Scroller_State" );
|
||||
var loadedState = dt.state.loaded();
|
||||
|
||||
if ( this.s.dt.oLoadedState ) {
|
||||
this.s.topRowFloat = this.s.dt.oLoadedState.iScrollerTopRow || 0;
|
||||
}
|
||||
dt.on( 'stateSaveParams.scroller', function ( e, settings, data ) {
|
||||
// Need to used the saved position on init
|
||||
data.scroller = {
|
||||
topRow: initialStateSave && loadedState && loadedState.scroller ?
|
||||
loadedState.scroller.topRow :
|
||||
that.s.topRowFloat,
|
||||
baseScrollTop: that.s.baseScrollTop,
|
||||
baseRowTop: that.s.baseRowTop
|
||||
};
|
||||
|
||||
// Measure immediately. Scroller will have been added using preInit, so
|
||||
// we can reliably do this here. We could potentially also measure on
|
||||
// init complete, which would be useful for cases where the data is Ajax
|
||||
// loaded and longer than a single line.
|
||||
$(this.s.dt.nTable).one( 'init.dt', function () {
|
||||
that.fnMeasure();
|
||||
initialStateSave = false;
|
||||
} );
|
||||
|
||||
/* Destructor */
|
||||
this.s.dt.aoDestroyCallback.push( {
|
||||
"sName": "Scroller",
|
||||
"fn": function () {
|
||||
$(window).off( 'resize.DTS' );
|
||||
$(that.dom.scroller).off('touchstart.DTS scroll.DTS');
|
||||
$(that.s.dt.nTableWrapper).removeClass('DTS');
|
||||
$('div.DTS_Loading', that.dom.scroller.parentNode).remove();
|
||||
$(that.s.dt.nTable).off( 'init.dt' );
|
||||
if ( loadedState && loadedState.scroller ) {
|
||||
this.s.topRowFloat = loadedState.scroller.topRow;
|
||||
this.s.baseScrollTop = loadedState.scroller.baseScrollTop;
|
||||
this.s.baseRowTop = loadedState.scroller.baseRowTop;
|
||||
}
|
||||
|
||||
that.dom.table.style.position = "";
|
||||
that.dom.table.style.top = "";
|
||||
that.dom.table.style.left = "";
|
||||
}
|
||||
dt.on( 'init.scroller', function () {
|
||||
that.fnMeasure( false );
|
||||
|
||||
that._fnDrawCallback();
|
||||
|
||||
// Update the scroller when the DataTable is redrawn
|
||||
dt.on( 'draw.scroller', function () {
|
||||
that._fnDrawCallback();
|
||||
});
|
||||
} );
|
||||
|
||||
// Set height before the draw happens, allowing everything else to update
|
||||
// on draw complete without worry for roder.
|
||||
dt.on( 'preDraw.dt.scroller', function () {
|
||||
that._fnScrollForce();
|
||||
} );
|
||||
|
||||
// Destructor
|
||||
dt.on( 'destroy.scroller', function () {
|
||||
$(window).off( 'resize.dt-scroller' );
|
||||
$(that.dom.scroller).off('.dt-scroller');
|
||||
$(that.s.dt.nTable).off( '.scroller' );
|
||||
|
||||
$(that.s.dt.nTableWrapper).removeClass('DTS');
|
||||
$('div.DTS_Loading', that.dom.scroller.parentNode).remove();
|
||||
|
||||
that.dom.table.style.position = "";
|
||||
that.dom.table.style.top = "";
|
||||
that.dom.table.style.left = "";
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -650,23 +678,19 @@ $.extend( Scroller.prototype, {
|
||||
*/
|
||||
clearTimeout( this.s.stateTO );
|
||||
this.s.stateTO = setTimeout( function () {
|
||||
that.s.dt.oApi._fnSaveState( that.s.dt );
|
||||
that.s.dtApi.state.save();
|
||||
}, 250 );
|
||||
|
||||
/* Check if the scroll point is outside the trigger boundary which would required
|
||||
* a DataTables redraw
|
||||
*/
|
||||
if ( iScrollTop < this.s.redrawTop || iScrollTop > this.s.redrawBottom ) {
|
||||
if ( this.s.forceReposition || iScrollTop < this.s.redrawTop || iScrollTop > this.s.redrawBottom ) {
|
||||
|
||||
var preRows = Math.ceil( ((this.s.displayBuffer-1)/2) * this.s.viewportRows );
|
||||
|
||||
if ( Math.abs( iScrollTop - this.s.lastScrollTop ) > heights.viewport || this.s.ani ) {
|
||||
iTopRow = parseInt(this._domain( 'physicalToVirtual', iScrollTop ) / heights.row, 10) - preRows;
|
||||
this.s.topRowFloat = this._domain( 'physicalToVirtual', iScrollTop ) / heights.row;
|
||||
}
|
||||
else {
|
||||
iTopRow = this.fnPixelsToRow( iScrollTop ) - preRows;
|
||||
this.s.topRowFloat = this.fnPixelsToRow( iScrollTop, false );
|
||||
}
|
||||
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 */
|
||||
@@ -718,7 +742,7 @@ $.extend( Scroller.prototype, {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.s.topRowFloat = this._domain( 'physicalToVirtual', iScrollTop ) / heights.row;
|
||||
this.s.topRowFloat = this.fnPixelsToRow( iScrollTop, false, true );
|
||||
}
|
||||
|
||||
this.s.lastScrollTop = iScrollTop;
|
||||
@@ -783,6 +807,45 @@ $.extend( Scroller.prototype, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -807,8 +870,10 @@ $.extend( Scroller.prototype, {
|
||||
// Disable the scroll event listener while we are updating the DOM
|
||||
this.s.skip = true;
|
||||
|
||||
// Resize the scroll forcing element
|
||||
this._fnScrollForce();
|
||||
// If paging is reset
|
||||
if ( (this.s.dt.bSorted || this.s.dt.bFiltered) && displayStart === 0 ) {
|
||||
this.s.topRowFloat = 0;
|
||||
}
|
||||
|
||||
// Reposition the scrolling for the updated virtual position if needed
|
||||
if ( displayStart === 0 ) {
|
||||
@@ -850,7 +915,9 @@ $.extend( Scroller.prototype, {
|
||||
// scroll event listener
|
||||
var boundaryPx = (iScrollTop - this.s.tableTop) * this.s.boundaryScale;
|
||||
this.s.redrawTop = iScrollTop - boundaryPx;
|
||||
this.s.redrawBottom = iScrollTop + boundaryPx;
|
||||
this.s.redrawBottom = iScrollTop + boundaryPx > heights.scroll - heights.viewport - heights.row ?
|
||||
heights.scroll - heights.viewport - heights.row :
|
||||
iScrollTop + boundaryPx;
|
||||
|
||||
this.s.skip = false;
|
||||
|
||||
@@ -1217,7 +1284,7 @@ Scroller.oDefaults = Scroller.defaults;
|
||||
* @name Scroller.version
|
||||
* @static
|
||||
*/
|
||||
Scroller.version = "1.4.2";
|
||||
Scroller.version = "1.5.1";
|
||||
|
||||
|
||||
|
||||
@@ -1298,11 +1365,11 @@ Api.register( 'scroller().pixelsToRow()', function ( pixels, intParse, virtual )
|
||||
// undefined
|
||||
} );
|
||||
|
||||
// Undocumented and deprecated - use `row().scrollTo()` instead
|
||||
Api.register( 'scroller().scrollToRow()', function ( row, ani ) {
|
||||
// `scroller().scrollToRow()` is undocumented and deprecated. Use `scroller.toPosition()
|
||||
Api.register( ['scroller().scrollToRow()', 'scroller.toPosition()'], function ( idx, ani ) {
|
||||
this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx.oScroller ) {
|
||||
ctx.oScroller.fnScrollToRow( row, ani );
|
||||
ctx.oScroller.fnScrollToRow( idx, ani );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
28
node_modules/datatables.net-scroller/js/dataTables.scroller.min.js
generated
vendored
Normal file
28
node_modules/datatables.net-scroller/js/dataTables.scroller.min.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*!
|
||||
Scroller 1.5.1
|
||||
©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});
|
||||
Reference in New Issue
Block a user