12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307 |
- (function( factory ){
- if ( typeof define === 'function' && define.amd ) {
-
- define( ['jquery', 'datatables.net'], function ( $ ) {
- return factory( $, window, document );
- } );
- }
- else if ( typeof exports === 'object' ) {
-
- module.exports = function (root, $) {
- if ( ! root ) {
- root = window;
- }
- if ( ! $ || ! $.fn.dataTable ) {
- $ = require('datatables.net')(root, $).$;
- }
- return factory( $, root, root.document );
- };
- }
- else {
-
- factory( jQuery, window, document );
- }
- }(function( $, window, document, undefined ) {
- 'use strict';
- var DataTable = $.fn.dataTable;
- var Scroller = function ( dt, opts ) {
-
- if ( ! (this instanceof Scroller) ) {
- alert( "Scroller warning: Scroller must be initialised with the 'new' keyword." );
- return;
- }
- if ( opts === undefined ) {
- opts = {};
- }
- var dtApi = $.fn.dataTable.Api( dt );
-
- this.s = {
-
- dt: dtApi.settings()[0],
-
- dtApi: dtApi,
-
- tableTop: 0,
-
- tableBottom: 0,
-
- redrawTop: 0,
-
- redrawBottom: 0,
-
- autoHeight: true,
-
- 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: false,
- forceReposition: false,
- baseRowTop: 0,
- baseScrollTop: 0,
- mousedown: false,
- lastScrollTop: 0
- };
-
-
- this.s = $.extend( this.s, Scroller.oDefaults, opts );
-
- this.s.heights.row = this.s.rowHeight;
-
- this.dom = {
- "force": document.createElement('div'),
- "label": $('<div class="dts_label">0</div>'),
- "scroller": null,
- "table": null,
- "loader": null
- };
-
-
- if ( this.s.dt.oScroller ) {
- return;
- }
- this.s.dt.oScroller = this;
-
- this.construct();
- };
- $.extend( Scroller.prototype, {
-
-
- measure: function ( redraw )
- {
- if ( this.s.autoHeight )
- {
- this._calcRowHeight();
- }
- 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 ( ! 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;
- }
- var label = this.dom.label.outerHeight();
- heights.labelFactor = (heights.viewport-label) / heights.scroll;
- if ( redraw === undefined || redraw )
- {
- this.s.dt.oInstance.fnDraw( false );
- }
- },
-
- 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
- };
- },
-
- pixelsToRow: function ( pixels, intParse, virtual )
- {
- var diff = pixels - this.s.baseScrollTop;
- var row = virtual ?
- (this._domain( 'physicalToVirtual', this.s.baseScrollTop ) + diff) / this.s.heights.row :
- ( diff / this.s.heights.row ) + this.s.baseRowTop;
- return intParse || intParse === undefined ?
- parseInt( row, 10 ) :
- row;
- },
-
- 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;
- },
-
- scrollToRow: function ( row, animate )
- {
- var that = this;
- var ani = false;
- var px = this.rowToPixels( row );
-
-
-
-
-
- var preRows = ((this.s.displayBuffer-1)/2) * this.s.viewportRows;
- var drawRow = row - preRows;
- if ( drawRow < 0 ) {
- drawRow = 0;
- }
- if ( (px > this.s.redrawBottom || px < this.s.redrawTop) && this.s.dt._iDisplayStart !== drawRow ) {
- ani = true;
- px = this._domain( 'virtualToPhysical', row * this.s.heights.row );
-
-
-
- if ( this.s.redrawTop < px && px < this.s.redrawBottom ) {
- this.s.forceReposition = true;
- animate = false;
- }
- }
- if ( typeof animate == 'undefined' || animate )
- {
- this.s.ani = ani;
- $(this.dom.scroller).animate( {
- "scrollTop": px
- }, function () {
-
-
- setTimeout( function () {
- that.s.ani = false;
- }, 25 );
- } );
- }
- else
- {
- $(this.dom.scroller).scrollTop( px );
- }
- },
-
-
- construct: function ()
- {
- var that = this;
- var dt = this.s.dtApi;
-
- if ( !this.s.dt.oFeatures.bPaginate ) {
- this.s.dt.oApi._fnLog( this.s.dt, 0, 'Pagination must be enabled for Scroller' );
- return;
- }
-
- 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 = $('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 = $('>table', this.dom.scroller)[0];
- this.dom.table.style.position = "absolute";
- this.dom.table.style.top = "0px";
- this.dom.table.style.left = "0px";
-
- $(dt.table().container()).addClass('dts DTS');
-
- if ( this.s.loadingIndicator )
- {
- this.dom.loader = $('<div class="dataTables_processing dts_loading">'+this.s.dt.oLanguage.sLoadingRecords+'</div>')
- .css('display', 'none');
- $(this.dom.scroller.parentNode)
- .css('position', 'relative')
- .append( this.dom.loader );
- }
- this.dom.label.appendTo(this.dom.scroller);
-
- if ( this.s.heights.row && this.s.heights.row != 'auto' )
- {
- this.s.autoHeight = false;
- }
- this.measure( false );
-
-
-
- this.s.ingnoreScroll = true;
- this.s.stateSaveThrottle = this.s.dt.oApi._fnThrottle( function () {
- that.s.dtApi.state.save();
- }, 500 );
- $(this.dom.scroller).on( 'scroll.dt-scroller', function (e) {
- that._scroll.call( that );
- } );
-
-
- $(this.dom.scroller).on('touchstart.dt-scroller', function () {
- 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');
- });
-
- $(window).on( 'resize.dt-scroller', function () {
- that.measure( false );
- that._info();
- } );
-
-
-
-
- var initialStateSave = true;
- var loadedState = dt.state.loaded();
- dt.on( 'stateSaveParams.scroller', function ( e, settings, data ) {
-
- data.scroller = {
- topRow: initialStateSave && loadedState && loadedState.scroller ?
- loadedState.scroller.topRow :
- that.s.topRowFloat,
- baseScrollTop: that.s.baseScrollTop,
- baseRowTop: that.s.baseRowTop
- };
- initialStateSave = false;
- } );
- if ( loadedState && loadedState.scroller ) {
- this.s.topRowFloat = loadedState.scroller.topRow;
- this.s.baseScrollTop = loadedState.scroller.baseScrollTop;
- this.s.baseRowTop = loadedState.scroller.baseRowTop;
- }
- dt.on( 'init.scroller', function () {
- that.measure( false );
- that._draw();
-
- dt.on( 'draw.scroller', function () {
- that._draw();
- });
- } );
-
-
- dt.on( 'preDraw.dt.scroller', function () {
- that._scrollForce();
- } );
-
- 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 = "";
- } );
- },
-
-
- _calcRowHeight: 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>'
- );
-
-
- $('tbody tr:lt(4)', origTable).clone().appendTo( tbody );
- var rowsCount = $('tr', tbody).length;
- if ( rowsCount === 1 ) {
- tbody.prepend('<tr><td> </td></tr>');
- tbody.append('<tr><td> </td></tr>');
- }
- else {
- for (; rowsCount < 3; rowsCount++) {
- tbody.append('<tr><td> </td></tr>');
- }
- }
-
- $('div.'+dt.oClasses.sScrollBody, container).append( nTable );
-
- var insertEl = this.s.dt.nHolding || origTable.parentNode;
- if ( ! $(insertEl).is(':visible') ) {
- insertEl = 'body';
- }
- container.appendTo( insertEl );
- this.s.heights.row = $('tr', tbody).eq(1).outerHeight();
- container.remove();
- },
-
- _draw: function ()
- {
- var
- that = this,
- heights = this.s.heights,
- iScrollTop = this.dom.scroller.scrollTop,
- iActualScrollTop = iScrollTop,
- iScrollBottom = iScrollTop + heights.viewport,
- iTableHeight = $(this.s.dt.nTable).height(),
- displayStart = this.s.dt._iDisplayStart,
- displayLen = this.s.dt._iDisplayLength,
- displayEnd = this.s.dt.fnRecordsDisplay();
-
- this.s.skip = true;
-
- if ( (this.s.dt.bSorted || this.s.dt.bFiltered) && displayStart === 0 && !this.s.dt._drawHold ) {
- this.s.topRowFloat = 0;
- }
- iScrollTop = this.scrollType === 'jump' ?
- this._domain( 'physicalToVirtual', this.s.topRowFloat * heights.row ) :
- iScrollTop;
-
- $(that.dom.scroller).scrollTop(iScrollTop);
-
-
- this.s.baseScrollTop = iScrollTop;
- this.s.baseRowTop = this.s.topRowFloat;
-
- var tableTop = iScrollTop - ((this.s.topRowFloat - displayStart) * heights.row);
- if ( displayStart === 0 ) {
- tableTop = 0;
- }
- else if ( displayStart + displayLen >= displayEnd ) {
- tableTop = heights.scroll - iTableHeight;
- }
- this.dom.table.style.top = tableTop+'px';
-
- this.s.tableTop = tableTop;
- this.s.tableBottom = iTableHeight + this.s.tableTop;
-
-
- var boundaryPx = (iScrollTop - this.s.tableTop) * this.s.boundaryScale;
- this.s.redrawTop = 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;
-
-
-
- if ( this.s.dt.oFeatures.bStateSave && this.s.dt.oLoadedState !== null &&
- typeof this.s.dt.oLoadedState.iScroller != 'undefined' )
- {
-
-
- var ajaxSourced = (this.s.dt.sAjaxSource || that.s.dt.ajax) && ! this.s.dt.oFeatures.bServerSide ?
- true :
- false;
- if ( ( ajaxSourced && this.s.dt.iDraw == 2) ||
- (!ajaxSourced && this.s.dt.iDraw == 1) )
- {
- setTimeout( function () {
- $(that.dom.scroller).scrollTop( that.s.dt.oLoadedState.iScroller );
- that.s.redrawTop = that.s.dt.oLoadedState.iScroller - (heights.viewport/2);
-
-
- setTimeout( function () {
- that.s.ingnoreScroll = false;
- }, 0 );
- }, 0 );
- }
- }
- else {
- that.s.ingnoreScroll = false;
- }
-
-
-
- if ( this.s.dt.oFeatures.bInfo ) {
- setTimeout( function () {
- that._info.call( that );
- }, 0 );
- }
-
- if ( this.dom.loader && this.s.loaderVisible ) {
- this.dom.loader.css( 'display', 'none' );
- this.s.loaderVisible = false;
- }
- },
-
- _domain: function ( dir, val )
- {
- var heights = this.s.heights;
- var diff;
- var magic = 10000;
-
-
- if ( heights.virtual === heights.scroll ) {
- return val;
- }
-
-
-
- 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;
- }
-
-
-
-
-
-
-
-
- var xMax = dir === 'virtualToPhysical' ?
- heights.virtual :
- heights.scroll;
- var yMax = dir === 'virtualToPhysical' ?
- heights.scroll :
- heights.virtual;
- var m = (yMax - magic) / (xMax - magic);
- var c = magic - (m*magic);
- return (m*val) + c;
- },
-
- _info: function ()
- {
- if ( !this.s.dt.oFeatures.bInfo )
- {
- return;
- }
- var
- dt = this.s.dt,
- language = dt.oLanguage,
- iScrollTop = this.dom.scroller.scrollTop,
- iStart = Math.floor( this.pixelsToRow(iScrollTop, false, this.s.ani)+1 ),
- iMax = dt.fnRecordsTotal(),
- iTotal = dt.fnRecordsDisplay(),
- iPossibleEnd = Math.ceil( this.pixelsToRow(iScrollTop+this.s.heights.viewport, false, this.s.ani) ),
- iEnd = iTotal < iPossibleEnd ? iTotal : iPossibleEnd,
- sStart = dt.fnFormatNumber( iStart ),
- sEnd = dt.fnFormatNumber( iEnd ),
- sMax = dt.fnFormatNumber( iMax ),
- sTotal = dt.fnFormatNumber( iTotal ),
- sOut;
- if ( dt.fnRecordsDisplay() === 0 &&
- dt.fnRecordsDisplay() == dt.fnRecordsTotal() )
- {
-
- sOut = language.sInfoEmpty+ language.sInfoPostFix;
- }
- else if ( dt.fnRecordsDisplay() === 0 )
- {
-
- sOut = language.sInfoEmpty +' '+
- language.sInfoFiltered.replace('_MAX_', sMax)+
- language.sInfoPostFix;
- }
- else if ( dt.fnRecordsDisplay() == dt.fnRecordsTotal() )
- {
-
- sOut = language.sInfo.
- replace('_START_', sStart).
- replace('_END_', sEnd).
- replace('_MAX_', sMax).
- replace('_TOTAL_', sTotal)+
- language.sInfoPostFix;
- }
- else
- {
-
- sOut = language.sInfo.
- replace('_START_', sStart).
- replace('_END_', sEnd).
- replace('_MAX_', sMax).
- replace('_TOTAL_', sTotal) +' '+
- language.sInfoFiltered.replace(
- '_MAX_',
- dt.fnFormatNumber(dt.fnRecordsTotal())
- )+
- language.sInfoPostFix;
- }
- var callback = language.fnInfoCallback;
- if ( callback ) {
- sOut = callback.call( dt.oInstance,
- dt, iStart, iEnd, iMax, iTotal, sOut
- );
- }
- var n = dt.aanFeatures.i;
- if ( typeof n != 'undefined' )
- {
- for ( var i=0, iLen=n.length ; i<iLen ; i++ )
- {
- $(n[i]).html( sOut );
- }
- }
-
- $(dt.nTable).triggerHandler( 'info.dt' );
- },
-
- _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;
- },
-
- _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 ( this.s.dt.bFiltered || this.s.dt.bSorted ) {
- this.s.lastScrollTop = 0;
- return;
- }
-
- this._info();
-
- 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;
- }
-
- 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 ) {
-
- iTopRow = 0;
- }
- else if ( iTopRow + this.s.dt._iDisplayLength > this.s.dt.fnRecordsDisplay() ) {
-
- iTopRow = this.s.dt.fnRecordsDisplay() - this.s.dt._iDisplayLength;
- if ( iTopRow < 0 ) {
- iTopRow = 0;
- }
- }
- else if ( iTopRow % 2 !== 0 ) {
-
-
-
- iTopRow++;
- }
- if ( iTopRow != this.s.dt._iDisplayStart ) {
-
- 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 );
- };
-
- 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' );
- }
- },
-
- _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;
- }
-
-
- this.dom.force.style.height = heights.scroll > this.s.heights.row ?
- heights.scroll+'px' :
- this.s.heights.row+'px';
- }
- } );
- Scroller.defaults = {
-
- boundaryScale: 0.5,
-
- displayBuffer: 9,
-
- loadingIndicator: false,
-
- rowHeight: "auto",
-
- serverWait: 200
- };
- Scroller.oDefaults = Scroller.defaults;
- Scroller.version = "2.0.0";
- $(document).on( 'preInit.dt.dtscroller', function (e, settings) {
- if ( e.namespace !== 'dt' ) {
- return;
- }
- var init = settings.oInit.scroller;
- var defaults = DataTable.defaults.scroller;
- if ( init || defaults ) {
- var opts = $.extend( {}, init, defaults );
- if ( init !== false ) {
- new Scroller( settings, opts );
- }
- }
- } );
- $.fn.dataTable.Scroller = Scroller;
- $.fn.DataTable.Scroller = Scroller;
- var Api = $.fn.dataTable.Api;
- Api.register( 'scroller()', function () {
- return this;
- } );
- Api.register( 'scroller().rowToPixels()', function ( rowIdx, intParse, virtual ) {
- var ctx = this.context;
- if ( ctx.length && ctx[0].oScroller ) {
- return ctx[0].oScroller.rowToPixels( rowIdx, intParse, virtual );
- }
-
- } );
- Api.register( 'scroller().pixelsToRow()', function ( pixels, intParse, virtual ) {
- var ctx = this.context;
- if ( ctx.length && ctx[0].oScroller ) {
- return ctx[0].oScroller.pixelsToRow( pixels, intParse, virtual );
- }
-
- } );
- Api.register( ['scroller().scrollToRow()', 'scroller.toPosition()'], function ( idx, ani ) {
- this.iterator( 'table', function ( ctx ) {
- if ( ctx.oScroller ) {
- ctx.oScroller.scrollToRow( idx, ani );
- }
- } );
- return this;
- } );
- Api.register( 'row().scrollTo()', function ( ani ) {
- var that = this;
- this.iterator( 'row', function ( ctx, rowIdx ) {
- if ( ctx.oScroller ) {
- var displayIdx = that
- .rows( { order: 'applied', search: 'applied' } )
- .indexes()
- .indexOf( rowIdx );
- ctx.oScroller.scrollToRow( displayIdx, ani );
- }
- } );
- return this;
- } );
- Api.register( 'scroller.measure()', function ( redraw ) {
- this.iterator( 'table', function ( ctx ) {
- if ( ctx.oScroller ) {
- ctx.oScroller.measure( redraw );
- }
- } );
- return this;
- } );
- Api.register( 'scroller.page()', function() {
- var ctx = this.context;
- if ( ctx.length && ctx[0].oScroller ) {
- return ctx[0].oScroller.pageInfo();
- }
-
- } );
- return Scroller;
- }));
|