You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
/*! © SpryMedia Ltd - datatables.net/license */
|
|
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;var PageResize=function(e,t){var i=e.table(),i=(this.s={dt:e,host:$(i.container()).parent(),header:$(i.header()),footer:$(i.footer()),body:$(i.body()),container:$(i.container()),table:$(i.node()),delta:t},this.sizes={offsetTop:this._getOffsetTop(),tableHeight:this._getTableHeight(),containerHeight:this._getContainerHeight(),headerHeight:this._getHeaderHeight(),footerHeight:this._getFooterHeight()},this.s.host),s=("static"===i.css("position")&&i.css("position","relative"),function(){e.off(".pageResize",s),this.s.obj&&this.s.obj.remove()}.bind(this)),o=(e.on("destroy.pageResize",s),this._attach(),"init.pageResize");e.on(o,function(){e.off(o),this._size()}.bind(this))};PageResize.prototype={_size:function(){var e=this.s,t=e.dt,i=t.table(),s=$("tr",e.body),s=s.eq(1<s.length?1:0).height(),o=e.host.height(),a=i.header().parentNode!==i.body().parentNode,e=e.delta,h=this.sizes.offsetTop=this._getOffsetTop(),n=this.sizes.tableHeight=this._getTableHeight(),r=this.sizes.containerHeight=this._getContainerHeight(),g=this.sizes.headerHeight=this._getHeaderHeight(),f=this.sizes.footerHeight=this._getFooterHeight(),a=(a||(i.header()&&(o-=g),i.footer()&&(o-=f)),o=o-h-(r-(h+n)),!isNaN(parseFloat(e))&&isFinite(e)&&(o-=e),Math.floor(o/s));a!==1/0&&a!==-1/0&&!isNaN(a)&&0<a&&a!==t.page.len()&&t.page.len(a).draw()},_attach:function(){var s=this,e=$("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");e[0].onload=function(){var e=this.contentDocument,t=e.body,i=t.offsetHeight;e.defaultView.onresize=function(){var e=t.clientHeight||t.offsetHeight;e!==i?(i=e,s._size()):s.sizes.offsetTop===s._getOffsetTop()&&s.sizes.containerHeight===s._getContainerHeight()&&s.sizes.tableHeight===s._getTableHeight()&&s.sizes.headerHeight===s._getHeaderHeight()&&s.sizes.footerHeight===s._getFooterHeight()||s._size()}},e.appendTo(this.s.host).attr("data","about:blank"),this.s.obj=e},_getOffsetTop:function(){return $(this.s.table).offset().top},_getTableHeight:function(){return this.s.table.height()},_getContainerHeight:function(){return this.s.container.height()},_getHeaderHeight:function(){return this.s.dt.table().header()?this.s.header.height():0},_getFooterHeight:function(){return this.s.dt.table().footer()?this.s.footer.height():0}},DataTable.PageResize=PageResize,$(document).on("preInit.dt",function(e,t){"dt"===e.namespace&&(e=new DataTable.Api(t),$(e.table().node()).hasClass("pageResize")||t.oInit.pageResize||DataTable.defaults.pageResize)&&new PageResize(e,t.oInit.pageResizeManualDelta)});export default DataTable; |