1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-27 10:32:24 +01:00
LocalCDN-Firefox-Chrome-Brave/resources/datatables/1.11.0/dataTables.fixedColumns.min.jsm
2021-08-29 08:19:58 +02:00

47 lines
18 KiB
JavaScript

/*!
Copyright 2010-2021 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
FixedColumns 3.3.3
©2010-2021 SpryMedia Ltd - datatables.net/license
*/
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(v){return d(v,window,document)}):"object"===typeof exports?module.exports=function(v,w){v||(v=window);w&&w.fn.dataTable||(w=require("datatables.net")(v,w).$);return d(w,v,v.document)}:d(jQuery,window,document)})(function(d,v,w,z){var y=d.fn.dataTable,B,q=function(a,b){var c=this;if(this instanceof q){if(b===z||!0===b)b={};var f=d.fn.dataTable.camelToHungarian;f&&(f(q.defaults,q.defaults,!0),f(q.defaults,
b));a=(new d.fn.dataTable.Api(a)).settings()[0];this.s={dt:a,iTableColumns:a.aoColumns.length,aiOuterWidths:[],aiInnerWidths:[],rtl:"rtl"===d(a.nTable).css("direction")};this.dom={scroller:null,header:null,body:null,footer:null,grid:{wrapper:null,dt:null,left:{wrapper:null,head:null,body:null,foot:null},right:{wrapper:null,head:null,body:null,foot:null}},clone:{left:{header:null,body:null,footer:null},right:{header:null,body:null,footer:null}}};if(a._oFixedColumns)throw"FixedColumns already initialised on this table";
a._oFixedColumns=this;a._bInitComplete?this._fnConstruct(b):a.oApi._fnCallbackReg(a,"aoInitComplete",function(){c._fnConstruct(b)},"FixedColumns")}else alert("FixedColumns warning: FixedColumns must be initialised with the 'new' keyword.")};d.extend(q.prototype,{fnUpdate:function(){this._fnDraw(!0)},fnRedrawLayout:function(){this._fnColCalc();this._fnGridLayout();this.fnUpdate()},fnRecalculateHeight:function(a){delete a._DTTC_iHeight;a.style.height="auto"},fnSetRowHeight:function(a,b){a.style.height=
b+"px"},fnGetPosition:function(a){var b=this.s.dt.oInstance;if(d(a).parents(".DTFC_Cloned").length){if("tr"===a.nodeName.toLowerCase())return a=d(a).index(),b.fnGetPosition(d("tr",this.s.dt.nTBody)[a]);var c=d(a).index();a=d(a.parentNode).index();return[b.fnGetPosition(d("tr",this.s.dt.nTBody)[a]),c,b.oApi._fnVisibleToColumnIndex(this.s.dt,c)]}return b.fnGetPosition(a)},fnToFixedNode:function(a,b){var c;b<this.s.iLeftColumns?c=d(this.dom.clone.left.body).find("[data-dt-row="+a+"][data-dt-column="+
b+"]"):b>=this.s.iRightColumns&&(c=d(this.dom.clone.right.body).find("[data-dt-row="+a+"][data-dt-column="+b+"]"));return c&&c.length?c[0]:(new d.fn.dataTable.Api(this.s.dt)).cell(a,b).node()},_fnConstruct:function(a){var b=this;if("function"!=typeof this.s.dt.oInstance.fnVersionCheck||!0!==this.s.dt.oInstance.fnVersionCheck("1.8.0"))alert("FixedColumns "+q.VERSION+" required DataTables 1.8.0 or later. Please upgrade your DataTables installation");else if(""===this.s.dt.oScroll.sX)this.s.dt.oInstance.oApi._fnLog(this.s.dt,
1,"FixedColumns is not needed (no x-scrolling in DataTables enabled), so no action will be taken. Use 'FixedHeader' for column fixing when scrolling is not enabled");else{this.s=d.extend(!0,this.s,q.defaults,a);a=this.s.dt.oClasses;this.dom.grid.dt=d(this.s.dt.nTable).parents("div."+a.sScrollWrapper)[0];this.dom.scroller=d("div."+a.sScrollBody,this.dom.grid.dt)[0];this._fnColCalc();this._fnGridSetup();var c,f=!1;d(this.s.dt.nTableWrapper).on("mousedown.DTFC",function(g){0===g.button&&(f=!0,d(w).one("mouseup",
function(){f=!1}))});d(this.dom.scroller).on("mouseover.DTFC touchstart.DTFC",function(){f||(c="main")}).on("scroll.DTFC",function(g){!c&&g.originalEvent&&(c="main");if("main"===c||"key"===c)0<b.s.iLeftColumns&&(b.dom.grid.left.liner.scrollTop=b.dom.scroller.scrollTop),0<b.s.iRightColumns&&(b.dom.grid.right.liner.scrollTop=b.dom.scroller.scrollTop)});var e="onwheel"in w.createElement("div")?"wheel.DTFC":"mousewheel.DTFC";0<b.s.iLeftColumns&&(d(b.dom.grid.left.liner).on("mouseover.DTFC touchstart.DTFC",
function(){f||"key"===c||(c="left")}).on("scroll.DTFC",function(g){!c&&g.originalEvent&&(c="left");"left"===c&&(b.dom.scroller.scrollTop=b.dom.grid.left.liner.scrollTop,0<b.s.iRightColumns&&(b.dom.grid.right.liner.scrollTop=b.dom.grid.left.liner.scrollTop))}).on(e,function(g){c="left";b.dom.scroller.scrollLeft-="wheel"===g.type?-g.originalEvent.deltaX:g.originalEvent.wheelDeltaX}),d(b.dom.grid.left.head).on("mouseover.DTFC touchstart.DTFC",function(){c="main"}));0<b.s.iRightColumns&&(d(b.dom.grid.right.liner).on("mouseover.DTFC touchstart.DTFC",
function(){f||"key"===c||(c="right")}).on("scroll.DTFC",function(g){!c&&g.originalEvent&&(c="right");"right"===c&&(b.dom.scroller.scrollTop=b.dom.grid.right.liner.scrollTop,0<b.s.iLeftColumns&&(b.dom.grid.left.liner.scrollTop=b.dom.grid.right.liner.scrollTop))}).on(e,function(g){c="right";b.dom.scroller.scrollLeft-="wheel"===g.type?-g.originalEvent.deltaX:g.originalEvent.wheelDeltaX}),d(b.dom.grid.right.head).on("mouseover.DTFC touchstart.DTFC",function(){c="main"}));d(v).on("resize.DTFC",function(){b._fnGridLayout.call(b)});
var h=!0,k=d(this.s.dt.nTable);k.on("draw.dt.DTFC",function(){b._fnColCalc();b._fnDraw.call(b,h);h=!1}).on("key-focus.dt.DTFC",function(){c="key"}).on("column-sizing.dt.DTFC",function(){b._fnColCalc();b._fnGridLayout(b)}).on("column-visibility.dt.DTFC",function(g,m,l,n,r){if(r===z||r)b._fnColCalc(),b._fnGridLayout(b),b._fnDraw(!0)}).on("select.dt.DTFC deselect.dt.DTFC",function(g,m,l,n){"dt"===g.namespace&&b._fnDraw(!1)}).on("position.dts.dt.DTFC",function(g,m){b.dom.grid.left.body&&d(b.dom.grid.left.body).find("table").eq(0).css("top",
m);b.dom.grid.right.body&&d(b.dom.grid.right.body).find("table").eq(0).css("top",m)}).on("destroy.dt.DTFC",function(){k.off(".DTFC");d(b.dom.scroller).off(".DTFC");d(v).off(".DTFC");d(b.s.dt.nTableWrapper).off(".DTFC");d(b.dom.grid.left.liner).off(".DTFC "+e);d(b.dom.grid.left.wrapper).remove();d(b.dom.grid.right.liner).off(".DTFC "+e);d(b.dom.grid.right.wrapper).remove()});this._fnGridLayout();this.s.dt.oInstance.fnDraw(!1)}},_fnColCalc:function(){var a=this,b=0,c=0;this.s.aiInnerWidths=[];this.s.aiOuterWidths=
[];d.each(this.s.dt.aoColumns,function(f,e){e=d(e.nTh);if(e.filter(":visible").length){var h=e.outerWidth();if(0===a.s.aiOuterWidths.length){var k=d(a.s.dt.nTable).css("border-left-width");h+="string"===typeof k&&-1===k.indexOf("px")?1:parseInt(k,10)}a.s.aiOuterWidths.length===a.s.dt.aoColumns.length-1&&(k=d(a.s.dt.nTable).css("border-right-width"),h+="string"===typeof k&&-1===k.indexOf("px")?1:parseInt(k,10));a.s.aiOuterWidths.push(h);a.s.aiInnerWidths.push(e.width());f<a.s.iLeftColumns&&(b+=h);
a.s.iTableColumns-a.s.iRightColumns<=f&&(c+=h)}else a.s.aiInnerWidths.push(0),a.s.aiOuterWidths.push(0)});this.s.iLeftWidth=b;this.s.iRightWidth=c},_fnGridSetup:function(){var a=this._fnDTOverflow();this.dom.body=this.s.dt.nTable;this.dom.header=this.s.dt.nTHead.parentNode;this.dom.header.parentNode.parentNode.style.position="relative";var b=d('<div class="DTFC_ScrollWrapper" style="position:relative; clear:both;"><div class="DTFC_LeftWrapper" style="position:absolute; top:0; left:0;" aria-hidden="true"><div class="DTFC_LeftHeadWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div><div class="DTFC_LeftBodyWrapper" style="position:relative; top:0; left:0; height:0; overflow:hidden;"><div class="DTFC_LeftBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div></div><div class="DTFC_LeftFootWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div></div><div class="DTFC_RightWrapper" style="position:absolute; top:0; right:0;" aria-hidden="true"><div class="DTFC_RightHeadWrapper" style="position:relative; top:0; left:0;"><div class="DTFC_RightHeadBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div></div><div class="DTFC_RightBodyWrapper" style="position:relative; top:0; left:0; height:0; overflow:hidden;"><div class="DTFC_RightBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div></div><div class="DTFC_RightFootWrapper" style="position:relative; top:0; left:0;"><div class="DTFC_RightFootBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div></div></div></div>')[0],
c=b.childNodes[0],f=b.childNodes[1];this.dom.grid.dt.parentNode.insertBefore(b,this.dom.grid.dt);b.appendChild(this.dom.grid.dt);this.dom.grid.wrapper=b;0<this.s.iLeftColumns&&(this.dom.grid.left.wrapper=c,this.dom.grid.left.head=c.childNodes[0],this.dom.grid.left.body=c.childNodes[1],this.dom.grid.left.liner=d("div.DTFC_LeftBodyLiner",b)[0],b.appendChild(c));if(0<this.s.iRightColumns){this.dom.grid.right.wrapper=f;this.dom.grid.right.head=f.childNodes[0];this.dom.grid.right.body=f.childNodes[1];
this.dom.grid.right.liner=d("div.DTFC_RightBodyLiner",b)[0];f.style.right=a.bar+"px";var e=d("div.DTFC_RightHeadBlocker",b)[0];e.style.width=a.bar+"px";e.style.right=-a.bar+"px";this.dom.grid.right.headBlock=e;e=d("div.DTFC_RightFootBlocker",b)[0];e.style.width=a.bar+"px";e.style.right=-a.bar+"px";this.dom.grid.right.footBlock=e;b.appendChild(f)}this.s.dt.nTFoot&&(this.dom.footer=this.s.dt.nTFoot.parentNode,0<this.s.iLeftColumns&&(this.dom.grid.left.foot=c.childNodes[2]),0<this.s.iRightColumns&&(this.dom.grid.right.foot=
f.childNodes[2]));this.s.rtl&&d("div.DTFC_RightHeadBlocker",b).css({left:-a.bar+"px",right:""})},_fnGridLayout:function(){var a=this,b=this.dom.grid;d(b.wrapper).width();var c=this.s.dt.nTable.parentNode.offsetHeight,f=this.s.dt.nTable.parentNode.parentNode.offsetHeight,e=this._fnDTOverflow(),h=this.s.iLeftWidth,k=this.s.iRightWidth,g="rtl"===d(this.dom.body).css("direction"),m=function(l,n){e.bar?a._firefoxScrollError()?34<d(l).height()&&(l.style.width=n+e.bar+"px"):l.style.width=n+e.bar+"px":(l.style.width=
n+20+"px",l.style.paddingRight="20px",l.style.boxSizing="border-box")};e.x&&(c-=e.bar);b.wrapper.style.height=f+"px";0<this.s.iLeftColumns&&(f=b.left.wrapper,f.style.width=h+"px",f.style.height="1px",g?(f.style.left="",f.style.right=0):(f.style.left=0,f.style.right=""),b.left.body.style.height=c+"px",b.left.foot&&(b.left.foot.style.top=(e.x?e.bar:0)+"px"),m(b.left.liner,h),b.left.liner.style.height=c+"px",b.left.liner.style.maxHeight=c+"px");0<this.s.iRightColumns&&(f=b.right.wrapper,f.style.width=
k+"px",f.style.height="1px",this.s.rtl?(f.style.left=e.y?e.bar+"px":0,f.style.right=""):(f.style.left="",f.style.right=e.y?e.bar+"px":0),b.right.body.style.height=c+"px",b.right.foot&&(b.right.foot.style.top=(e.x?e.bar:0)+"px"),m(b.right.liner,k),b.right.liner.style.height=c+"px",b.right.liner.style.maxHeight=c+"px",b.right.headBlock.style.display=e.y?"block":"none",b.right.footBlock.style.display=e.y?"block":"none")},_fnDTOverflow:function(){var a=this.s.dt.nTable,b=a.parentNode,c={x:!1,y:!1,bar:this.s.dt.oScroll.iBarWidth};
a.offsetWidth>b.clientWidth&&(c.x=!0);a.offsetHeight>b.clientHeight&&(c.y=!0);return c},_fnDraw:function(a){this._fnGridLayout();this._fnCloneLeft(a);this._fnCloneRight(a);d(this.dom.scroller).trigger("scroll");null!==this.s.fnDrawCallback&&this.s.fnDrawCallback.call(this,this.dom.clone.left,this.dom.clone.right);d(this).trigger("draw.dtfc",{leftClone:this.dom.clone.left,rightClone:this.dom.clone.right})},_fnCloneRight:function(a){if(!(0>=this.s.iRightColumns)){var b,c=[];for(b=this.s.iTableColumns-
this.s.iRightColumns;b<this.s.iTableColumns;b++)this.s.dt.aoColumns[b].bVisible&&c.push(b);this._fnClone(this.dom.clone.right,this.dom.grid.right,c,a)}},_fnCloneLeft:function(a){if(!(0>=this.s.iLeftColumns)){var b,c=[];for(b=0;b<this.s.iLeftColumns;b++)this.s.dt.aoColumns[b].bVisible&&c.push(b);this._fnClone(this.dom.clone.left,this.dom.grid.left,c,a)}},_fnCopyLayout:function(a,b,c){for(var f=[],e=[],h=[],k=0,g=a.length;k<g;k++){var m=[];m.nTr=d(a[k].nTr).clone(c,!1)[0];for(var l=0,n=this.s.iTableColumns;l<
n;l++)if(-1!==d.inArray(l,b)){var r=d.inArray(a[k][l].cell,h);-1===r?(r=d(a[k][l].cell).clone(c,!1)[0],e.push(r),h.push(a[k][l].cell),m.push({cell:r,unique:a[k][l].unique})):m.push({cell:e[r],unique:a[k][l].unique})}f.push(m)}return f},_fnClone:function(a,b,c,f){var e=this,h,k,g=this.s.dt;if(f){d(a.header).remove();a.header=d(this.dom.header).clone(!0,!1)[0];a.header.className+=" DTFC_Cloned";a.header.style.width="100%";b.head.appendChild(a.header);var m=this._fnCopyLayout(g.aoHeader,c,!0);var l=
d(">thead",a.header);l.empty();var n=0;for(h=m.length;n<h;n++)l[0].appendChild(m[n].nTr);g.oApi._fnDrawHead(g,m,!0)}else{m=this._fnCopyLayout(g.aoHeader,c,!1);var r=[];g.oApi._fnDetectHeader(r,d(">thead",a.header)[0]);n=0;for(h=m.length;n<h;n++){var t=0;for(l=m[n].length;t<l;t++)r[n][t].cell.className=m[n][t].cell.className,d("span.DataTables_sort_icon",r[n][t].cell).each(function(){this.className=d("span.DataTables_sort_icon",m[n][t].cell)[0].className})}}this._fnEqualiseHeights("thead",this.dom.header,
a.header);"auto"==this.s.sHeightMatch&&d(">tbody>tr",e.dom.body).css("height","auto");null!==a.body&&(d(a.body).remove(),a.body=null);a.body=d(this.dom.body).clone(!0)[0];a.body.className+=" DTFC_Cloned";a.body.style.paddingBottom=g.oScroll.iBarWidth+"px";a.body.style.marginBottom=2*g.oScroll.iBarWidth+"px";null!==a.body.getAttribute("id")&&a.body.removeAttribute("id");d(">thead>tr",a.body).empty();d(">tfoot",a.body).remove();var C=d("tbody",a.body)[0];d(C).empty();if(0<g.aiDisplay.length){h=d(">thead>tr",
a.body)[0];for(k=0;k<c.length;k++){var x=c[k];var p=d(g.aoColumns[x].nTh).clone(!0)[0];p.innerHTML="";l=p.style;l.paddingTop="0";l.paddingBottom="0";l.borderTopWidth="0";l.borderBottomWidth="0";l.height=0;l.width=e.s.aiInnerWidths[x]+"px";h.appendChild(p)}d(">tbody>tr",e.dom.body).each(function(u){u=!1===e.s.dt.oFeatures.bServerSide?e.s.dt.aiDisplay[e.s.dt._iDisplayStart+u]:u;var D=e.s.dt.aoData[u].anCells||d(this).children("td, th"),A=this.cloneNode(!1);A.removeAttribute("id");A.setAttribute("data-dt-row",
u);for(k=0;k<c.length;k++)x=c[k],0<D.length&&(p=d(D[x]).clone(!0,!0)[0],p.removeAttribute("id"),p.setAttribute("data-dt-row",u),p.setAttribute("data-dt-column",x),A.appendChild(p));C.appendChild(A)})}else d(">tbody>tr",e.dom.body).each(function(u){p=this.cloneNode(!0);p.className+=" DTFC_NoData";d("td",p).html("");C.appendChild(p)});a.body.style.width="100%";a.body.style.margin="0";a.body.style.padding="0";g.oScroller!==z&&(h=g.oScroller.dom.force,b.forcer?b.forcer.style.height=h.style.height:(b.forcer=
h.cloneNode(!0),b.liner.appendChild(b.forcer)));b.liner.appendChild(a.body);this._fnEqualiseHeights("tbody",e.dom.body,a.body);if(null!==g.nTFoot){if(f){null!==a.footer&&a.footer.parentNode.removeChild(a.footer);a.footer=d(this.dom.footer).clone(!0,!0)[0];a.footer.className+=" DTFC_Cloned";a.footer.style.width="100%";b.foot.appendChild(a.footer);m=this._fnCopyLayout(g.aoFooter,c,!0);b=d(">tfoot",a.footer);b.empty();n=0;for(h=m.length;n<h;n++)b[0].appendChild(m[n].nTr);g.oApi._fnDrawHead(g,m,!0)}else for(m=
this._fnCopyLayout(g.aoFooter,c,!1),b=[],g.oApi._fnDetectHeader(b,d(">tfoot",a.footer)[0]),n=0,h=m.length;n<h;n++)for(t=0,l=m[n].length;t<l;t++)b[n][t].cell.className=m[n][t].cell.className;this._fnEqualiseHeights("tfoot",this.dom.footer,a.footer)}b=g.oApi._fnGetUniqueThs(g,d(">thead",a.header)[0]);d(b).each(function(u){x=c[u];this.style.width=e.s.aiInnerWidths[x]+"px"});null!==e.s.dt.nTFoot&&(b=g.oApi._fnGetUniqueThs(g,d(">tfoot",a.footer)[0]),d(b).each(function(u){x=c[u];this.style.width=e.s.aiInnerWidths[x]+
"px"}))},_fnGetTrNodes:function(a){for(var b=[],c=0,f=a.childNodes.length;c<f;c++)"TR"==a.childNodes[c].nodeName.toUpperCase()&&b.push(a.childNodes[c]);return b},_fnEqualiseHeights:function(a,b,c){if("none"!=this.s.sHeightMatch||"thead"===a||"tfoot"===a){var f=b.getElementsByTagName(a)[0];c=c.getElementsByTagName(a)[0];a=d(">"+a+">tr:eq(0)",b).children(":first");a.outerHeight();a.height();f=this._fnGetTrNodes(f);b=this._fnGetTrNodes(c);var e=[];c=0;for(a=b.length;c<a;c++){var h=f[c].offsetHeight;
var k=b[c].offsetHeight;h=k>h?k:h;"semiauto"==this.s.sHeightMatch&&(f[c]._DTTC_iHeight=h);e.push(h)}c=0;for(a=b.length;c<a;c++)b[c].style.height=e[c]+"px",f[c].style.height=e[c]+"px"}},_firefoxScrollError:function(){if(B===z){var a=d("<div/>").css({position:"absolute",top:0,left:0,height:10,width:50,overflow:"scroll"}).appendTo("body");B=a[0].clientWidth===a[0].offsetWidth&&0!==this._fnDTOverflow().bar;a.remove()}return B}});q.defaults={iLeftColumns:1,iRightColumns:0,fnDrawCallback:null,sHeightMatch:"semiauto"};
q.version="3.3.3";y.Api.register("fixedColumns()",function(){return this});y.Api.register("fixedColumns().update()",function(){return this.iterator("table",function(a){a._oFixedColumns&&a._oFixedColumns.fnUpdate()})});y.Api.register("fixedColumns().relayout()",function(){return this.iterator("table",function(a){a._oFixedColumns&&a._oFixedColumns.fnRedrawLayout()})});y.Api.register("rows().recalcHeight()",function(){return this.iterator("row",function(a,b){a._oFixedColumns&&a._oFixedColumns.fnRecalculateHeight(this.row(b).node())})});
y.Api.register("fixedColumns().rowIndex()",function(a){a=d(a);return a.parents(".DTFC_Cloned").length?this.rows({page:"current"}).indexes()[a.index()]:this.row(a).index()});y.Api.register("fixedColumns().cellIndex()",function(a){a=d(a);if(a.parents(".DTFC_Cloned").length){var b=a.parent().index();b=this.rows({page:"current"}).indexes()[b];a=a.parents(".DTFC_LeftWrapper").length?a.index():this.columns().flatten().length-this.context[0]._oFixedColumns.s.iRightColumns+a.index();return{row:b,column:this.column.index("toData",
a),columnVisible:a}}return this.cell(a).index()});y.Api.registerPlural("cells().fixedNodes()","cell().fixedNode()",function(){return this.iterator("cell",function(a,b,c){return a._oFixedColumns?a._oFixedColumns.fnToFixedNode(b,c):this.cell(b,c).node()},1)});d(w).on("init.dt.fixedColumns",function(a,b){if("dt"===a.namespace){a=b.oInit.fixedColumns;var c=y.defaults.fixedColumns;if(a||c)c=d.extend({},a,c),!1!==a&&new q(b,c)}});d.fn.dataTable.FixedColumns=q;return d.fn.DataTable.FixedColumns=q});