1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
!function(t){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return t(e,window,document)}):"object"==typeof exports?module.exports=function(e,n){return e||(e=window),n&&n.fn.dataTable||(n=require("datatables.net")(e,n).$),t(n,e,e.document)}:t(jQuery,window,document)}(function(t,e,n,i){"use strict";var r=t.fn.dataTable,s=function(e,n){if(!r.versionCheck||!r.versionCheck("1.10.3"))throw"DataTables Responsive requires DataTables 1.10.3 or newer";this.s={dt:new r.Api(e),columns:[],current:[]},this.s.dt.settings()[0].responsive||(n&&"string"==typeof n.details?n.details={type:n.details}:n&&n.details===!1?n.details={type:!1}:n&&n.details===!0&&(n.details={type:"inline"}),this.c=t.extend(!0,{},s.defaults,r.defaults.responsive,n),e.responsive=this,this._constructor())};t.extend(s.prototype,{_constructor:function(){var n=this,i=this.s.dt,s=i.settings()[0],o=t(e).width();i.settings()[0]._responsive=this,t(e).on("resize.dtr orientationchange.dtr",r.util.throttle(function(){var i=t(e).width();i!==o&&(n._resize(),o=i)})),s.oApi._fnCallbackReg(s,"aoRowCreatedCallback",function(e,r,s){t.inArray(!1,n.s.current)!==-1&&t("td, th",e).each(function(e){var r=i.column.index("toData",e);n.s.current[r]===!1&&t(this).css("display","none")})}),i.on("destroy.dtr",function(){i.off(".dtr"),t(i.table().body()).off(".dtr"),t(e).off("resize.dtr orientationchange.dtr"),t.each(n.s.current,function(t,e){e===!1&&n._setColumnVis(t,!0)})}),this.c.breakpoints.sort(function(t,e){return t.width<e.width?1:t.width>e.width?-1:0}),this._classLogic(),this._resizeAuto();var a=this.c.details;a.type!==!1&&(n._detailsInit(),i.on("column-visibility.dtr",function(t,e,i,r){n._classLogic(),n._resizeAuto(),n._resize()}),i.on("draw.dtr",function(){n._redrawChildren()}),t(i.table().node()).addClass("dtr-"+a.type)),i.on("column-reorder.dtr",function(t,e,i){n._classLogic(),n._resizeAuto(),n._resize()}),i.on("column-sizing.dtr",function(){n._resizeAuto(),n._resize()}),i.on("init.dtr",function(e,r,s){n._resizeAuto(),n._resize(),t.inArray(!1,n.s.current)&&i.columns.adjust()}),this._resize()},_columnsVisiblity:function(e){var n,i,r=this.s.dt,s=this.s.columns,o=s.map(function(t,e){return{columnIdx:e,priority:t.priority}}).sort(function(t,e){return t.priority!==e.priority?t.priority-e.priority:t.columnIdx-e.columnIdx}),a=t.map(s,function(n){return(!n.auto||null!==n.minWidth)&&(n.auto===!0?"-":t.inArray(e,n.includeIn)!==-1)}),d=0;for(n=0,i=a.length;n<i;n++)a[n]===!0&&(d+=s[n].minWidth);var l=r.settings()[0].oScroll,c=l.sY||l.sX?l.iBarWidth:0,u=r.table().container().offsetWidth-c,h=u-d;for(n=0,i=a.length;n<i;n++)s[n].control&&(h-=s[n].minWidth);var p=!1;for(n=0,i=o.length;n<i;n++){var f=o[n].columnIdx;"-"===a[f]&&!s[f].control&&s[f].minWidth&&(p||h-s[f].minWidth<0?(p=!0,a[f]=!1):a[f]=!0,h-=s[f].minWidth)}var m=!1;for(n=0,i=s.length;n<i;n++)if(!s[n].control&&!s[n].never&&!a[n]){m=!0;break}for(n=0,i=s.length;n<i;n++)s[n].control&&(a[n]=m);return t.inArray(!0,a)===-1&&(a[0]=!0),a},_classLogic:function(){var e=this,n=this.c.breakpoints,r=this.s.dt,s=r.columns().eq(0).map(function(e){var n=this.column(e),s=n.header().className,o=r.settings()[0].aoColumns[e].responsivePriority;if(o===i){var a=t(n.header()).data("priority");o=a!==i?1*a:1e4}return{className:s,includeIn:[],auto:!1,control:!1,never:!!s.match(/\bnever\b/),priority:o}}),o=function(e,n){var i=s[e].includeIn;t.inArray(n,i)===-1&&i.push(n)},a=function(t,i,r,a){var d,l,c;if(r){if("max-"===r)for(d=e._find(i).width,l=0,c=n.length;l<c;l++)n[l].width<=d&&o(t,n[l].name);else if("min-"===r)for(d=e._find(i).width,l=0,c=n.length;l<c;l++)n[l].width>=d&&o(t,n[l].name);else if("not-"===r)for(l=0,c=n.length;l<c;l++)n[l].name.indexOf(a)===-1&&o(t,n[l].name)}else s[t].includeIn.push(i)};s.each(function(e,i){for(var r=e.className.split(" "),s=!1,o=0,d=r.length;o<d;o++){var l=t.trim(r[o]);if("all"===l)return s=!0,void(e.includeIn=t.map(n,function(t){return t.name}));if("none"===l||e.never)return void(s=!0);if("control"===l)return s=!0,void(e.control=!0);t.each(n,function(t,e){var n=e.name.split("-"),r=new RegExp("(
|