New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

datatables.net-scroller

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatables.net-scroller - npm Package Compare versions

Comparing version 2.0.7 to 2.1.0

js/dataTables.scroller.min.mjs

71

js/dataTables.scroller.js

@@ -1,23 +0,5 @@

/*! Scroller 2.0.7
/*! Scroller 2.1.0
* ©2011-2022 SpryMedia Ltd - datatables.net/license
*/
/**
* @summary Scroller
* @description Virtual rendering for DataTables
* @version 2.0.7
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
* @copyright SpryMedia Ltd.
*
* This source file is free software, available under the following license:
* MIT license - http://datatables.net/license/mit
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*
* For details please refer to: http://www.datatables.net
*/
(function( factory ){

@@ -34,9 +16,17 @@ if ( typeof define === 'function' && define.amd ) {

if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}
if ( ! $ || ! $.fn.dataTable ) {
$ = require('datatables.net')(root, $).$;
if ( ! $ ) {
$ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
require('jquery') :
require('jquery')( root );
}
if ( ! $.fn.dataTable ) {
require('datatables.net')(root, $);
}
return factory( $, root, root.document );

@@ -54,3 +44,23 @@ };

/**
* @summary Scroller
* @description Virtual rendering for DataTables
* @version 2.1.0
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
* @copyright SpryMedia Ltd.
*
* This source file is free software, available under the following license:
* MIT license - http://datatables.net/license/mit
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*
* For details please refer to: http://www.datatables.net
*/
/**
* Scroller is a virtual rendering plug-in for DataTables which allows large

@@ -682,3 +692,4 @@ * datasets to be drawn on screen every quickly. What the virtual rendering means

displayLen = this.s.dt._iDisplayLength,
displayEnd = this.s.dt.fnRecordsDisplay();
displayEnd = this.s.dt.fnRecordsDisplay(),
viewportEndY = iScrollTop + heights.viewport;

@@ -710,2 +721,13 @@ // Disable the scroll event listener while we are updating the DOM

}
else {
var iTableBottomY = tableTop + iTableHeight;
if (iTableBottomY < viewportEndY) {
// The last row of the data is above the end of the viewport.
// This means the background is visible, which is not what the user expects.
var newTableTop = viewportEndY - iTableHeight;
var diffPx = newTableTop - tableTop;
this.s.baseScrollTop += diffPx + 1; // Update start row number in footer.
tableTop = newTableTop; // Move table so last line of data is at the bottom of the viewport.
}
}

@@ -1218,3 +1240,3 @@ this.dom.table.style.top = tableTop+'px';

*/
Scroller.version = "2.0.7";
Scroller.version = "2.1.0";

@@ -1326,3 +1348,4 @@

return Scroller;
return DataTable;
}));

@@ -1,45 +0,4 @@

/*!
SpryMedia Ltd.
This source file is free software, available under the following license:
MIT license - http://datatables.net/license/mit
This source file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
For details please refer to: http://www.datatables.net
Scroller 2.0.7
©2011-2022 SpryMedia Ltd - datatables.net/license
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,f,g){c instanceof String&&(c=String(c));for(var h=c.length,l=0;l<h;l++){var m=c[l];if(f.call(g,m,l,c))return{i:l,v:m}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(c,f,g){if(c==Array.prototype||c==Object.prototype)return c;c[f]=g.value;return c};$jscomp.getGlobal=function(c){c=["object"==typeof globalThis&&globalThis,c,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var f=0;f<c.length;++f){var g=c[f];if(g&&g.Math==Math)return g}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(c,f){var g=$jscomp.propertyToPolyfillSymbol[f];if(null==g)return c[f];g=c[g];return void 0!==g?g:c[f]};
$jscomp.polyfill=function(c,f,g,h){f&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(c,f,g,h):$jscomp.polyfillUnisolated(c,f,g,h))};$jscomp.polyfillUnisolated=function(c,f,g,h){g=$jscomp.global;c=c.split(".");for(h=0;h<c.length-1;h++){var l=c[h];if(!(l in g))return;g=g[l]}c=c[c.length-1];h=g[c];f=f(h);f!=h&&null!=f&&$jscomp.defineProperty(g,c,{configurable:!0,writable:!0,value:f})};
$jscomp.polyfillIsolated=function(c,f,g,h){var l=c.split(".");c=1===l.length;h=l[0];h=!c&&h in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var m=0;m<l.length-1;m++){var q=l[m];if(!(q in h))return;h=h[q]}l=l[l.length-1];g=$jscomp.IS_SYMBOL_NATIVE&&"es6"===g?h[l]:null;f=f(g);null!=f&&(c?$jscomp.defineProperty($jscomp.polyfills,l,{configurable:!0,writable:!0,value:f}):f!==g&&($jscomp.propertyToPolyfillSymbol[l]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(l):$jscomp.POLYFILL_PREFIX+l,l=
$jscomp.propertyToPolyfillSymbol[l],$jscomp.defineProperty(h,l,{configurable:!0,writable:!0,value:f})))};$jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(f,g){return $jscomp.findInternal(this,f,g).v}},"es6","es3");
(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(f){return c(f,window,document)}):"object"===typeof exports?module.exports=function(f,g){f||(f=window);g&&g.fn.dataTable||(g=require("datatables.net")(f,g).$);return c(g,f,f.document)}:c(jQuery,window,document)})(function(c,f,g,h){var l=c.fn.dataTable,m=function(a,b){this instanceof m?(b===h&&(b={}),a=c.fn.dataTable.Api(a),this.s={dt:a.settings()[0],dtApi:a,tableTop:0,tableBottom:0,redrawTop:0,redrawBottom:0,
autoHeight:!0,viewportRows:0,stateTO:null,stateSaveThrottle:function(){},drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null,labelHeight:0,xbar:0},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1,forceReposition:!1,baseRowTop:0,baseScrollTop:0,mousedown:!1,lastScrollTop:0},this.s=c.extend(this.s,m.oDefaults,b),this.s.heights.row=this.s.rowHeight,this.dom={force:g.createElement("div"),label:c('<div class="dts_label">0</div>'),scroller:null,table:null,loader:null},
this.s.dt.oScroller||(this.s.dt.oScroller=this,this.construct())):alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")};c.extend(m.prototype,{measure:function(a){this.s.autoHeight&&this._calcRowHeight();var b=this.s.heights;b.row&&(b.viewport=this._parseHeight(c(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);var d=this.dom.label.outerHeight();b.xbar=this.dom.scroller.offsetHeight-
this.dom.scroller.clientHeight;b.labelHeight=d;(a===h||a)&&this.s.dt.oInstance.fnDraw(!1)},pageInfo:function(){var a=this.dom.scroller.scrollTop,b=this.s.dt.fnRecordsDisplay(),d=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:b<d?b-1:d-1}},pixelsToRow:function(a,b,d){a-=this.s.baseScrollTop;d=d?(this._domain("physicalToVirtual",this.s.baseScrollTop)+a)/this.s.heights.row:a/this.s.heights.row+this.s.baseRowTop;return b||
b===h?parseInt(d,10):d},rowToPixels:function(a,b,d){a-=this.s.baseRowTop;d=d?this._domain("virtualToPhysical",this.s.baseScrollTop):this.s.baseScrollTop;d+=a*this.s.heights.row;return b||b===h?parseInt(d,10):d},scrollToRow:function(a,b){var d=this,e=!1,k=this.rowToPixels(a),n=a-(this.s.displayBuffer-1)/2*this.s.viewportRows;0>n&&(n=0);(k>this.s.redrawBottom||k<this.s.redrawTop)&&this.s.dt._iDisplayStart!==n&&(e=!0,k=this._domain("virtualToPhysical",a*this.s.heights.row),this.s.redrawTop<k&&k<this.s.redrawBottom&&
(this.s.forceReposition=!0,b=!1));b===h||b?(this.s.ani=e,c(this.dom.scroller).animate({scrollTop:k},function(){setTimeout(function(){d.s.ani=!1},250)})):c(this.dom.scroller).scrollTop(k)},construct: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=c("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=c(">table",this.dom.scroller)[0];this.dom.table.style.position="absolute";this.dom.table.style.top="0px";this.dom.table.style.left="0px";c(b.table().container()).addClass("dts DTS");this.s.loadingIndicator&&(this.dom.loader=c('<div class="dataTables_processing dts_loading">'+this.s.dt.oLanguage.sLoadingRecords+"</div>").css("display","none"),c(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.s.ingnoreScroll=!0;c(this.dom.scroller).on("scroll.dt-scroller",function(k){a._scroll.call(a)});c(this.dom.scroller).on("touchstart.dt-scroller",function(){a._scroll.call(a)});c(this.dom.scroller).on("mousedown.dt-scroller",function(){a.s.mousedown=!0}).on("mouseup.dt-scroller",function(){a.s.labelVisible=!1;a.s.mousedown=!1;a.dom.label.css("display","none")});c(f).on("resize.dt-scroller",function(){a.measure(!1);a._info()});
var d=!0,e=b.state.loaded();b.on("stateSaveParams.scroller",function(k,n,p){d&&e?(p.scroller=e.scroller,d=!1,p.scroller&&(a.s.lastScrollTop=p.scroller.scrollTop)):p.scroller={topRow:a.s.topRowFloat,baseScrollTop:a.s.baseScrollTop,baseRowTop:a.s.baseRowTop,scrollTop:a.s.lastScrollTop}});b.on("stateLoadParams.scroller",function(k,n,p){p.scroller!==h&&a.scrollToRow(p.scroller.topRow)});e&&e.scroller&&(this.s.topRowFloat=e.scroller.topRow,this.s.baseScrollTop=e.scroller.baseScrollTop,this.s.baseRowTop=
e.scroller.baseRowTop);this.measure(!1);a.s.stateSaveThrottle=a.s.dt.oApi._fnThrottle(function(){a.s.dtApi.state.save()},500);b.on("init.scroller",function(){a.measure(!1);a.s.scrollType="jump";a._draw();b.on("draw.scroller",function(){a._draw()})});b.on("preDraw.dt.scroller",function(){a._scrollForce()});b.on("destroy.scroller",function(){c(f).off("resize.dt-scroller");c(a.dom.scroller).off(".dt-scroller");c(a.s.dt.nTable).off(".scroller");c(a.s.dt.nTableWrapper).removeClass("DTS");c("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,b=a.nTable,d=b.cloneNode(!1),e=c("<tbody/>").appendTo(d),k=c('<div class="'+a.oClasses.sWrapper+' DTS"><div class="'+a.oClasses.sScrollWrapper+'"><div class="'+a.oClasses.sScrollBody+'"></div></div></div>');c("tbody tr:lt(4)",b).clone().appendTo(e);var n=c("tr",
e).length;if(1===n)e.prepend("<tr><td>&#160;</td></tr>"),e.append("<tr><td>&#160;</td></tr>");else for(;3>n;n++)e.append("<tr><td>&#160;</td></tr>");c("div."+a.oClasses.sScrollBody,k).append(d);a=this.s.dt.nHolding||b.parentNode;c(a).is(":visible")||(a="body");k.find("input").removeAttr("name");k.appendTo(a);this.s.heights.row=c("tr",e).eq(1).outerHeight();k.remove()},_draw:function(){var a=this,b=this.s.heights,d=this.dom.scroller.scrollTop,e=c(this.s.dt.nTable).height(),k=this.s.dt._iDisplayStart,
n=this.s.dt._iDisplayLength,p=this.s.dt.fnRecordsDisplay();this.s.skip=!0;!this.s.dt.bSorted&&!this.s.dt.bFiltered||0!==k||this.s.dt._drawHold||(this.s.topRowFloat=0);d="jump"===this.s.scrollType?this._domain("virtualToPhysical",this.s.topRowFloat*b.row):d;this.s.baseScrollTop=d;this.s.baseRowTop=this.s.topRowFloat;var r=d-(this.s.topRowFloat-k)*b.row;0===k?r=0:k+n>=p&&(r=b.scroll-e);this.dom.table.style.top=r+"px";this.s.tableTop=r;this.s.tableBottom=e+this.s.tableTop;e=(d-this.s.tableTop)*this.s.boundaryScale;
this.s.redrawTop=d-e;this.s.redrawBottom=d+e>b.scroll-b.viewport-b.row?b.scroll-b.viewport-b.row:d+e;this.s.skip=!1;a.s.ingnoreScroll&&(this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&"undefined"!=typeof this.s.dt.oLoadedState.scroller?((b=!this.s.dt.sAjaxSource&&!a.s.dt.ajax||this.s.dt.oFeatures.bServerSide?!1:!0)&&2<=this.s.dt.iDraw||!b&&1<=this.s.dt.iDraw)&&setTimeout(function(){c(a.dom.scroller).scrollTop(a.s.dt.oLoadedState.scroller.scrollTop);setTimeout(function(){a.s.ingnoreScroll=
!1},0)},0):a.s.ingnoreScroll=!1);this.s.dt.oFeatures.bInfo&&setTimeout(function(){a._info.call(a)},0);c(this.s.dt.nTable).triggerHandler("position.dts.dt",r);this.dom.loader&&this.s.loaderVisible&&(this.dom.loader.css("display","none"),this.s.loaderVisible=!1)},_domain:function(a,b){var d=this.s.heights;if(d.virtual===d.scroll||1E4>b)return b;if("virtualToPhysical"===a&&b>=d.virtual-1E4)return a=d.virtual-b,d.scroll-a;if("physicalToVirtual"===a&&b>=d.scroll-1E4)return a=d.scroll-b,d.virtual-a;d=(d.virtual-
1E4-1E4)/(d.scroll-1E4-1E4);var e=1E4-1E4*d;return"virtualToPhysical"===a?(b-e)/d:d*b+e},_info:function(){if(this.s.dt.oFeatures.bInfo){var a=this.s.dt,b=a.oLanguage,d=this.dom.scroller.scrollTop,e=Math.floor(this.pixelsToRow(d,!1,this.s.ani)+1),k=a.fnRecordsTotal(),n=a.fnRecordsDisplay();d=Math.ceil(this.pixelsToRow(d+this.s.heights.viewport,!1,this.s.ani));d=n<d?n:d;var p=a.fnFormatNumber(e),r=a.fnFormatNumber(d),t=a.fnFormatNumber(k),u=a.fnFormatNumber(n);p=0===a.fnRecordsDisplay()&&a.fnRecordsDisplay()==
a.fnRecordsTotal()?b.sInfoEmpty+b.sInfoPostFix:0===a.fnRecordsDisplay()?b.sInfoEmpty+" "+b.sInfoFiltered.replace("_MAX_",t)+b.sInfoPostFix:a.fnRecordsDisplay()==a.fnRecordsTotal()?b.sInfo.replace("_START_",p).replace("_END_",r).replace("_MAX_",t).replace("_TOTAL_",u)+b.sInfoPostFix:b.sInfo.replace("_START_",p).replace("_END_",r).replace("_MAX_",t).replace("_TOTAL_",u)+" "+b.sInfoFiltered.replace("_MAX_",a.fnFormatNumber(a.fnRecordsTotal()))+b.sInfoPostFix;(b=b.fnInfoCallback)&&(p=b.call(a.oInstance,
a,e,d,k,n,p));e=a.aanFeatures.i;if("undefined"!=typeof e)for(k=0,n=e.length;k<n;k++)c(e[k]).html(p);c(a.nTable).triggerHandler("info.dt")}},_parseHeight:function(a){var b,d=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(a);if(null===d)return 0;a=parseFloat(d[1]);d=d[2];"px"===d?b=a:"vh"===d?b=a/100*c(f).height():"rem"===d?b=a*parseFloat(c(":root").css("font-size")):"em"===d&&(b=a*parseFloat(c("body").css("font-size")));return b?b:0},_scroll:function(){var a=this,b=this.s.heights,d=this.dom.scroller.scrollTop;
if(!this.s.skip&&!this.s.ingnoreScroll&&d!==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(d-this.s.lastScrollTop)>b.viewport?"jump":"cont";this.s.topRowFloat="cont"===this.s.scrollType?this.pixelsToRow(d,!1,!1):this._domain("physicalToVirtual",d)/b.row;0>this.s.topRowFloat&&(this.s.topRowFloat=0);if(this.s.forceReposition||
d<this.s.redrawTop||d>this.s.redrawBottom){var e=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows);e=parseInt(this.s.topRowFloat,10)-e;this.s.forceReposition=!1;0>=e?e=0:e+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(e=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength,0>e&&(e=0)):0!==e%2&&e++;this.s.targetTop=e;e!=this.s.dt._iDisplayStart&&(this.s.tableTop=c(this.s.dt.nTable).offset().top,this.s.tableBottom=c(this.s.dt.nTable).height()+this.s.tableTop,e=function(){a.s.dt._iDisplayStart=
a.s.targetTop;a.s.dt.oApi._fnDraw(a.s.dt)},this.s.dt.oFeatures.bServerSide?(this.s.forceReposition=!0,clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(e,this.s.serverWait)):e(),this.dom.loader&&!this.s.loaderVisible&&(this.dom.loader.css("display","block"),this.s.loaderVisible=!0))}else this.s.topRowFloat=this.pixelsToRow(d,!1,!0);this.s.lastScrollTop=d;this.s.stateSaveThrottle();"jump"===this.s.scrollType&&this.s.mousedown&&(this.s.labelVisible=!0);this.s.labelVisible&&(b=(b.viewport-b.labelHeight-
b.xbar)/b.scroll,this.dom.label.html(this.s.dt.fnFormatNumber(parseInt(this.s.topRowFloat,10)+1)).css("top",d+d*b).css("right",10-this.dom.scroller.scrollLeft).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"}});m.defaults={boundaryScale:.5,displayBuffer:9,loadingIndicator:!1,rowHeight:"auto",
serverWait:200};m.oDefaults=m.defaults;m.version="2.0.7";c(g).on("preInit.dt.dtscroller",function(a,b){if("dt"===a.namespace){a=b.oInit.scroller;var d=l.defaults.scroller;if(a||d)d=c.extend({},a,d),!1!==a&&new m(b,d)}});c.fn.dataTable.Scroller=m;c.fn.DataTable.Scroller=m;var q=c.fn.dataTable.Api;q.register("scroller()",function(){return this});q.register("scroller().rowToPixels()",function(a,b,d){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.rowToPixels(a,b,d)});q.register("scroller().pixelsToRow()",
function(a,b,d){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.pixelsToRow(a,b,d)});q.register(["scroller().scrollToRow()","scroller.toPosition()"],function(a,b){this.iterator("table",function(d){d.oScroller&&d.oScroller.scrollToRow(a,b)});return this});q.register("row().scrollTo()",function(a){var b=this;this.iterator("row",function(d,e){d.oScroller&&(e=b.rows({order:"applied",search:"applied"}).indexes().indexOf(e),d.oScroller.scrollToRow(e,a))});return this});q.register("scroller.measure()",
function(a){this.iterator("table",function(b){b.oScroller&&b.oScroller.measure(a)});return this});q.register("scroller.page()",function(){var a=this.context;if(a.length&&a[0].oScroller)return a[0].oScroller.pageInfo()});return m});
/*! Scroller 2.1.0
* ©2011-2022 SpryMedia Ltd - datatables.net/license
*/
!function(o){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(s){return o(s,window,document)}):"object"==typeof exports?module.exports=function(s,t){return s=s||window,(t=t||("undefined"!=typeof window?require("jquery"):require("jquery")(s))).fn.dataTable||require("datatables.net")(s,t),o(t,s,s.document)}:o(jQuery,window,document)}(function(f,i,o,a){"use strict";function e(s,t){this instanceof e?(t===a&&(t={}),s=f.fn.dataTable.Api(s),this.s={dt:s.settings()[0],dtApi:s,tableTop:0,tableBottom:0,redrawTop:0,redrawBottom:0,autoHeight:!0,viewportRows:0,stateTO:null,stateSaveThrottle:function(){},drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null,labelHeight:0,xbar:0},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1,forceReposition:!1,baseRowTop:0,baseScrollTop:0,mousedown:!1,lastScrollTop:0},this.s=f.extend(this.s,e.oDefaults,t),this.s.heights.row=this.s.rowHeight,this.dom={force:o.createElement("div"),label:f('<div class="dts_label">0</div>'),scroller:null,table:null,loader:null},this.s.dt.oScroller||(this.s.dt.oScroller=this).construct()):alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")}var l=f.fn.dataTable,s=(f.extend(e.prototype,{measure:function(s){this.s.autoHeight&&this._calcRowHeight();var t=this.s.heights,o=(t.row&&(t.viewport=this._parseHeight(f(this.dom.scroller).css("max-height")),this.s.viewportRows=parseInt(t.viewport/t.row,10)+1,this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer),this.dom.label.outerHeight());t.xbar=this.dom.scroller.offsetHeight-this.dom.scroller.clientHeight,t.labelHeight=o,s!==a&&!s||this.s.dt.oInstance.fnDraw(!1)},pageInfo:function(){var s=this.s.dt,t=this.dom.scroller.scrollTop,s=s.fnRecordsDisplay(),o=Math.ceil(this.pixelsToRow(t+this.s.heights.viewport,!1,this.s.ani));return{start:Math.floor(this.pixelsToRow(t,!1,this.s.ani)),end:s<o?s-1:o-1}},pixelsToRow:function(s,t,o){s-=this.s.baseScrollTop,o=o?(this._domain("physicalToVirtual",this.s.baseScrollTop)+s)/this.s.heights.row:s/this.s.heights.row+this.s.baseRowTop;return t||t===a?parseInt(o,10):o},rowToPixels:function(s,t,o){s-=this.s.baseRowTop,o=o?this._domain("virtualToPhysical",this.s.baseScrollTop):this.s.baseScrollTop;return o+=s*this.s.heights.row,t||t===a?parseInt(o,10):o},scrollToRow:function(s,t){var o=this,e=!1,l=this.rowToPixels(s),r=s-(this.s.displayBuffer-1)/2*this.s.viewportRows;r<0&&(r=0),(l>this.s.redrawBottom||l<this.s.redrawTop)&&this.s.dt._iDisplayStart!==r&&(e=!0,l=this._domain("virtualToPhysical",s*this.s.heights.row),this.s.redrawTop<l&&l<this.s.redrawBottom&&(t=!(this.s.forceReposition=!0))),t===a||t?(this.s.ani=e,f(this.dom.scroller).animate({scrollTop:l},function(){setTimeout(function(){o.s.ani=!1},250)})):f(this.dom.scroller).scrollTop(l)},construct:function(){var e,l,r=this,s=this.s.dtApi;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=f("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=f(">table",this.dom.scroller)[0],this.dom.table.style.position="absolute",this.dom.table.style.top="0px",this.dom.table.style.left="0px",f(s.table().container()).addClass("dts DTS"),this.s.loadingIndicator&&(this.dom.loader=f('<div class="dataTables_processing dts_loading">'+this.s.dt.oLanguage.sLoadingRecords+"</div>").css("display","none"),f(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.s.ingnoreScroll=!0,f(this.dom.scroller).on("scroll.dt-scroller",function(s){r._scroll.call(r)}),f(this.dom.scroller).on("touchstart.dt-scroller",function(){r._scroll.call(r)}),f(this.dom.scroller).on("mousedown.dt-scroller",function(){r.s.mousedown=!0}).on("mouseup.dt-scroller",function(){r.s.labelVisible=!1,r.s.mousedown=!1,r.dom.label.css("display","none")}),f(i).on("resize.dt-scroller",function(){r.measure(!1),r._info()}),e=!0,l=s.state.loaded(),s.on("stateSaveParams.scroller",function(s,t,o){e&&l?(o.scroller=l.scroller,e=!1,o.scroller&&(r.s.lastScrollTop=o.scroller.scrollTop)):o.scroller={topRow:r.s.topRowFloat,baseScrollTop:r.s.baseScrollTop,baseRowTop:r.s.baseRowTop,scrollTop:r.s.lastScrollTop}}),s.on("stateLoadParams.scroller",function(s,t,o){o.scroller!==a&&r.scrollToRow(o.scroller.topRow)}),l&&l.scroller&&(this.s.topRowFloat=l.scroller.topRow,this.s.baseScrollTop=l.scroller.baseScrollTop,this.s.baseRowTop=l.scroller.baseRowTop),this.measure(!1),r.s.stateSaveThrottle=r.s.dt.oApi._fnThrottle(function(){r.s.dtApi.state.save()},500),s.on("init.scroller",function(){r.measure(!1),r.s.scrollType="jump",r._draw(),s.on("draw.scroller",function(){r._draw()})}),s.on("preDraw.dt.scroller",function(){r._scrollForce()}),s.on("destroy.scroller",function(){f(i).off("resize.dt-scroller"),f(r.dom.scroller).off(".dt-scroller"),f(r.s.dt.nTable).off(".scroller"),f(r.s.dt.nTableWrapper).removeClass("DTS"),f("div.DTS_Loading",r.dom.scroller.parentNode).remove(),r.dom.table.style.position="",r.dom.table.style.top="",r.dom.table.style.left=""})):this.s.dt.oApi._fnLog(this.s.dt,0,"Pagination must be enabled for Scroller")},_calcRowHeight:function(){var s=this.s.dt,t=s.nTable,o=t.cloneNode(!1),e=f("<tbody/>").appendTo(o),l=f('<div class="'+s.oClasses.sWrapper+' DTS"><div class="'+s.oClasses.sScrollWrapper+'"><div class="'+s.oClasses.sScrollBody+'"></div></div></div>'),r=(f("tbody tr:lt(4)",t).clone().appendTo(e),f("tr",e).length);if(1===r)e.prepend("<tr><td>&#160;</td></tr>"),e.append("<tr><td>&#160;</td></tr>");else for(;r<3;r++)e.append("<tr><td>&#160;</td></tr>");f("div."+s.oClasses.sScrollBody,l).append(o);s=this.s.dt.nHolding||t.parentNode;f(s).is(":visible")||(s="body"),l.find("input").removeAttr("name"),l.appendTo(s),this.s.heights.row=f("tr",e).eq(1).outerHeight(),l.remove()},_draw:function(){var s=this,t=this.s.heights,o=this.dom.scroller.scrollTop,e=f(this.s.dt.nTable).height(),l=this.s.dt._iDisplayStart,r=this.s.dt._iDisplayLength,i=this.s.dt.fnRecordsDisplay(),a=o+t.viewport,n=(this.s.skip=!0,!this.s.dt.bSorted&&!this.s.dt.bFiltered||0!==l||this.s.dt._drawHold||(this.s.topRowFloat=0),o="jump"===this.s.scrollType?this._domain("virtualToPhysical",this.s.topRowFloat*t.row):o,this.s.baseScrollTop=o,this.s.baseRowTop=this.s.topRowFloat,o-(this.s.topRowFloat-l)*t.row),l=(0===l?n=0:i<=l+r?n=t.scroll-e:n+e<a&&(this.s.baseScrollTop+=1+((i=a-e)-n),n=i),this.dom.table.style.top=n+"px",this.s.tableTop=n,this.s.tableBottom=e+this.s.tableTop,(o-this.s.tableTop)*this.s.boundaryScale);this.s.redrawTop=o-l,this.s.redrawBottom=o+l>t.scroll-t.viewport-t.row?t.scroll-t.viewport-t.row:o+l,this.s.skip=!1,s.s.ingnoreScroll&&(this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&void 0!==this.s.dt.oLoadedState.scroller?((r=!(!this.s.dt.sAjaxSource&&!s.s.dt.ajax||this.s.dt.oFeatures.bServerSide))&&2<=this.s.dt.iDraw||!r&&1<=this.s.dt.iDraw)&&setTimeout(function(){f(s.dom.scroller).scrollTop(s.s.dt.oLoadedState.scroller.scrollTop),setTimeout(function(){s.s.ingnoreScroll=!1},0)},0):s.s.ingnoreScroll=!1),this.s.dt.oFeatures.bInfo&&setTimeout(function(){s._info.call(s)},0),f(this.s.dt.nTable).triggerHandler("position.dts.dt",n),this.dom.loader&&this.s.loaderVisible&&(this.dom.loader.css("display","none"),this.s.loaderVisible=!1)},_domain:function(s,t){var o,e=this.s.heights,l=1e4;return e.virtual===e.scroll||t<l?t:"virtualToPhysical"===s&&t>=e.virtual-l?(o=e.virtual-t,e.scroll-o):"physicalToVirtual"===s&&t>=e.scroll-l?(o=e.scroll-t,e.virtual-o):(e=l-(o=(e.virtual-l-l)/(e.scroll-l-l))*l,"virtualToPhysical"===s?(t-e)/o:o*t+e)},_info:function(){if(this.s.dt.oFeatures.bInfo){var s=this.s.dt,t=s.oLanguage,o=this.dom.scroller.scrollTop,e=Math.floor(this.pixelsToRow(o,!1,this.s.ani)+1),l=s.fnRecordsTotal(),r=s.fnRecordsDisplay(),o=Math.ceil(this.pixelsToRow(o+this.s.heights.viewport,!1,this.s.ani)),o=r<o?r:o,i=s.fnFormatNumber(e),a=s.fnFormatNumber(o),n=s.fnFormatNumber(l),h=s.fnFormatNumber(r),c=0===s.fnRecordsDisplay()&&s.fnRecordsDisplay()==s.fnRecordsTotal()?t.sInfoEmpty+t.sInfoPostFix:0===s.fnRecordsDisplay()?t.sInfoEmpty+" "+t.sInfoFiltered.replace("_MAX_",n)+t.sInfoPostFix:s.fnRecordsDisplay()==s.fnRecordsTotal()?t.sInfo.replace("_START_",i).replace("_END_",a).replace("_MAX_",n).replace("_TOTAL_",h)+t.sInfoPostFix:t.sInfo.replace("_START_",i).replace("_END_",a).replace("_MAX_",n).replace("_TOTAL_",h)+" "+t.sInfoFiltered.replace("_MAX_",s.fnFormatNumber(s.fnRecordsTotal()))+t.sInfoPostFix,i=t.fnInfoCallback,d=(i&&(c=i.call(s.oInstance,s,e,o,l,r,c)),s.aanFeatures.i);if(void 0!==d)for(var p=0,u=d.length;p<u;p++)f(d[p]).html(c);f(s.nTable).triggerHandler("info.dt")}},_parseHeight:function(s){var t,o,s=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(s);return null!==s&&(o=parseFloat(s[1]),"px"===(s=s[2])?t=o:"vh"===s?t=o/100*f(i).height():"rem"===s?t=o*parseFloat(f(":root").css("font-size")):"em"===s&&(t=o*parseFloat(f("body").css("font-size"))),t)||0},_scroll:function(){var s,t=this,o=this.s.heights,e=this.dom.scroller.scrollTop;this.s.skip||this.s.ingnoreScroll||e!==this.s.lastScrollTop&&(this.s.dt.bFiltered||this.s.dt.bSorted?this.s.lastScrollTop=0:(this._info(),clearTimeout(this.s.stateTO),this.s.stateTO=setTimeout(function(){t.s.dtApi.state.save()},250),this.s.scrollType=Math.abs(e-this.s.lastScrollTop)>o.viewport?"jump":"cont",this.s.topRowFloat="cont"===this.s.scrollType?this.pixelsToRow(e,!1,!1):this._domain("physicalToVirtual",e)/o.row,this.s.topRowFloat<0&&(this.s.topRowFloat=0),this.s.forceReposition||e<this.s.redrawTop||e>this.s.redrawBottom?(s=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows),s=parseInt(this.s.topRowFloat,10)-s,this.s.forceReposition=!1,s<=0?s=0:s+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(s=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength)<0&&(s=0):s%2!=0&&s++,(this.s.targetTop=s)!=this.s.dt._iDisplayStart&&(this.s.tableTop=f(this.s.dt.nTable).offset().top,this.s.tableBottom=f(this.s.dt.nTable).height()+this.s.tableTop,s=function(){t.s.dt._iDisplayStart=t.s.targetTop,t.s.dt.oApi._fnDraw(t.s.dt)},this.s.dt.oFeatures.bServerSide?(this.s.forceReposition=!0,clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(s,this.s.serverWait)):s(),this.dom.loader&&!this.s.loaderVisible&&(this.dom.loader.css("display","block"),this.s.loaderVisible=!0))):this.s.topRowFloat=this.pixelsToRow(e,!1,!0),this.s.lastScrollTop=e,this.s.stateSaveThrottle(),"jump"===this.s.scrollType&&this.s.mousedown&&(this.s.labelVisible=!0),this.s.labelVisible&&(s=(o.viewport-o.labelHeight-o.xbar)/o.scroll,this.dom.label.html(this.s.dt.fnFormatNumber(parseInt(this.s.topRowFloat,10)+1)).css("top",e+e*s).css("right",10-this.dom.scroller.scrollLeft).css("display","block"))))},_scrollForce:function(){var s=this.s.heights;s.virtual=s.row*this.s.dt.fnRecordsDisplay(),s.scroll=s.virtual,1e6<s.scroll&&(s.scroll=1e6),this.dom.force.style.height=s.scroll>this.s.heights.row?s.scroll+"px":this.s.heights.row+"px"}}),e.oDefaults=e.defaults={boundaryScale:.5,displayBuffer:9,loadingIndicator:!1,rowHeight:"auto",serverWait:200},e.version="2.1.0",f(o).on("preInit.dt.dtscroller",function(s,t){var o;"dt"===s.namespace&&(s=t.oInit.scroller,o=l.defaults.scroller,(s||o)&&(o=f.extend({},s,o),!1!==s&&new e(t,o)))}),f.fn.dataTable.Scroller=e,f.fn.DataTable.Scroller=e,f.fn.dataTable.Api);return s.register("scroller()",function(){return this}),s.register("scroller().rowToPixels()",function(s,t,o){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.rowToPixels(s,t,o)}),s.register("scroller().pixelsToRow()",function(s,t,o){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.pixelsToRow(s,t,o)}),s.register(["scroller().scrollToRow()","scroller.toPosition()"],function(t,o){return this.iterator("table",function(s){s.oScroller&&s.oScroller.scrollToRow(t,o)}),this}),s.register("row().scrollTo()",function(o){var e=this;return this.iterator("row",function(s,t){s.oScroller&&(t=e.rows({order:"applied",search:"applied"}).indexes().indexOf(t),s.oScroller.scrollToRow(t,o))}),this}),s.register("scroller.measure()",function(t){return this.iterator("table",function(s){s.oScroller&&s.oScroller.measure(t)}),this}),s.register("scroller.page()",function(){var s=this.context;if(s.length&&s[0].oScroller)return s[0].oScroller.pageInfo()}),l});

