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.
Plugins/features/pageResize/dataTables.pageResize.min.js

4 lines
2.9 KiB
JavaScript

/*! PageResize for DataTables v1.0.0
* 2015 SpryMedia Ltd - datatables.net/license
*/
!function(i){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return i(e,window,document)}):"object"==typeof exports?module.exports=function(e,t){return e=e||window,t&&t.fn.dataTable||(t=require("datatables.net")(e,t).$),i(t,0,e.document)}:i(jQuery,window,document)}(function(d,e,t,i){"use strict";function s(e,t){var i=e.table();this.s={dt:e,host:d(i.container()).parent(),header:d(i.header()),footer:d(i.footer()),body:d(i.body()),container:d(i.container()),table:d(i.node()),delta:t},this.sizes={offsetTop:this._getOffsetTop(),tableHeight:this._getTableHeight(),containerHeight:this._getContainerHeight(),headerHeight:this._getHeaderHeight(),footerHeight:this._getFooterHeight()};"static"===(i=this.s.host).css("position")&&i.css("position","relative");var s=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))}s.prototype={_size:function(){var e=this.s,t=e.dt,i=t.table(),s=d("tr",e.body),s=s.eq(1<s.length?1:0).height(),o=e.host.height(),n=i.header().parentNode!==i.body().parentNode,e=e.delta,a=this.sizes.offsetTop=this._getOffsetTop(),h=this.sizes.tableHeight=this._getTableHeight(),r=this.sizes.containerHeight=this._getContainerHeight(),g=this.sizes.headerHeight=this._getHeaderHeight(),f=this.sizes.footerHeight=this._getFooterHeight(),n=(n||(i.header()&&(o-=g),i.footer()&&(o-=f)),o=o-a-(r-(a+h)),!isNaN(parseFloat(e))&&isFinite(e)&&(o-=e),Math.floor(o/s));n!==1/0&&n!==-1/0&&!isNaN(n)&&0<n&&n!==t.page.len()&&t.page.len(n).draw()},_attach:function(){var s=this,e=d("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");e[0].onload=function(){var t=this.contentDocument.body,i=t.offsetHeight;this.contentDocument.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 d(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}},d.fn.dataTable.PageResize=s,d.fn.DataTable.PageResize=s,d(t).on("preInit.dt",function(e,t){"dt"===e.namespace&&(e=new d.fn.dataTable.Api(t),d(e.table().node()).hasClass("pageResize")||t.oInit.pageResize||d.fn.dataTable.defaults.pageResize)&&new s(e,t.oInit.pageResizeManualDelta)})});