LocalCDN-Firefox-Chrome-Brave/resources/datatables/1.10.25/dataTables.responsive.min.jsm

43 lines
14 KiB
JavaScript

/*!
Copyright 2014-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
Responsive 2.2.8
2014-2021 SpryMedia Ltd - datatables.net/license
*/
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(q){return e(q,window,document)}):"object"===typeof exports?module.exports=function(q,v){q||(q=window);v&&v.fn.dataTable||(v=require("datatables.net")(q,v).$);return e(v,q,q.document)}:e(jQuery,window,document)})(function(e,q,v,A){function D(a,b,c){var f=b+"-"+c;if(w[f])return w[f];var g=[];a=a.cell(b,c).node().childNodes;b=0;for(c=a.length;b<c;b++)g.push(a[b]);return w[f]=g}function C(a,b,c){var f=b+"-"+
c;if(w[f]){a=a.cell(b,c).node();c=w[f][0].parentNode.childNodes;b=[];for(var g=0,k=c.length;g<k;g++)b.push(c[g]);c=0;for(g=b.length;c<g;c++)a.appendChild(b[c]);w[f]=A}}var y=e.fn.dataTable,p=function(a,b){if(!y.versionCheck||!y.versionCheck("1.10.10"))throw"DataTables Responsive requires DataTables 1.10.10 or newer";this.s={dt:new y.Api(a),columns:[],current:[]};this.s.dt.settings()[0].responsive||(b&&"string"===typeof b.details?b.details={type:b.details}:b&&!1===b.details?b.details={type:!1}:b&&
!0===b.details&&(b.details={type:"inline"}),this.c=e.extend(!0,{},p.defaults,y.defaults.responsive,b),a.responsive=this,this._constructor())};e.extend(p.prototype,{_constructor:function(){var a=this,b=this.s.dt,c=b.settings()[0],f=e(q).innerWidth();b.settings()[0]._responsive=this;e(q).on("resize.dtr orientationchange.dtr",y.util.throttle(function(){var g=e(q).innerWidth();g!==f&&(a._resize(),f=g)}));c.oApi._fnCallbackReg(c,"aoRowCreatedCallback",function(g,k,h){-1!==e.inArray(!1,a.s.current)&&e(">td, >th",
g).each(function(d){d=b.column.index("toData",d);!1===a.s.current[d]&&e(this).css("display","none")})});b.on("destroy.dtr",function(){b.off(".dtr");e(b.table().body()).off(".dtr");e(q).off("resize.dtr orientationchange.dtr");b.cells(".dtr-control").nodes().to$().removeClass("dtr-control");e.each(a.s.current,function(g,k){!1===k&&a._setColumnVis(g,!0)})});this.c.breakpoints.sort(function(g,k){return g.width<k.width?1:g.width>k.width?-1:0});this._classLogic();this._resizeAuto();c=this.c.details;!1!==
c.type&&(a._detailsInit(),b.on("column-visibility.dtr",function(){a._timer&&clearTimeout(a._timer);a._timer=setTimeout(function(){a._timer=null;a._classLogic();a._resizeAuto();a._resize(!0);a._redrawChildren()},100)}),b.on("draw.dtr",function(){a._redrawChildren()}),e(b.table().node()).addClass("dtr-"+c.type));b.on("column-reorder.dtr",function(g,k,h){a._classLogic();a._resizeAuto();a._resize(!0)});b.on("column-sizing.dtr",function(){a._resizeAuto();a._resize()});b.on("preXhr.dtr",function(){var g=
[];b.rows().every(function(){this.child.isShown()&&g.push(this.id(!0))});b.one("draw.dtr",function(){a._resizeAuto();a._resize();b.rows(g).every(function(){a._detailsDisplay(this,!1)})})});b.on("draw.dtr",function(){a._controlClass()}).on("init.dtr",function(g,k,h){"dt"===g.namespace&&(a._resizeAuto(),a._resize(),e.inArray(!1,a.s.current)&&b.columns.adjust())});this._resize()},_columnsVisiblity:function(a){var b=this.s.dt,c=this.s.columns,f,g=c.map(function(n,r){return{columnIdx:r,priority:n.priority}}).sort(function(n,
r){return n.priority!==r.priority?n.priority-r.priority:n.columnIdx-r.columnIdx}),k=e.map(c,function(n,r){return!1===b.column(r).visible()?"not-visible":n.auto&&null===n.minWidth?!1:!0===n.auto?"-":-1!==e.inArray(a,n.includeIn)}),h=0;var d=0;for(f=k.length;d<f;d++)!0===k[d]&&(h+=c[d].minWidth);d=b.settings()[0].oScroll;d=d.sY||d.sX?d.iBarWidth:0;h=b.table().container().offsetWidth-d-h;d=0;for(f=k.length;d<f;d++)c[d].control&&(h-=c[d].minWidth);var m=!1;d=0;for(f=g.length;d<f;d++){var l=g[d].columnIdx;
"-"===k[l]&&!c[l].control&&c[l].minWidth&&(m||0>h-c[l].minWidth?(m=!0,k[l]=!1):k[l]=!0,h-=c[l].minWidth)}g=!1;d=0;for(f=c.length;d<f;d++)if(!c[d].control&&!c[d].never&&!1===k[d]){g=!0;break}d=0;for(f=c.length;d<f;d++)c[d].control&&(k[d]=g),"not-visible"===k[d]&&(k[d]=!1);-1===e.inArray(!0,k)&&(k[0]=!0);return k},_classLogic:function(){var a=this,b=this.c.breakpoints,c=this.s.dt,f=c.columns().eq(0).map(function(h){var d=this.column(h),m=d.header().className;h=c.settings()[0].aoColumns[h].responsivePriority;
d=d.header().getAttribute("data-priority");h===A&&(h=d===A||null===d?1E4:1*d);return{className:m,includeIn:[],auto:!1,control:!1,never:m.match(/\bnever\b/)?!0:!1,priority:h}}),g=function(h,d){h=f[h].includeIn;-1===e.inArray(d,h)&&h.push(d)},k=function(h,d,m,l){if(!m)f[h].includeIn.push(d);else if("max-"===m)for(l=a._find(d).width,d=0,m=b.length;d<m;d++)b[d].width<=l&&g(h,b[d].name);else if("min-"===m)for(l=a._find(d).width,d=0,m=b.length;d<m;d++)b[d].width>=l&&g(h,b[d].name);else if("not-"===m)for(d=
0,m=b.length;d<m;d++)-1===b[d].name.indexOf(l)&&g(h,b[d].name)};f.each(function(h,d){for(var m=h.className.split(" "),l=!1,n=0,r=m.length;n<r;n++){var x=m[n].trim();if("all"===x){l=!0;h.includeIn=e.map(b,function(t){return t.name});return}if("none"===x||h.never){l=!0;return}if("control"===x||"dtr-control"===x){l=!0;h.control=!0;return}e.each(b,function(t,B){t=B.name.split("-");var u=x.match(new RegExp("(min\\-|max\\-|not\\-)?("+t[0]+")(\\-[_a-zA-Z0-9])?"));u&&(l=!0,u[2]===t[0]&&u[3]==="-"+t[1]?k(d,
B.name,u[1],u[2]+u[3]):u[2]!==t[0]||u[3]||k(d,B.name,u[1],u[2]))})}l||(h.auto=!0)});this.s.columns=f},_controlClass:function(){if("inline"===this.c.details.type){var a=this.s.dt,b=e.inArray(!0,this.s.current);a.cells(null,function(c){return c!==b},{page:"current"}).nodes().to$().filter(".dtr-control").removeClass("dtr-control");a.cells(null,b,{page:"current"}).nodes().to$().addClass("dtr-control")}},_detailsDisplay:function(a,b){var c=this,f=this.s.dt,g=this.c.details;if(g&&!1!==g.type){var k=g.display(a,
b,function(){return g.renderer(f,a[0],c._detailsObj(a[0]))});!0!==k&&!1!==k||e(f.table().node()).triggerHandler("responsive-display.dt",[f,a,k,b])}},_detailsInit:function(){var a=this,b=this.s.dt,c=this.c.details;"inline"===c.type&&(c.target="td.dtr-control, th.dtr-control");b.on("draw.dtr",function(){a._tabIndexes()});a._tabIndexes();e(b.table().body()).on("keyup.dtr","td, th",function(g){13===g.keyCode&&e(this).data("dtr-keyboard")&&e(this).click()});var f=c.target;c="string"===typeof f?f:"td, th";
if(f!==A||null!==f)e(b.table().body()).on("click.dtr mousedown.dtr mouseup.dtr",c,function(g){if(e(b.table().node()).hasClass("collapsed")&&-1!==e.inArray(e(this).closest("tr").get(0),b.rows().nodes().toArray())){if("number"===typeof f){var k=0>f?b.columns().eq(0).length+f:f;if(b.cell(this).index().column!==k)return}k=b.row(e(this).closest("tr"));"click"===g.type?a._detailsDisplay(k,!1):"mousedown"===g.type?e(this).css("outline","none"):"mouseup"===g.type&&e(this).trigger("blur").css("outline","")}})},
_detailsObj:function(a){var b=this,c=this.s.dt;return e.map(this.s.columns,function(f,g){if(!f.never&&!f.control)return f=c.settings()[0].aoColumns[g],{className:f.sClass,columnIndex:g,data:c.cell(a,g).render(b.c.orthogonal),hidden:c.column(g).visible()&&!b.s.current[g],rowIndex:a,title:null!==f.sTitle?f.sTitle:e(c.column(g).header()).text()}})},_find:function(a){for(var b=this.c.breakpoints,c=0,f=b.length;c<f;c++)if(b[c].name===a)return b[c]},_redrawChildren:function(){var a=this,b=this.s.dt;b.rows({page:"current"}).iterator("row",
function(c,f){b.row(f);a._detailsDisplay(b.row(f),!0)})},_resize:function(a){var b=this,c=this.s.dt,f=e(q).innerWidth(),g=this.c.breakpoints,k=g[0].name,h=this.s.columns,d,m=this.s.current.slice();for(d=g.length-1;0<=d;d--)if(f<=g[d].width){k=g[d].name;break}var l=this._columnsVisiblity(k);this.s.current=l;g=!1;d=0;for(f=h.length;d<f;d++)if(!1===l[d]&&!h[d].never&&!h[d].control&&!1===!c.column(d).visible()){g=!0;break}e(c.table().node()).toggleClass("collapsed",g);var n=!1,r=0;c.columns().eq(0).each(function(x,
t){!0===l[t]&&r++;if(a||l[t]!==m[t])n=!0,b._setColumnVis(x,l[t])});n&&(this._redrawChildren(),e(c.table().node()).trigger("responsive-resize.dt",[c,this.s.current]),0===c.page.info().recordsDisplay&&e("td",c.table().body()).eq(0).attr("colspan",r));b._controlClass()},_resizeAuto:function(){var a=this.s.dt,b=this.s.columns;if(this.c.auto&&-1!==e.inArray(!0,e.map(b,function(d){return d.auto}))){e.isEmptyObject(w)||e.each(w,function(d){d=d.split("-");C(a,1*d[0],1*d[1])});a.table().node();var c=a.table().node().cloneNode(!1),
f=e(a.table().header().cloneNode(!1)).appendTo(c),g=e(a.table().body()).clone(!1,!1).empty().appendTo(c);c.style.width="auto";var k=a.columns().header().filter(function(d){return a.column(d).visible()}).to$().clone(!1).css("display","table-cell").css("width","auto").css("min-width",0);e(g).append(e(a.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display","");if(g=a.table().footer()){g=e(g.cloneNode(!1)).appendTo(c);var h=a.columns().footer().filter(function(d){return a.column(d).visible()}).to$().clone(!1).css("display",
"table-cell");e("<tr/>").append(h).appendTo(g)}e("<tr/>").append(k).appendTo(f);"inline"===this.c.details.type&&e(c).addClass("dtr-inline collapsed");e(c).find("[name]").removeAttr("name");e(c).css("position","relative");c=e("<div/>").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(c);c.insertBefore(a.table().node());k.each(function(d){d=a.column.index("fromVisible",d);b[d].minWidth=this.offsetWidth||0});c.remove()}},_responsiveOnlyHidden:function(){var a=this.s.dt;return e.map(this.s.current,
function(b,c){return!1===a.column(c).visible()?!0:b})},_setColumnVis:function(a,b){var c=this.s.dt;b=b?"":"none";e(c.column(a).header()).css("display",b);e(c.column(a).footer()).css("display",b);c.column(a).nodes().to$().css("display",b);e.isEmptyObject(w)||c.cells(null,a).indexes().each(function(f){C(c,f.row,f.column)})},_tabIndexes:function(){var a=this.s.dt,b=a.cells({page:"current"}).nodes().to$(),c=a.settings()[0],f=this.c.details.target;b.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]");
"number"===typeof f?a.cells(null,f,{page:"current"}).nodes().to$().attr("tabIndex",c.iTabIndex).data("dtr-keyboard",1):("td:first-child, th:first-child"===f&&(f=">td:first-child, >th:first-child"),e(f,a.rows({page:"current"}).nodes()).attr("tabIndex",c.iTabIndex).data("dtr-keyboard",1))}});p.breakpoints=[{name:"desktop",width:Infinity},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}];p.display={childRow:function(a,b,c){if(b){if(e(a.node()).hasClass("parent"))return a.child(c(),
"child").show(),!0}else{if(a.child.isShown())return a.child(!1),e(a.node()).removeClass("parent"),!1;a.child(c(),"child").show();e(a.node()).addClass("parent");return!0}},childRowImmediate:function(a,b,c){if(!b&&a.child.isShown()||!a.responsive.hasHidden())return a.child(!1),e(a.node()).removeClass("parent"),!1;a.child(c(),"child").show();e(a.node()).addClass("parent");return!0},modal:function(a){return function(b,c,f){if(c)e("div.dtr-modal-content").empty().append(f());else{var g=function(){k.remove();
e(v).off("keypress.dtr")},k=e('<div class="dtr-modal"/>').append(e('<div class="dtr-modal-display"/>').append(e('<div class="dtr-modal-content"/>').append(f())).append(e('<div class="dtr-modal-close">&times;</div>').click(function(){g()}))).append(e('<div class="dtr-modal-background"/>').click(function(){g()})).appendTo("body");e(v).on("keyup.dtr",function(h){27===h.keyCode&&(h.stopPropagation(),g())})}a&&a.header&&e("div.dtr-modal-content").prepend("<h2>"+a.header(b)+"</h2>")}}};var w={};p.renderer=
{listHiddenNodes:function(){return function(a,b,c){var f=e('<ul data-dtr-index="'+b+'" class="dtr-details"/>'),g=!1;e.each(c,function(k,h){h.hidden&&(e("<li "+(h.className?'class="'+h.className+'"':"")+' data-dtr-index="'+h.columnIndex+'" data-dt-row="'+h.rowIndex+'" data-dt-column="'+h.columnIndex+'"><span class="dtr-title">'+h.title+"</span> </li>").append(e('<span class="dtr-data"/>').append(D(a,h.rowIndex,h.columnIndex))).appendTo(f),g=!0)});return g?f:!1}},listHidden:function(){return function(a,
b,c){return(a=e.map(c,function(f){var g=f.className?'class="'+f.className+'"':"";return f.hidden?"<li "+g+' data-dtr-index="'+f.columnIndex+'" data-dt-row="'+f.rowIndex+'" data-dt-column="'+f.columnIndex+'"><span class="dtr-title">'+f.title+'</span> <span class="dtr-data">'+f.data+"</span></li>":""}).join(""))?e('<ul data-dtr-index="'+b+'" class="dtr-details"/>').append(a):!1}},tableAll:function(a){a=e.extend({tableClass:""},a);return function(b,c,f){b=e.map(f,function(g){return"<tr "+(g.className?
'class="'+g.className+'"':"")+' data-dt-row="'+g.rowIndex+'" data-dt-column="'+g.columnIndex+'"><td>'+g.title+":</td> <td>"+g.data+"</td></tr>"}).join("");return e('<table class="'+a.tableClass+' dtr-details" width="100%"/>').append(b)}}};p.defaults={breakpoints:p.breakpoints,auto:!0,details:{display:p.display.childRow,renderer:p.renderer.listHidden(),target:0,type:"inline"},orthogonal:"display"};var z=e.fn.dataTable.Api;z.register("responsive()",function(){return this});z.register("responsive.index()",
function(a){a=e(a);return{column:a.data("dtr-index"),row:a.parent().data("dtr-index")}});z.register("responsive.rebuild()",function(){return this.iterator("table",function(a){a._responsive&&a._responsive._classLogic()})});z.register("responsive.recalc()",function(){return this.iterator("table",function(a){a._responsive&&(a._responsive._resizeAuto(),a._responsive._resize())})});z.register("responsive.hasHidden()",function(){var a=this.context[0];return a._responsive?-1!==e.inArray(!1,a._responsive._responsiveOnlyHidden()):
!1});z.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(a,b){return a._responsive?a._responsive._responsiveOnlyHidden()[b]:!1},1)});p.version="2.2.8";e.fn.dataTable.Responsive=p;e.fn.DataTable.Responsive=p;e(v).on("preInit.dt.dtr",function(a,b,c){"dt"===a.namespace&&(e(b.nTable).hasClass("responsive")||e(b.nTable).hasClass("dt-responsive")||b.oInit.responsive||y.defaults.responsive)&&(a=b.oInit.responsive,!1!==a&&new p(b,
e.isPlainObject(a)?a:{}))});return p});