@@ -5,6 +5,8 @@ {

"main": "js/dataTables.scroller.js",
"module": "js/dataTables.scroller.mjs",
"types": "./types/types.d.ts",
"version": "2.0.7",
"version": "2.1.0",
"files": [
"js/**/*.js",
"js/**/*.mjs",
"types/**/*.d.ts"

@@ -22,3 +24,3 @@ ],

"dependencies": {
"datatables.net": ">=1.11.3",
"datatables.net": ">=1.12.1",
"jquery": ">=1.7"

@@ -25,0 +27,0 @@ },

@@ -1,121 +0,143 @@

// Type definitions for datatables.net-scroller 1.4
// Project: https://datatables.net
// Definitions by: Konstantin Rohde <https://github.com/RohdeK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
// Type definitions for DataTables Scroller
//
// Project: https://datatables.net/extensions/scroller/, https://datatables.net
// Definitions by:
// SpryMedia
// Konstantin Rohde <https://github.com/RohdeK>
/// <reference types="jquery" />
/// <reference types="datatables.net"/>
import DataTables, {Api} from 'datatables.net';
declare namespace DataTables {
interface Settings {
/*
* Select extension options
*/
scroller?: boolean | ScrollerSettings;
}
export default DataTables;
interface ScrollerSettings {
/*
* Indicate if Scroller show show trace information on the console or not.
*/
trace?: boolean;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DataTables' types integration
*/
declare module 'datatables.net' {
interface Config {
/**
* Scroller extension options
*/
scroller?: boolean | ConfigScroller;
}
/*
* 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.
*/
rowHeight?: number | string;
interface Api<T> {
/**
* Scroller methods container
*
* @returns Api for chaining with the additional Scroller methods
*/
scroller: ApiScrollerMethods<T>;
}
/*
* 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.
*/
serverWait?: number;
interface ApiRowMethods<T> {
/**
* Scroll to a row
*/
scrollTo(animate?: boolean): Api<T>;
}
/*
* The display buffer is what Scroller uses to calculate how many rows it should pre-fetch
* for scrolling.
*/
displayBuffer?: number;
interface ApiStatic {
/**
* Scroller class
*/
Scroller: {
/**
* Create a new Scroller instance for the target DataTable
*/
new (dt: Api<any>, settings: boolean | ConfigScroller);
/*
* 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).
*/
boundaryScale?: number;
/**
* Scroller version
*/
version: string;
/*
* Show (or not) the loading element in the background of the table. Note that you should
* include the dataTables.scroller.css file for this to be displayed correctly.
*/
loadingIndicator?: boolean;
}
/**
* Default configuration values
*/
defaults: ConfigScroller;
}
}
}
interface Api {
scroller: ScrollerMethodsModel;
}
interface ScrollerMethodsModel {
/**
* 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.
*
* @param redraw Flag to indicate if the table should immediately redraw or not. true will redraw the table, false will not.
* @returns DataTables Api instance for chaining
*/
measure(redraw?: boolean): Api;
/**
* Get information about current displayed record range.
*
* @returnsAn object with the parameters start and end, defining the start and end, 0 based, display indexes of the rows that are visible in the table's scrolling viewport.
*/
page(): PageInfo;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Options
*/
/**
* Move the display to show the row at the index given.
*
* @param index Display index to jump to.
* @param animate Animate the scroll (true) or not (false).
*/
toPosition(index: number, animate?: boolean): Api;
/**
* Get Scroller Api
*/
scroller(): ScrollerMethods;
}
interface ConfigScroller {
/**
* 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).
*/
boundaryScale?: number;
interface ScrollerMethods extends Api {
/*
* Calculate the pixel position from the top of the scrolling container for
* a given row
*/
rowToPixels(rowIdx: number, intParse?: boolean, virtual?: boolean): number;
/*
* Calculate the row number that will be found at the given pixel position
* (y-scroll).
*/
pixelsToRow(pixels: number, intParse?: boolean, virtual?: boolean): number;
scrollToRow(rowIdx: number, animate?: boolean): Api;
}
/**
* The display buffer is what Scroller uses to calculate how many rows it should pre-fetch
* for scrolling.
*/
displayBuffer?: number;
/*
* start: {int}, // the 0-indexed record at the top of the viewport
* end: {int}, // the 0-indexed record at the bottom of the viewport
*/
interface PageInfo {
start: number;
end: number;
}
/**
* Show (or not) the loading element in the background of the table. Note that you should
* include the dataTables.scroller.css file for this to be displayed correctly.
*/
loadingIndicator?: boolean;
interface RowMethods {
/**
* Scroll to a row
*/
scrollTo(animate?: boolean): Api;
}
/**
* 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.
*/
rowHeight?: number | string;
/**
* 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.
*/
serverWait?: number;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* API
*/
interface ApiScrollerMethods<T> {
/**
* 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.
*
* @param redraw Flag to indicate if the table should immediately redraw or not. true will redraw the table, false will not.
* @returns DataTables Api instance for chaining
*/
measure(redraw?: boolean): Api<T>;
/**
* Get information about current displayed record range.
*
* @returnsAn object with the parameters start and end, defining the start and end, 0 based, display indexes of the rows that are visible in the table's scrolling viewport.
*/
page(): PageInfo;
/**
* Move the display to show the row at the index given.
*
* @param index Display index to jump to.
* @param animate Animate the scroll (true) or not (false).
*/
toPosition(index: number, animate?: boolean): Api<T>;
}
interface PageInfo {
/**
* The 0-indexed record at the top of the viewport
*/
start: number;
/**
* The 0-indexed record at the bottom of the viewport
*/
end: number;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc