Socket
Socket
Sign inDemoInstall

datatables.net-responsive

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatables.net-responsive - npm Package Compare versions

Comparing version 2.2.3 to 2.2.4

194

js/dataTables.responsive.js

@@ -1,3 +0,3 @@

/*! Responsive 2.2.3
* 2014-2018 SpryMedia Ltd - datatables.net/license
/*! Responsive 2.2.4
* 2014-2020 SpryMedia Ltd - datatables.net/license
*/

@@ -8,7 +8,7 @@

* @description Responsive tables plug-in for DataTables
* @version 2.2.3
* @version 2.2.4
* @file dataTables.responsive.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
* @copyright Copyright 2014-2018 SpryMedia Ltd.
* @copyright Copyright 2014-2020 SpryMedia Ltd.
*

@@ -148,3 +148,3 @@ * This source file is free software, available under the following license:

var dtPrivateSettings = dt.settings()[0];
var oldWindowWidth = $(window).width();
var oldWindowWidth = $(window).innerWidth();

@@ -158,3 +158,3 @@ dt.settings()[0]._responsive = this;

// See: http://stackoverflow.com/questions/8898412
var width = $(window).width();
var width = $(window).innerWidth();

@@ -187,2 +187,3 @@ if ( width !== oldWindowWidth ) {

$(window).off( 'resize.dtr orientationchange.dtr' );
dt.cells('.dtr-control').nodes().to$().removeClass('dtr-control');

@@ -245,3 +246,3 @@ // Restore the columns that we've hidden

that._resizeAuto();
that._resize();
that._resize(true);
} );

@@ -276,2 +277,6 @@

dt.on( 'init.dtr', function (e, settings, details) {
if ( e.namespace !== 'dt' ) {
return;
}
that._resizeAuto();

@@ -450,9 +455,8 @@ that._resize();

var priority = dt.settings()[0].aoColumns[i].responsivePriority;
var dataPriority = column.header().getAttribute('data-priority');
if ( priority === undefined ) {
var dataPriority = $(column.header()).data('priority');
priority = dataPriority !== undefined ?
dataPriority * 1 :
10000;
priority = dataPriority === undefined || dataPriority === null?
10000 :
dataPriority * 1;
}

@@ -618,3 +622,3 @@

if ( details.type === 'inline' ) {
details.target = 'td:first-child, th:first-child';
details.target = 'td.dtr-control, th.dtr-control';
}

@@ -638,47 +642,49 @@

// Click handler to show / hide the details rows when they are available
$( dt.table().body() )
.on( 'click.dtr mousedown.dtr mouseup.dtr', selector, function (e) {
// If the table is not collapsed (i.e. there is no hidden columns)
// then take no action
if ( ! $(dt.table().node()).hasClass('collapsed' ) ) {
return;
}
if ( target !== undefined || target !== null ) {
// Click handler to show / hide the details rows when they are available
$( dt.table().body() )
.on( 'click.dtr mousedown.dtr mouseup.dtr', selector, function (e) {
// If the table is not collapsed (i.e. there is no hidden columns)
// then take no action
if ( ! $(dt.table().node()).hasClass('collapsed' ) ) {
return;
}
// Check that the row is actually a DataTable's controlled node
if ( $.inArray( $(this).closest('tr').get(0), dt.rows().nodes().toArray() ) === -1 ) {
return;
}
// Check that the row is actually a DataTable's controlled node
if ( $.inArray( $(this).closest('tr').get(0), dt.rows().nodes().toArray() ) === -1 ) {
return;
}
// For column index, we determine if we should act or not in the
// handler - otherwise it is already okay
if ( typeof target === 'number' ) {
var targetIdx = target < 0 ?
dt.columns().eq(0).length + target :
target;
// For column index, we determine if we should act or not in the
// handler - otherwise it is already okay
if ( typeof target === 'number' ) {
var targetIdx = target < 0 ?
dt.columns().eq(0).length + target :
target;
if ( dt.cell( this ).index().column !== targetIdx ) {
return;
if ( dt.cell( this ).index().column !== targetIdx ) {
return;
}
}
}
// $().closest() includes itself in its check
var row = dt.row( $(this).closest('tr') );
// $().closest() includes itself in its check
var row = dt.row( $(this).closest('tr') );
// Check event type to do an action
if ( e.type === 'click' ) {
// The renderer is given as a function so the caller can execute it
// only when they need (i.e. if hiding there is no point is running
// the renderer)
that._detailsDisplay( row, false );
}
else if ( e.type === 'mousedown' ) {
// For mouse users, prevent the focus ring from showing
$(this).css('outline', 'none');
}
else if ( e.type === 'mouseup' ) {
// And then re-allow at the end of the click
$(this).blur().css('outline', '');
}
} );
// Check event type to do an action
if ( e.type === 'click' ) {
// The renderer is given as a function so the caller can execute it
// only when they need (i.e. if hiding there is no point is running
// the renderer)
that._detailsDisplay( row, false );
}
else if ( e.type === 'mousedown' ) {
// For mouse users, prevent the focus ring from showing
$(this).css('outline', 'none');
}
else if ( e.type === 'mouseup' ) {
// And then re-allow at the end of the click
$(this).trigger('blur').css('outline', '');
}
} );
}
},

@@ -703,8 +709,11 @@

var dtCol = dt.settings()[0].aoColumns[ i ];
return {
title: dt.settings()[0].aoColumns[ i ].sTitle,
className: dtCol.sClass,
columnIndex: i,
data: dt.cell( rowIdx, i ).render( that.c.orthogonal ),
hidden: dt.column( i ).visible() && !that.s.current[ i ],
columnIndex: i,
rowIndex: rowIdx
rowIndex: rowIdx,
title: dtCol.sTitle
};

@@ -758,9 +767,10 @@ } );

*
* @param {boolean} forceRedraw Force a redraw
* @private
*/
_resize: function ()
_resize: function (forceRedraw)
{
var that = this;
var dt = this.s.dt;
var width = $(window).width();
var width = $(window).innerWidth();
var breakpoints = this.c.breakpoints;

@@ -788,2 +798,3 @@ var breakpoint = breakpoints[0].name;

var collapsedClass = false;
for ( i=0, ien=columns.length ; i<ien ; i++ ) {

@@ -806,3 +817,3 @@ if ( columnsVis[i] === false && ! columns[i].never && ! columns[i].control && ! dt.column(i).visible() === false ) {

if ( columnsVis[i] !== oldVis[i] ) {
if ( forceRedraw || columnsVis[i] !== oldVis[i] ) {
changed = true;

@@ -824,2 +835,25 @@ that._setColumnVis( colIdx, columnsVis[i] );

}
// Add a control class to the element which should show the control element
if ( this.c.details.type === 'inline' ) {
var firstVisible = $.inArray(true, columnsVis);
// Remove from any cells which shouldn't have it
dt.cells(
null,
function(idx) {
return idx !== firstVisible;
},
{page: 'current'}
)
.nodes()
.to$()
.filter('.dtr-control')
.removeClass('dtr-control');
dt.cells(null, firstVisible, {page: 'current'})
.nodes()
.to$()
.addClass('dtr-control');
}
},

@@ -868,2 +902,4 @@

clonedTable.style.width = 'auto';
// Header

@@ -878,2 +914,3 @@ var headerCells = dt.columns()

.css( 'display', 'table-cell' )
.css( 'width', 'auto' )
.css( 'min-width', 0 );

@@ -946,2 +983,19 @@

/**
* Get the state of the current hidden columns - controlled by Responsive only
*/
_responsiveOnlyHidden: function ()
{
var dt = this.s.dt;
return $.map( this.s.current, function (v, i) {
// If the column is hidden by DataTables then it can't be hidden by
// Responsive!
if ( dt.column(i).visible() === false ) {
return true;
}
return v;
} );
},
/**
* Set a column's visibility.

@@ -1199,4 +1253,8 @@ *

if ( col.hidden ) {
var klass = col.className ?
'class="'+ col.className +'"' :
'';
$(
'<li data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
'<li '+klass+' data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
'<span class="dtr-title">'+

@@ -1223,4 +1281,8 @@ col.title+

var data = $.map( columns, function ( col ) {
var klass = col.className ?
'class="'+ col.className +'"' :
'';
return col.hidden ?
'<li data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
'<li '+klass+' data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
'<span class="dtr-title">'+

@@ -1249,3 +1311,7 @@ col.title+

var data = $.map( columns, function ( col ) {
return '<tr data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
var klass = col.className ?
'class="'+ col.className +'"' :
'';
return '<tr '+klass+' data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
'<td>'+col.title+':'+'</td> '+

@@ -1366,3 +1432,3 @@ '<td>'+col.data+'</td>'+

return ctx._responsive ?
$.inArray( false, ctx._responsive.s.current ) !== -1 :
$.inArray( false, ctx._responsive._responsiveOnlyHidden() ) !== -1 :
false;

@@ -1374,3 +1440,3 @@ } );

return settings._responsive ?
settings._responsive.s.current[ column ] :
settings._responsive._responsiveOnlyHidden()[ column ] :
false;

@@ -1387,3 +1453,3 @@ }, 1 );

*/
Responsive.version = '2.2.3';
Responsive.version = '2.2.4';

@@ -1390,0 +1456,0 @@

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

@@ -5,0 +5,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc