datatables.net-responsive
Advanced tools
Comparing version 2.5.0 to 3.0.0
@@ -1,2 +0,2 @@ | ||
/*! Responsive 2.5.0 | ||
/*! Responsive 3.0.0 | ||
* © SpryMedia Ltd - datatables.net/license | ||
@@ -46,3 +46,3 @@ */ | ||
} | ||
}(function( $, window, document, undefined ) { | ||
}(function( $, window, document ) { | ||
'use strict'; | ||
@@ -56,3 +56,3 @@ var DataTable = $.fn.dataTable; | ||
* @description Responsive tables plug-in for DataTables | ||
* @version 2.5.0 | ||
* @version 3.0.0 | ||
* @author SpryMedia Ltd | ||
@@ -118,4 +118,4 @@ * @copyright SpryMedia Ltd. | ||
// Sanity check that we are using DataTables 1.10 or newer | ||
if (!DataTable.versionCheck || !DataTable.versionCheck('1.10.10')) { | ||
throw 'DataTables Responsive requires DataTables 1.10.10 or newer'; | ||
if (!DataTable.versionCheck || !DataTable.versionCheck('2')) { | ||
throw 'DataTables Responsive requires DataTables 2 or newer'; | ||
} | ||
@@ -147,3 +147,9 @@ | ||
this.c = $.extend(true, {}, Responsive.defaults, DataTable.defaults.responsive, opts); | ||
this.c = $.extend( | ||
true, | ||
{}, | ||
Responsive.defaults, | ||
DataTable.defaults.responsive, | ||
opts | ||
); | ||
settings.responsive = this; | ||
@@ -166,3 +172,2 @@ this._constructor(); | ||
var dt = this.s.dt; | ||
var dtPrivateSettings = dt.settings()[0]; | ||
var oldWindowWidth = $(window).innerWidth(); | ||
@@ -172,6 +177,5 @@ | ||
// Use DataTables' throttle function to avoid processor thrashing on | ||
// resize | ||
// Use DataTables' throttle function to avoid processor thrashing | ||
$(window).on( | ||
'resize.dtr orientationchange.dtr', | ||
'orientationchange.dtr', | ||
DataTable.util.throttle(function () { | ||
@@ -189,20 +193,16 @@ // iOS has a bug whereby resize can fire when only scrolling | ||
// DataTables doesn't currently trigger an event when a row is added, so | ||
// we need to hook into its private API to enforce the hidden rows when | ||
// new data is added | ||
dtPrivateSettings.oApi._fnCallbackReg( | ||
dtPrivateSettings, | ||
'aoRowCreatedCallback', | ||
function (tr, data, idx) { | ||
if ($.inArray(false, that.s.current) !== -1) { | ||
$('>td, >th', tr).each(function (i) { | ||
var idx = dt.column.index('toData', i); | ||
// Handle new rows being dynamically added - needed as responsive | ||
// updates all rows (shown or not) a responsive change, rather than | ||
// per draw. | ||
dt.on('row-created.dtr', function (e, tr, data, idx) { | ||
if ($.inArray(false, that.s.current) !== -1) { | ||
$('>td, >th', tr).each(function (i) { | ||
var idx = dt.column.index('toData', i); | ||
if (that.s.current[idx] === false) { | ||
$(this).css('display', 'none'); | ||
} | ||
}); | ||
} | ||
if (that.s.current[idx] === false) { | ||
$(this).css('display', 'none'); | ||
} | ||
}); | ||
} | ||
); | ||
}); | ||
@@ -215,2 +215,3 @@ // Destroy event handler | ||
dt.cells('.dtr-control').nodes().to$().removeClass('dtr-control'); | ||
$(dt.table().node()).removeClass('dtr-inline collapsed'); | ||
@@ -381,12 +382,14 @@ // Restore the columns that we've hidden | ||
var store = this.s.childNodeStore[name]; | ||
var parent = store[0].parentNode; | ||
var parentChildren = parent.childNodes; | ||
var a = []; | ||
if (store.length > 0) { | ||
var parent = store[0].parentNode; | ||
var parentChildren = parent.childNodes; | ||
var a = []; | ||
for (var i = 0, ien = parentChildren.length; i < ien; i++) { | ||
a.push(parentChildren[i]); | ||
} | ||
for (var i = 0, ien = parentChildren.length; i < ien; i++) { | ||
a.push(parentChildren[i]); | ||
} | ||
for (var j = 0, jen = a.length; j < jen; j++) { | ||
node.appendChild(a[j]); | ||
for (var j = 0, jen = a.length; j < jen; j++) { | ||
node.appendChild(a[j]); | ||
} | ||
} | ||
@@ -481,3 +484,7 @@ | ||
if (display[colIdx] === '-' && !columns[colIdx].control && columns[colIdx].minWidth) { | ||
if ( | ||
display[colIdx] === '-' && | ||
!columns[colIdx].control && | ||
columns[colIdx].minWidth | ||
) { | ||
// Once we've found a column that won't fit we don't let any | ||
@@ -506,3 +513,7 @@ // others display either, or columns might disappear in the | ||
for (i = 0, ien = columns.length; i < ien; i++) { | ||
if (!columns[i].control && !columns[i].never && display[i] === false) { | ||
if ( | ||
!columns[i].control && | ||
!columns[i].never && | ||
display[i] === false | ||
) { | ||
showControl = true; | ||
@@ -543,3 +554,2 @@ break; | ||
var that = this; | ||
var calc = {}; | ||
var breakpoints = this.c.breakpoints; | ||
@@ -553,4 +563,6 @@ var dt = this.s.dt; | ||
var className = column.header().className; | ||
var priority = dt.settings()[0].aoColumns[i].responsivePriority; | ||
var dataPriority = column.header().getAttribute('data-priority'); | ||
var priority = column.init().responsivePriority; | ||
var dataPriority = column | ||
.header() | ||
.getAttribute('data-priority'); | ||
@@ -638,3 +650,7 @@ if (priority === undefined) { | ||
} | ||
else if (className === 'none' || className === 'dtr-none' || col.never) { | ||
else if ( | ||
className === 'none' || | ||
className === 'dtr-none' || | ||
col.never | ||
) { | ||
// Include in none (default) and no auto | ||
@@ -644,3 +660,6 @@ hasClass = true; | ||
} | ||
else if (className === 'control' || className === 'dtr-control') { | ||
else if ( | ||
className === 'control' || | ||
className === 'dtr-control' | ||
) { | ||
// Special column that is only visible, when one of the other | ||
@@ -657,3 +676,5 @@ // columns is hidden. This is used for the details control | ||
var re = new RegExp( | ||
'(min\\-|max\\-|not\\-)?(' + brokenPoint[0] + ')(\\-[_a-zA-Z0-9])?' | ||
'(min\\-|max\\-|not\\-)?(' + | ||
brokenPoint[0] + | ||
')(\\-[_a-zA-Z0-9])?' | ||
); | ||
@@ -665,5 +686,13 @@ var match = className.match(re); | ||
if (match[2] === brokenPoint[0] && match[3] === '-' + brokenPoint[1]) { | ||
if ( | ||
match[2] === brokenPoint[0] && | ||
match[3] === '-' + brokenPoint[1] | ||
) { | ||
// Class name matches breakpoint name fully | ||
column(i, breakpoint.name, match[1], match[2] + match[3]); | ||
column( | ||
i, | ||
breakpoint.name, | ||
match[1], | ||
match[2] + match[3] | ||
); | ||
} | ||
@@ -710,3 +739,6 @@ else if (match[2] === brokenPoint[0] && !match[3]) { | ||
dt.cells(null, firstVisible, { page: 'current' }).nodes().to$().addClass('dtr-control'); | ||
dt.cells(null, firstVisible, { page: 'current' }) | ||
.nodes() | ||
.to$() | ||
.addClass('dtr-control'); | ||
} | ||
@@ -727,4 +759,9 @@ }, | ||
var event = function (res) { | ||
$(row.node()).toggleClass('parent', res !== false); | ||
$(dt.table().node()).triggerHandler('responsive-display.dt', [dt, row, res, update]); | ||
$(row.node()).toggleClass('dtr-expanded', res !== false); | ||
$(dt.table().node()).triggerHandler('responsive-display.dt', [ | ||
dt, | ||
row, | ||
res, | ||
update | ||
]); | ||
}; | ||
@@ -742,3 +779,8 @@ | ||
function () { | ||
return renderer.call(that, dt, row[0], that._detailsObj(row[0])); | ||
return renderer.call( | ||
that, | ||
dt, | ||
row[0][0], | ||
that._detailsObj(row[0]) | ||
); | ||
}, | ||
@@ -789,43 +831,55 @@ function () { | ||
// 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; | ||
} | ||
$(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); | ||
// 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', ''); | ||
} | ||
} | ||
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', ''); | ||
} | ||
}); | ||
); | ||
} | ||
@@ -857,3 +911,3 @@ }, | ||
rowIndex: rowIdx, | ||
title: dtCol.sTitle !== null ? dtCol.sTitle : $(dt.column(i).header()).text() | ||
title: dt.column(i).title() | ||
}; | ||
@@ -946,2 +1000,3 @@ }); | ||
var visible = 0; | ||
var dtSettings = dt.settings()[0]; | ||
@@ -951,2 +1006,8 @@ dt.columns() | ||
.each(function (colIdx, i) { | ||
// Do nothing on DataTables' hidden column - DT removes it from the table | ||
// so we need to slide back | ||
if (! dt.column(colIdx).visible()) { | ||
return; | ||
} | ||
if (columnsVis[i] === true) { | ||
@@ -960,11 +1021,19 @@ visible++; | ||
} | ||
// DataTables 2 uses `col` to define the width for a column | ||
// and this needs to run each time, as DataTables will change | ||
// the column width | ||
if (! columnsVis[i]) { | ||
$(dtSettings.aoColumns[colIdx].colEl).detach(); | ||
} | ||
}); | ||
// Always need to update the display, regardless of if it has changed or not, so nodes | ||
// can be re-inserted for listHiddenNodes | ||
this._redrawChildren(); | ||
if (changed) { | ||
this._redrawChildren(); | ||
if (changed) { | ||
// Inform listeners of the change | ||
$(dt.table().node()).trigger('responsive-resize.dt', [dt, this.s.current]); | ||
$(dt.table().node()).trigger('responsive-resize.dt', [ | ||
dt, | ||
this._responsiveOnlyHidden() | ||
]); | ||
@@ -992,2 +1061,8 @@ // If no records, update the "No records" display element | ||
var that = this; | ||
var visibleColumns = dt | ||
.columns() | ||
.indexes() | ||
.filter(function (idx) { | ||
return dt.column(idx).visible(); | ||
}); | ||
@@ -1012,17 +1087,14 @@ // Are we allowed to do auto sizing? | ||
// Need to restore all children. They will be reinstated by a re-render | ||
if (!$.isEmptyObject(this.s.childNodeStore)) { | ||
$.each(this.s.childNodeStore, function (key) { | ||
var idx = key.split('-'); | ||
that._childNodesRestore(dt, idx[0] * 1, idx[1] * 1); | ||
}); | ||
} | ||
// Clone the table with the current data in it | ||
var tableWidth = dt.table().node().offsetWidth; | ||
var columnWidths = dt.columns; | ||
var clonedTable = dt.table().node().cloneNode(false); | ||
var clonedHeader = $(dt.table().header().cloneNode(false)).appendTo(clonedTable); | ||
var clonedBody = $(dt.table().body()).clone(false, false).empty().appendTo(clonedTable); // use jQuery because of IE8 | ||
var clonedHeader = $(dt.table().header().cloneNode(false)).appendTo( | ||
clonedTable | ||
); | ||
var clonedFooter = $(dt.table().footer().cloneNode(false)).appendTo( | ||
clonedTable | ||
); | ||
var clonedBody = $(dt.table().body()) | ||
.clone(false, false) | ||
.empty() | ||
.appendTo(clonedTable); // use jQuery because of IE8 | ||
@@ -1032,40 +1104,78 @@ clonedTable.style.width = 'auto'; | ||
// Header | ||
var headerCells = dt | ||
.columns() | ||
.header() | ||
.filter(function (idx) { | ||
return dt.column(idx).visible(); | ||
}) | ||
.to$() | ||
.clone(false) | ||
.css('display', 'table-cell') | ||
.css('width', 'auto') | ||
.css('min-width', 0); | ||
dt.table() | ||
.header.structure(visibleColumns) | ||
.forEach((row) => { | ||
var cells = row | ||
.filter(function (el) { | ||
return el ? true : false; | ||
}) | ||
.map(function (el) { | ||
return $(el.cell) | ||
.clone(false) | ||
.css('display', 'table-cell') | ||
.css('width', 'auto') | ||
.css('min-width', 0); | ||
}); | ||
$('<tr/>').append(cells).appendTo(clonedHeader); | ||
}); | ||
// Always need an empty row that we can read widths from | ||
var emptyRow = $('<tr/>').appendTo(clonedBody); | ||
for (var i = 0; i < visibleColumns.count(); i++) { | ||
emptyRow.append('<td/>'); | ||
} | ||
// Body rows - we don't need to take account of DataTables' column | ||
// visibility since we implement our own here (hence the `display` set) | ||
$(clonedBody) | ||
.append($(dt.rows({ page: 'current' }).nodes()).clone(false)) | ||
.find('th, td') | ||
.css('display', ''); | ||
dt.rows({ page: 'current' }).every(function (rowIdx) { | ||
var node = this.node(); | ||
if (! node) { | ||
return; | ||
} | ||
// We clone the table's rows and cells to create the sizing table | ||
var tr = node.cloneNode(false); | ||
dt.cells(rowIdx, '*').every(function (rowIdx2, colIdx) { | ||
// If nodes have been moved out (listHiddenNodes), we need to | ||
// clone from the store | ||
var store = that.s.childNodeStore[rowIdx + '-' + colIdx]; | ||
if (store) { | ||
$(this.node().cloneNode(false)) | ||
.append($(store).clone()) | ||
.appendTo(tr); | ||
} | ||
else { | ||
$(this.node()).clone(false).appendTo(tr); | ||
} | ||
}); | ||
clonedBody.append(tr); | ||
}); | ||
clonedBody.find('th, td').css('display', ''); | ||
// Footer | ||
var footer = dt.table().footer(); | ||
if (footer) { | ||
var clonedFooter = $(footer.cloneNode(false)).appendTo(clonedTable); | ||
var footerCells = dt | ||
.columns() | ||
.footer() | ||
.filter(function (idx) { | ||
return dt.column(idx).visible(); | ||
}) | ||
.to$() | ||
.clone(false) | ||
.css('display', 'table-cell'); | ||
dt.table() | ||
.footer.structure(visibleColumns) | ||
.forEach((row) => { | ||
var cells = row | ||
.filter(function (el) { | ||
return el ? true : false; | ||
}) | ||
.map(function (el) { | ||
return $(el.cell) | ||
.clone(false) | ||
.css('display', 'table-cell') | ||
.css('width', 'auto') | ||
.css('min-width', 0); | ||
}); | ||
$('<tr/>').append(footerCells).appendTo(clonedFooter); | ||
} | ||
$('<tr/>').append(cells).appendTo(clonedFooter); | ||
}); | ||
$('<tr/>').append(headerCells).appendTo(clonedHeader); | ||
// In the inline case extra padding is applied to the first column to | ||
@@ -1098,4 +1208,4 @@ // give space for the show / hide icon. We need to use this in the | ||
// The cloned header now contains the smallest that each column can be | ||
headerCells.each(function (i) { | ||
// The cloned table now contains the smallest that each column can be | ||
emptyRow.children().each(function (i) { | ||
var idx = dt.column.index('fromVisible', i); | ||
@@ -1141,8 +1251,11 @@ columns[idx].minWidth = this.offsetWidth || 0; | ||
$(dt.column(col).header()).css('display', display).toggleClass('dtr-hidden', !showHide); | ||
this._setHeaderVis(col, showHide, dt.table().header.structure()); | ||
this._setHeaderVis(col, showHide, dt.table().footer.structure()); | ||
$(dt.column(col).footer()).css('display', display).toggleClass('dtr-hidden', !showHide); | ||
dt.column(col) | ||
.nodes() | ||
.to$() | ||
.css('display', display) | ||
.toggleClass('dtr-hidden', !showHide); | ||
dt.column(col).nodes().to$().css('display', display).toggleClass('dtr-hidden', !showHide); | ||
// If the are child nodes stored, we might need to reinsert them | ||
@@ -1159,2 +1272,59 @@ if (!$.isEmptyObject(this.s.childNodeStore)) { | ||
/** | ||
* Set the a column's visibility, taking into account multiple rows | ||
* in a header / footer and colspan attributes | ||
* @param {*} col | ||
* @param {*} showHide | ||
* @param {*} structure | ||
*/ | ||
_setHeaderVis: function (col, showHide, structure) { | ||
var that = this; | ||
var display = showHide ? '' : 'none'; | ||
structure.forEach(function (row) { | ||
if (row[col]) { | ||
$(row[col].cell) | ||
.css('display', display) | ||
.toggleClass('dtr-hidden', !showHide); | ||
} | ||
else { | ||
// In a colspan - need to rewind calc the new span since | ||
// display:none elements do not count as being spanned over | ||
var search = col; | ||
while (search >= 0) { | ||
if (row[search]) { | ||
row[search].cell.colSpan = that._colspan(row, search); | ||
break; | ||
} | ||
search--; | ||
} | ||
} | ||
}); | ||
}, | ||
/** | ||
* How many columns should this cell span | ||
* | ||
* @param {*} row Header structure row | ||
* @param {*} idx The column index of the cell to span | ||
*/ | ||
_colspan: function (row, idx) { | ||
var colspan = 1; | ||
for (var col = idx + 1; col < row.length; col++) { | ||
if (row[col] === null && this.s.current[col]) { | ||
// colspan and not hidden by Responsive | ||
colspan++; | ||
} | ||
else if (row[col]) { | ||
// Got the next cell, jump out | ||
break; | ||
} | ||
} | ||
return colspan; | ||
}, | ||
/** | ||
* Update the cell tab indexes for keyboard accessibility. This is called on | ||
@@ -1225,4 +1395,6 @@ * every table draw - that is potentially inefficient, but also the least | ||
childRow: function (row, update, render) { | ||
var rowNode = $(row.node()); | ||
if (update) { | ||
if ($(row.node()).hasClass('parent')) { | ||
if (rowNode.hasClass('dtr-expanded')) { | ||
row.child(render(), 'child').show(); | ||
@@ -1234,5 +1406,10 @@ | ||
else { | ||
if (!row.child.isShown()) { | ||
row.child(render(), 'child').show(); | ||
if (!rowNode.hasClass('dtr-expanded')) { | ||
var rendered = render(); | ||
if (rendered === false) { | ||
return false; | ||
} | ||
row.child(rendered, 'child').show(); | ||
return true; | ||
@@ -1249,3 +1426,8 @@ } | ||
childRowImmediate: function (row, update, render) { | ||
if ((!update && row.child.isShown()) || !row.responsive.hasHidden()) { | ||
var rowNode = $(row.node()); | ||
if ( | ||
(!update && rowNode.hasClass('dtr-expanded')) || | ||
!row.responsive.hasHidden() | ||
) { | ||
// User interaction and the row is show, or nothing to show | ||
@@ -1258,4 +1440,10 @@ row.child(false); | ||
// Display | ||
row.child(render(), 'child').show(); | ||
var rendered = render(); | ||
if (rendered === false) { | ||
return false; | ||
} | ||
row.child(rendered, 'child').show(); | ||
return true; | ||
@@ -1270,2 +1458,9 @@ } | ||
return function (row, update, render, closeCallback) { | ||
var modal; | ||
var rendered = render(); | ||
if (rendered === false) { | ||
return false; | ||
} | ||
if (!update) { | ||
@@ -1276,3 +1471,3 @@ // Show a modal | ||
$(document).off('keypress.dtr'); | ||
$(row.node()).removeClass('parent'); | ||
$(row.node()).removeClass('dtr-expanded'); | ||
@@ -1282,3 +1477,3 @@ closeCallback(); | ||
var modal = $('<div class="dtr-modal"/>') | ||
modal = $('<div class="dtr-modal"/>') | ||
.append( | ||
@@ -1289,6 +1484,8 @@ $('<div class="dtr-modal-display"/>') | ||
.data('dtr-row-idx', row.index()) | ||
.append(render()) | ||
.append(rendered) | ||
) | ||
.append( | ||
$('<div class="dtr-modal-close">×</div>').click(function () { | ||
$( | ||
'<div class="dtr-modal-close">×</div>' | ||
).click(function () { | ||
close(); | ||
@@ -1299,9 +1496,11 @@ }) | ||
.append( | ||
$('<div class="dtr-modal-background"/>').click(function () { | ||
close(); | ||
}) | ||
$('<div class="dtr-modal-background"/>').click( | ||
function () { | ||
close(); | ||
} | ||
) | ||
) | ||
.appendTo('body'); | ||
$(row.node()).addClass('parent'); | ||
$(row.node()).addClass('dtr-expanded'); | ||
@@ -1317,6 +1516,6 @@ $(document).on('keyup.dtr', function (e) { | ||
else { | ||
var modal = $('div.dtr-modal-content'); | ||
modal = $('div.dtr-modal-content'); | ||
if (modal.length && row.index() === modal.data('dtr-row-idx')) { | ||
modal.empty().append(render()); | ||
modal.empty().append(rendered); | ||
} | ||
@@ -1330,3 +1529,5 @@ else { | ||
if (options && options.header) { | ||
$('div.dtr-modal-content').prepend('<h2>' + options.header(row) + '</h2>'); | ||
$('div.dtr-modal-content').prepend( | ||
'<h2>' + options.header(row) + '</h2>' | ||
); | ||
} | ||
@@ -1351,8 +1552,12 @@ | ||
var that = this; | ||
var ul = $('<ul data-dtr-index="' + rowIdx + '" class="dtr-details"/>'); | ||
var ul = $( | ||
'<ul data-dtr-index="' + rowIdx + '" class="dtr-details"/>' | ||
); | ||
var found = false; | ||
var data = $.each(columns, function (i, col) { | ||
$.each(columns, function (i, col) { | ||
if (col.hidden) { | ||
var klass = col.className ? 'class="' + col.className + '"' : ''; | ||
var klass = col.className | ||
? 'class="' + col.className + '"' | ||
: ''; | ||
@@ -1376,3 +1581,7 @@ $( | ||
$('<span class="dtr-data"/>').append( | ||
that._childNodes(api, col.rowIndex, col.columnIndex) | ||
that._childNodes( | ||
api, | ||
col.rowIndex, | ||
col.columnIndex | ||
) | ||
) | ||
@@ -1393,3 +1602,5 @@ ) // api.cell( col.rowIndex, col.columnIndex ).node().childNodes ) ) | ||
var data = $.map(columns, function (col) { | ||
var klass = col.className ? 'class="' + col.className + '"' : ''; | ||
var klass = col.className | ||
? 'class="' + col.className + '"' | ||
: ''; | ||
@@ -1417,3 +1628,7 @@ return col.hidden | ||
return data | ||
? $('<ul data-dtr-index="' + rowIdx + '" class="dtr-details"/>').append(data) | ||
? $( | ||
'<ul data-dtr-index="' + | ||
rowIdx + | ||
'" class="dtr-details"/>' | ||
).append(data) | ||
: false; | ||
@@ -1433,3 +1648,5 @@ }; | ||
var data = $.map(columns, function (col) { | ||
var klass = col.className ? 'class="' + col.className + '"' : ''; | ||
var klass = col.className | ||
? 'class="' + col.className + '"' | ||
: ''; | ||
@@ -1455,5 +1672,7 @@ return ( | ||
return $('<table class="' + options.tableClass + ' dtr-details" width="100%"/>').append( | ||
data | ||
); | ||
return $( | ||
'<table class="' + | ||
options.tableClass + | ||
' dtr-details" width="100%"/>' | ||
).append(data); | ||
}; | ||
@@ -1571,13 +1790,17 @@ } | ||
Api.registerPlural('columns().responsiveHidden()', 'column().responsiveHidden()', function () { | ||
return this.iterator( | ||
'column', | ||
function (settings, column) { | ||
return settings._responsive | ||
? settings._responsive._responsiveOnlyHidden()[column] | ||
: false; | ||
}, | ||
1 | ||
); | ||
}); | ||
Api.registerPlural( | ||
'columns().responsiveHidden()', | ||
'column().responsiveHidden()', | ||
function () { | ||
return this.iterator( | ||
'column', | ||
function (settings, column) { | ||
return settings._responsive | ||
? settings._responsive._responsiveOnlyHidden()[column] | ||
: false; | ||
}, | ||
1 | ||
); | ||
} | ||
); | ||
@@ -1590,3 +1813,3 @@ /** | ||
*/ | ||
Responsive.version = '2.5.0'; | ||
Responsive.version = '3.0.0'; | ||
@@ -1593,0 +1816,0 @@ $.fn.dataTable.Responsive = Responsive; |
@@ -1,4 +0,4 @@ | ||
/*! Responsive 2.5.0 | ||
/*! Responsive 3.0.0 | ||
* © SpryMedia Ltd - datatables.net/license | ||
*/ | ||
!function(n){var i,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return n(e,window,document)}):"object"==typeof exports?(i=require("jquery"),r=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||i(e),r(e,t),n(t,e,e.document)}:(r(window,i),module.exports=n(i,window,window.document))):n(jQuery,window,document)}(function(f,m,d,h){"use strict";function a(e,t){if(!r.versionCheck||!r.versionCheck("1.10.10"))throw"DataTables Responsive requires DataTables 1.10.10 or newer";this.s={childNodeStore:{},columns:[],current:[],dt:new r.Api(e)},this.s.dt.settings()[0].responsive||(t&&"string"==typeof t.details?t.details={type:t.details}:t&&!1===t.details?t.details={type:!1}:t&&!0===t.details&&(t.details={type:"inline"}),this.c=f.extend(!0,{},a.defaults,r.defaults.responsive,t),(e.responsive=this)._constructor())}var r=f.fn.dataTable,e=(f.extend(a.prototype,{_constructor:function(){var s=this,i=this.s.dt,e=i.settings()[0],t=f(m).innerWidth(),e=(i.settings()[0]._responsive=this,f(m).on("resize.dtr orientationchange.dtr",r.util.throttle(function(){var e=f(m).innerWidth();e!==t&&(s._resize(),t=e)})),e.oApi._fnCallbackReg(e,"aoRowCreatedCallback",function(e,t,n){-1!==f.inArray(!1,s.s.current)&&f(">td, >th",e).each(function(e){e=i.column.index("toData",e);!1===s.s.current[e]&&f(this).css("display","none")})}),i.on("destroy.dtr",function(){i.off(".dtr"),f(i.table().body()).off(".dtr"),f(m).off("resize.dtr orientationchange.dtr"),i.cells(".dtr-control").nodes().to$().removeClass("dtr-control"),f.each(s.s.current,function(e,t){!1===t&&s._setColumnVis(e,!0)})}),this.c.breakpoints.sort(function(e,t){return e.width<t.width?1:e.width>t.width?-1:0}),this._classLogic(),this._resizeAuto(),this.c.details);!1!==e.type&&(s._detailsInit(),i.on("column-visibility.dtr",function(){s._timer&&clearTimeout(s._timer),s._timer=setTimeout(function(){s._timer=null,s._classLogic(),s._resizeAuto(),s._resize(!0),s._redrawChildren()},100)}),i.on("draw.dtr",function(){s._redrawChildren()}),f(i.table().node()).addClass("dtr-"+e.type)),i.on("column-reorder.dtr",function(e,t,n){s._classLogic(),s._resizeAuto(),s._resize(!0)}),i.on("column-sizing.dtr",function(){s._resizeAuto(),s._resize()}),i.on("column-calc.dt",function(e,t){for(var n=s.s.current,i=0;i<n.length;i++){var r=t.visible.indexOf(i);!1===n[i]&&0<=r&&t.visible.splice(r,1)}}),i.on("preXhr.dtr",function(){var e=[];i.rows().every(function(){this.child.isShown()&&e.push(this.id(!0))}),i.one("draw.dtr",function(){s._resizeAuto(),s._resize(),i.rows(e).every(function(){s._detailsDisplay(this,!1)})})}),i.on("draw.dtr",function(){s._controlClass()}).on("init.dtr",function(e,t,n){"dt"===e.namespace&&(s._resizeAuto(),s._resize(),f.inArray(!1,s.s.current)&&i.columns.adjust())}),this._resize()},_childNodes:function(e,t,n){var i=t+"-"+n;if(this.s.childNodeStore[i])return this.s.childNodeStore[i];for(var r=[],s=e.cell(t,n).node().childNodes,o=0,d=s.length;o<d;o++)r.push(s[o]);return this.s.childNodeStore[i]=r},_childNodesRestore:function(e,t,n){var i=t+"-"+n;if(this.s.childNodeStore[i]){for(var r=e.cell(t,n).node(),s=this.s.childNodeStore[i][0].parentNode.childNodes,o=[],d=0,a=s.length;d<a;d++)o.push(s[d]);for(var l=0,c=o.length;l<c;l++)r.appendChild(o[l]);this.s.childNodeStore[i]=h}},_columnsVisiblity:function(n){for(var i=this.s.dt,e=this.s.columns,t=e.map(function(e,t){return{columnIdx:t,priority:e.priority}}).sort(function(e,t){return e.priority!==t.priority?e.priority-t.priority:e.columnIdx-t.columnIdx}),r=f.map(e,function(e,t){return!1===i.column(t).visible()?"not-visible":(!e.auto||null!==e.minWidth)&&(!0===e.auto?"-":-1!==f.inArray(n,e.includeIn))}),s=0,o=0,d=r.length;o<d;o++)!0===r[o]&&(s+=e[o].minWidth);var a=i.settings()[0].oScroll,a=a.sY||a.sX?a.iBarWidth:0,l=i.table().container().offsetWidth-a-s;for(o=0,d=r.length;o<d;o++)e[o].control&&(l-=e[o].minWidth);var c=!1;for(o=0,d=t.length;o<d;o++){var u=t[o].columnIdx;"-"===r[u]&&!e[u].control&&e[u].minWidth&&(c||l-e[u].minWidth<0?r[u]=!(c=!0):r[u]=!0,l-=e[u].minWidth)}var h=!1;for(o=0,d=e.length;o<d;o++)if(!e[o].control&&!e[o].never&&!1===r[o]){h=!0;break}for(o=0,d=e.length;o<d;o++)e[o].control&&(r[o]=h),"not-visible"===r[o]&&(r[o]=!1);return-1===f.inArray(!0,r)&&(r[0]=!0),r},_classLogic:function(){function d(e,t,n,i){var r,s,o;if(n){if("max-"===n)for(r=a._find(t).width,s=0,o=l.length;s<o;s++)l[s].width<=r&&u(e,l[s].name);else if("min-"===n)for(r=a._find(t).width,s=0,o=l.length;s<o;s++)l[s].width>=r&&u(e,l[s].name);else if("not-"===n)for(s=0,o=l.length;s<o;s++)-1===l[s].name.indexOf(i)&&u(e,l[s].name)}else c[e].includeIn.push(t)}var a=this,l=this.c.breakpoints,i=this.s.dt,c=i.columns().eq(0).map(function(e){var t=this.column(e),n=t.header().className,e=i.settings()[0].aoColumns[e].responsivePriority,t=t.header().getAttribute("data-priority");return e===h&&(e=t===h||null===t?1e4:+t),{className:n,includeIn:[],auto:!1,control:!1,never:!!n.match(/\b(dtr\-)?never\b/),priority:e}}),u=function(e,t){e=c[e].includeIn;-1===f.inArray(t,e)&&e.push(t)};c.each(function(e,r){for(var t=e.className.split(" "),s=!1,n=0,i=t.length;n<i;n++){var o=t[n].trim();if("all"===o||"dtr-all"===o)return s=!0,void(e.includeIn=f.map(l,function(e){return e.name}));if("none"===o||"dtr-none"===o||e.never)return void(s=!0);if("control"===o||"dtr-control"===o)return s=!0,void(e.control=!0);f.each(l,function(e,t){var n=t.name.split("-"),i=new RegExp("(min\\-|max\\-|not\\-)?("+n[0]+")(\\-[_a-zA-Z0-9])?"),i=o.match(i);i&&(s=!0,i[2]===n[0]&&i[3]==="-"+n[1]?d(r,t.name,i[1],i[2]+i[3]):i[2]!==n[0]||i[3]||d(r,t.name,i[1],i[2]))})}s||(e.auto=!0)}),this.s.columns=c},_controlClass:function(){var e,t,n;"inline"===this.c.details.type&&(e=this.s.dt,t=this.s.current,n=f.inArray(!0,t),e.cells(null,function(e){return e!==n},{page:"current"}).nodes().to$().filter(".dtr-control").removeClass("dtr-control"),e.cells(null,n,{page:"current"}).nodes().to$().addClass("dtr-control"))},_detailsDisplay:function(t,n){function e(e){f(t.node()).toggleClass("parent",!1!==e),f(s.table().node()).triggerHandler("responsive-display.dt",[s,t,e,n])}var i,r=this,s=this.s.dt,o=this.c.details;o&&!1!==o.type&&(i="string"==typeof o.renderer?a.renderer[o.renderer]():o.renderer,"boolean"==typeof(o=o.display(t,n,function(){return i.call(r,s,t[0],r._detailsObj(t[0]))},function(){e(!1)}))&&e(o))},_detailsInit:function(){var n=this,i=this.s.dt,e=this.c.details,r=("inline"===e.type&&(e.target="td.dtr-control, th.dtr-control"),i.on("draw.dtr",function(){n._tabIndexes()}),n._tabIndexes(),f(i.table().body()).on("keyup.dtr","td, th",function(e){13===e.keyCode&&f(this).data("dtr-keyboard")&&f(this).click()}),e.target),e="string"==typeof r?r:"td, th";r===h&&null===r||f(i.table().body()).on("click.dtr mousedown.dtr mouseup.dtr",e,function(e){if(f(i.table().node()).hasClass("collapsed")&&-1!==f.inArray(f(this).closest("tr").get(0),i.rows().nodes().toArray())){if("number"==typeof r){var t=r<0?i.columns().eq(0).length+r:r;if(i.cell(this).index().column!==t)return}t=i.row(f(this).closest("tr"));"click"===e.type?n._detailsDisplay(t,!1):"mousedown"===e.type?f(this).css("outline","none"):"mouseup"===e.type&&f(this).trigger("blur").css("outline","")}})},_detailsObj:function(n){var i=this,r=this.s.dt;return f.map(this.s.columns,function(e,t){if(!e.never&&!e.control)return{className:(e=r.settings()[0].aoColumns[t]).sClass,columnIndex:t,data:r.cell(n,t).render(i.c.orthogonal),hidden:r.column(t).visible()&&!i.s.current[t],rowIndex:n,title:null!==e.sTitle?e.sTitle:f(r.column(t).header()).text()}})},_find:function(e){for(var t=this.c.breakpoints,n=0,i=t.length;n<i;n++)if(t[n].name===e)return t[n]},_redrawChildren:function(){var n=this,i=this.s.dt;i.rows({page:"current"}).iterator("row",function(e,t){n._detailsDisplay(i.row(t),!0)})},_resize:function(n){for(var e,i=this,t=this.s.dt,r=f(m).innerWidth(),s=this.c.breakpoints,o=s[0].name,d=this.s.columns,a=this.s.current.slice(),l=s.length-1;0<=l;l--)if(r<=s[l].width){o=s[l].name;break}var c=this._columnsVisiblity(o),u=(this.s.current=c,!1);for(l=0,e=d.length;l<e;l++)if(!1===c[l]&&!d[l].never&&!d[l].control&&!1==!t.column(l).visible()){u=!0;break}f(t.table().node()).toggleClass("collapsed",u);var h=!1,p=0;t.columns().eq(0).each(function(e,t){!0===c[t]&&p++,!n&&c[t]===a[t]||(h=!0,i._setColumnVis(e,c[t]))}),this._redrawChildren(),h&&(f(t.table().node()).trigger("responsive-resize.dt",[t,this.s.current]),0===t.page.info().recordsDisplay&&f("td",t.table().body()).eq(0).attr("colspan",p)),i._controlClass()},_resizeAuto:function(){var e,t,n,i,r,s=this.s.dt,o=this.s.columns,d=this;this.c.auto&&-1!==f.inArray(!0,f.map(o,function(e){return e.auto}))&&(f.isEmptyObject(this.s.childNodeStore)||f.each(this.s.childNodeStore,function(e){e=e.split("-");d._childNodesRestore(s,+e[0],+e[1])}),s.table().node().offsetWidth,s.columns,e=s.table().node().cloneNode(!1),t=f(s.table().header().cloneNode(!1)).appendTo(e),i=f(s.table().body()).clone(!1,!1).empty().appendTo(e),e.style.width="auto",n=s.columns().header().filter(function(e){return s.column(e).visible()}).to$().clone(!1).css("display","table-cell").css("width","auto").css("min-width",0),f(i).append(f(s.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display",""),(i=s.table().footer())&&(i=f(i.cloneNode(!1)).appendTo(e),r=s.columns().footer().filter(function(e){return s.column(e).visible()}).to$().clone(!1).css("display","table-cell"),f("<tr/>").append(r).appendTo(i)),f("<tr/>").append(n).appendTo(t),"inline"===this.c.details.type&&f(e).addClass("dtr-inline collapsed"),f(e).find("[name]").removeAttr("name"),f(e).css("position","relative"),(r=f("<div/>").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(e)).insertBefore(s.table().node()),n.each(function(e){e=s.column.index("fromVisible",e);o[e].minWidth=this.offsetWidth||0}),r.remove())},_responsiveOnlyHidden:function(){var n=this.s.dt;return f.map(this.s.current,function(e,t){return!1===n.column(t).visible()||e})},_setColumnVis:function(e,t){var n=this,i=this.s.dt,r=t?"":"none";f(i.column(e).header()).css("display",r).toggleClass("dtr-hidden",!t),f(i.column(e).footer()).css("display",r).toggleClass("dtr-hidden",!t),i.column(e).nodes().to$().css("display",r).toggleClass("dtr-hidden",!t),f.isEmptyObject(this.s.childNodeStore)||i.cells(null,e).indexes().each(function(e){n._childNodesRestore(i,e.row,e.column)})},_tabIndexes:function(){var e=this.s.dt,t=e.cells({page:"current"}).nodes().to$(),n=e.settings()[0],i=this.c.details.target;t.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]"),("number"==typeof i?e.cells(null,i,{page:"current"}).nodes().to$():f(i="td:first-child, th:first-child"===i?">td:first-child, >th:first-child":i,e.rows({page:"current"}).nodes())).attr("tabIndex",n.iTabIndex).data("dtr-keyboard",1)}}),a.defaults={breakpoints:a.breakpoints=[{name:"desktop",width:1/0},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}],auto:!0,details:{display:(a.display={childRow:function(e,t,n){return t?f(e.node()).hasClass("parent")?(e.child(n(),"child").show(),!0):void 0:e.child.isShown()?(e.child(!1),!1):(e.child(n(),"child").show(),!0)},childRowImmediate:function(e,t,n){return!t&&e.child.isShown()||!e.responsive.hasHidden()?(e.child(!1),!1):(e.child(n(),"child").show(),!0)},modal:function(o){return function(e,t,n,i){if(t){if(!(s=f("div.dtr-modal-content")).length||e.index()!==s.data("dtr-row-idx"))return null;s.empty().append(n())}else{var r=function(){s.remove(),f(d).off("keypress.dtr"),f(e.node()).removeClass("parent"),i()},s=f('<div class="dtr-modal"/>').append(f('<div class="dtr-modal-display"/>').append(f('<div class="dtr-modal-content"/>').data("dtr-row-idx",e.index()).append(n())).append(f('<div class="dtr-modal-close">×</div>').click(function(){r()}))).append(f('<div class="dtr-modal-background"/>').click(function(){r()})).appendTo("body");f(e.node()).addClass("parent"),f(d).on("keyup.dtr",function(e){27===e.keyCode&&(e.stopPropagation(),r())})}return o&&o.header&&f("div.dtr-modal-content").prepend("<h2>"+o.header(e)+"</h2>"),!0}}}).childRow,renderer:(a.renderer={listHiddenNodes:function(){return function(i,e,t){var r=this,s=f('<ul data-dtr-index="'+e+'" class="dtr-details"/>'),o=!1;f.each(t,function(e,t){var n;t.hidden&&(n=t.className?'class="'+t.className+'"':"",f("<li "+n+' data-dtr-index="'+t.columnIndex+'" data-dt-row="'+t.rowIndex+'" data-dt-column="'+t.columnIndex+'"><span class="dtr-title">'+t.title+"</span> </li>").append(f('<span class="dtr-data"/>').append(r._childNodes(i,t.rowIndex,t.columnIndex))).appendTo(s),o=!0)});return!!o&&s}},listHidden:function(){return function(e,t,n){n=f.map(n,function(e){var t=e.className?'class="'+e.className+'"':"";return e.hidden?"<li "+t+' data-dtr-index="'+e.columnIndex+'" data-dt-row="'+e.rowIndex+'" data-dt-column="'+e.columnIndex+'"><span class="dtr-title">'+e.title+'</span> <span class="dtr-data">'+e.data+"</span></li>":""}).join("");return!!n&&f('<ul data-dtr-index="'+t+'" class="dtr-details"/>').append(n)}},tableAll:function(i){return i=f.extend({tableClass:""},i),function(e,t,n){n=f.map(n,function(e){return"<tr "+(e.className?'class="'+e.className+'"':"")+' data-dt-row="'+e.rowIndex+'" data-dt-column="'+e.columnIndex+'"><td>'+e.title+":</td> <td>"+e.data+"</td></tr>"}).join("");return f('<table class="'+i.tableClass+' dtr-details" width="100%"/>').append(n)}}}).listHidden(),target:0,type:"inline"},orthogonal:"display"},f.fn.dataTable.Api);return e.register("responsive()",function(){return this}),e.register("responsive.index()",function(e){return{column:(e=f(e)).data("dtr-index"),row:e.parent().data("dtr-index")}}),e.register("responsive.rebuild()",function(){return this.iterator("table",function(e){e._responsive&&e._responsive._classLogic()})}),e.register("responsive.recalc()",function(){return this.iterator("table",function(e){e._responsive&&(e._responsive._resizeAuto(),e._responsive._resize())})}),e.register("responsive.hasHidden()",function(){var e=this.context[0];return!!e._responsive&&-1!==f.inArray(!1,e._responsive._responsiveOnlyHidden())}),e.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(e,t){return!!e._responsive&&e._responsive._responsiveOnlyHidden()[t]},1)}),a.version="2.5.0",f.fn.dataTable.Responsive=a,f.fn.DataTable.Responsive=a,f(d).on("preInit.dt.dtr",function(e,t,n){"dt"===e.namespace&&(f(t.nTable).hasClass("responsive")||f(t.nTable).hasClass("dt-responsive")||t.oInit.responsive||r.defaults.responsive)&&!1!==(e=t.oInit.responsive)&&new a(t,f.isPlainObject(e)?e:{})}),r}); | ||
!function(n){var i,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return n(e,window,document)}):"object"==typeof exports?(i=require("jquery"),r=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||i(e),r(e,t),n(t,e,e.document)}:(r(window,i),module.exports=n(i,window,window.document))):n(jQuery,window,document)}(function(m,v,d){"use strict";function a(e,t){if(!i.versionCheck||!i.versionCheck("2"))throw"DataTables Responsive requires DataTables 2 or newer";this.s={childNodeStore:{},columns:[],current:[],dt:new i.Api(e)},this.s.dt.settings()[0].responsive||(t&&"string"==typeof t.details?t.details={type:t.details}:t&&!1===t.details?t.details={type:!1}:t&&!0===t.details&&(t.details={type:"inline"}),this.c=m.extend(!0,{},a.defaults,i.defaults.responsive,t),(e.responsive=this)._constructor())}var i=m.fn.dataTable,e=(m.extend(a.prototype,{_constructor:function(){var s=this,r=this.s.dt,t=m(v).innerWidth(),e=(r.settings()[0]._responsive=this,m(v).on("orientationchange.dtr",i.util.throttle(function(){var e=m(v).innerWidth();e!==t&&(s._resize(),t=e)})),r.on("row-created.dtr",function(e,t,n,i){-1!==m.inArray(!1,s.s.current)&&m(">td, >th",t).each(function(e){e=r.column.index("toData",e);!1===s.s.current[e]&&m(this).css("display","none")})}),r.on("destroy.dtr",function(){r.off(".dtr"),m(r.table().body()).off(".dtr"),m(v).off("resize.dtr orientationchange.dtr"),r.cells(".dtr-control").nodes().to$().removeClass("dtr-control"),m(r.table().node()).removeClass("dtr-inline collapsed"),m.each(s.s.current,function(e,t){!1===t&&s._setColumnVis(e,!0)})}),this.c.breakpoints.sort(function(e,t){return e.width<t.width?1:e.width>t.width?-1:0}),this._classLogic(),this._resizeAuto(),this.c.details);!1!==e.type&&(s._detailsInit(),r.on("column-visibility.dtr",function(){s._timer&&clearTimeout(s._timer),s._timer=setTimeout(function(){s._timer=null,s._classLogic(),s._resizeAuto(),s._resize(!0),s._redrawChildren()},100)}),r.on("draw.dtr",function(){s._redrawChildren()}),m(r.table().node()).addClass("dtr-"+e.type)),r.on("column-reorder.dtr",function(e,t,n){s._classLogic(),s._resizeAuto(),s._resize(!0)}),r.on("column-sizing.dtr",function(){s._resizeAuto(),s._resize()}),r.on("column-calc.dt",function(e,t){for(var n=s.s.current,i=0;i<n.length;i++){var r=t.visible.indexOf(i);!1===n[i]&&0<=r&&t.visible.splice(r,1)}}),r.on("preXhr.dtr",function(){var e=[];r.rows().every(function(){this.child.isShown()&&e.push(this.id(!0))}),r.one("draw.dtr",function(){s._resizeAuto(),s._resize(),r.rows(e).every(function(){s._detailsDisplay(this,!1)})})}),r.on("draw.dtr",function(){s._controlClass()}).on("init.dtr",function(e,t,n){"dt"===e.namespace&&(s._resizeAuto(),s._resize(),m.inArray(!1,s.s.current))&&r.columns.adjust()}),this._resize()},_childNodes:function(e,t,n){var i=t+"-"+n;if(this.s.childNodeStore[i])return this.s.childNodeStore[i];for(var r=[],s=e.cell(t,n).node().childNodes,o=0,d=s.length;o<d;o++)r.push(s[o]);return this.s.childNodeStore[i]=r},_childNodesRestore:function(e,t,n){var i=t+"-"+n;if(this.s.childNodeStore[i]){var r=e.cell(t,n).node(),e=this.s.childNodeStore[i];if(0<e.length){for(var s=e[0].parentNode.childNodes,o=[],d=0,a=s.length;d<a;d++)o.push(s[d]);for(var l=0,c=o.length;l<c;l++)r.appendChild(o[l])}this.s.childNodeStore[i]=void 0}},_columnsVisiblity:function(n){for(var i=this.s.dt,e=this.s.columns,t=e.map(function(e,t){return{columnIdx:t,priority:e.priority}}).sort(function(e,t){return e.priority!==t.priority?e.priority-t.priority:e.columnIdx-t.columnIdx}),r=m.map(e,function(e,t){return!1===i.column(t).visible()?"not-visible":(!e.auto||null!==e.minWidth)&&(!0===e.auto?"-":-1!==m.inArray(n,e.includeIn))}),s=0,o=0,d=r.length;o<d;o++)!0===r[o]&&(s+=e[o].minWidth);var a=i.settings()[0].oScroll,a=a.sY||a.sX?a.iBarWidth:0,l=i.table().container().offsetWidth-a-s;for(o=0,d=r.length;o<d;o++)e[o].control&&(l-=e[o].minWidth);var c=!1;for(o=0,d=t.length;o<d;o++){var u=t[o].columnIdx;"-"===r[u]&&!e[u].control&&e[u].minWidth&&(c||l-e[u].minWidth<0?r[u]=!(c=!0):r[u]=!0,l-=e[u].minWidth)}var h=!1;for(o=0,d=e.length;o<d;o++)if(!e[o].control&&!e[o].never&&!1===r[o]){h=!0;break}for(o=0,d=e.length;o<d;o++)e[o].control&&(r[o]=h),"not-visible"===r[o]&&(r[o]=!1);return-1===m.inArray(!0,r)&&(r[0]=!0),r},_classLogic:function(){function d(e,t,n,i){var r,s,o;if(n){if("max-"===n)for(r=a._find(t).width,s=0,o=l.length;s<o;s++)l[s].width<=r&&u(e,l[s].name);else if("min-"===n)for(r=a._find(t).width,s=0,o=l.length;s<o;s++)l[s].width>=r&&u(e,l[s].name);else if("not-"===n)for(s=0,o=l.length;s<o;s++)-1===l[s].name.indexOf(i)&&u(e,l[s].name)}else c[e].includeIn.push(t)}var a=this,l=this.c.breakpoints,c=this.s.dt.columns().eq(0).map(function(e){var e=this.column(e),t=e.header().className,n=e.init().responsivePriority,e=e.header().getAttribute("data-priority");return void 0===n&&(n=null==e?1e4:+e),{className:t,includeIn:[],auto:!1,control:!1,never:!!t.match(/\b(dtr\-)?never\b/),priority:n}}),u=function(e,t){e=c[e].includeIn;-1===m.inArray(t,e)&&e.push(t)};c.each(function(e,r){for(var t=e.className.split(" "),s=!1,n=0,i=t.length;n<i;n++){var o=t[n].trim();if("all"===o||"dtr-all"===o)return s=!0,void(e.includeIn=m.map(l,function(e){return e.name}));if("none"===o||"dtr-none"===o||e.never)return void(s=!0);if("control"===o||"dtr-control"===o)return s=!0,void(e.control=!0);m.each(l,function(e,t){var n=t.name.split("-"),i=new RegExp("(min\\-|max\\-|not\\-)?("+n[0]+")(\\-[_a-zA-Z0-9])?"),i=o.match(i);i&&(s=!0,i[2]===n[0]&&i[3]==="-"+n[1]?d(r,t.name,i[1],i[2]+i[3]):i[2]!==n[0]||i[3]||d(r,t.name,i[1],i[2]))})}s||(e.auto=!0)}),this.s.columns=c},_controlClass:function(){var e,t,n;"inline"===this.c.details.type&&(e=this.s.dt,t=this.s.current,n=m.inArray(!0,t),e.cells(null,function(e){return e!==n},{page:"current"}).nodes().to$().filter(".dtr-control").removeClass("dtr-control"),e.cells(null,n,{page:"current"}).nodes().to$().addClass("dtr-control"))},_detailsDisplay:function(t,n){function e(e){m(t.node()).toggleClass("dtr-expanded",!1!==e),m(s.table().node()).triggerHandler("responsive-display.dt",[s,t,e,n])}var i,r=this,s=this.s.dt,o=this.c.details;o&&!1!==o.type&&(i="string"==typeof o.renderer?a.renderer[o.renderer]():o.renderer,"boolean"==typeof(o=o.display(t,n,function(){return i.call(r,s,t[0][0],r._detailsObj(t[0]))},function(){e(!1)})))&&e(o)},_detailsInit:function(){var n=this,i=this.s.dt,e=this.c.details,r=("inline"===e.type&&(e.target="td.dtr-control, th.dtr-control"),i.on("draw.dtr",function(){n._tabIndexes()}),n._tabIndexes(),m(i.table().body()).on("keyup.dtr","td, th",function(e){13===e.keyCode&&m(this).data("dtr-keyboard")&&m(this).click()}),e.target),e="string"==typeof r?r:"td, th";void 0===r&&null===r||m(i.table().body()).on("click.dtr mousedown.dtr mouseup.dtr",e,function(e){if(m(i.table().node()).hasClass("collapsed")&&-1!==m.inArray(m(this).closest("tr").get(0),i.rows().nodes().toArray())){if("number"==typeof r){var t=r<0?i.columns().eq(0).length+r:r;if(i.cell(this).index().column!==t)return}t=i.row(m(this).closest("tr"));"click"===e.type?n._detailsDisplay(t,!1):"mousedown"===e.type?m(this).css("outline","none"):"mouseup"===e.type&&m(this).trigger("blur").css("outline","")}})},_detailsObj:function(n){var i=this,r=this.s.dt;return m.map(this.s.columns,function(e,t){if(!e.never&&!e.control)return{className:r.settings()[0].aoColumns[t].sClass,columnIndex:t,data:r.cell(n,t).render(i.c.orthogonal),hidden:r.column(t).visible()&&!i.s.current[t],rowIndex:n,title:r.column(t).title()}})},_find:function(e){for(var t=this.c.breakpoints,n=0,i=t.length;n<i;n++)if(t[n].name===e)return t[n]},_redrawChildren:function(){var n=this,i=this.s.dt;i.rows({page:"current"}).iterator("row",function(e,t){n._detailsDisplay(i.row(t),!0)})},_resize:function(n){for(var e,i=this,r=this.s.dt,t=m(v).innerWidth(),s=this.c.breakpoints,o=s[0].name,d=this.s.columns,a=this.s.current.slice(),l=s.length-1;0<=l;l--)if(t<=s[l].width){o=s[l].name;break}var c=this._columnsVisiblity(o),u=(this.s.current=c,!1);for(l=0,e=d.length;l<e;l++)if(!1===c[l]&&!d[l].never&&!d[l].control&&!1==!r.column(l).visible()){u=!0;break}m(r.table().node()).toggleClass("collapsed",u);var h=!1,p=0,f=r.settings()[0];r.columns().eq(0).each(function(e,t){r.column(e).visible()&&(!0===c[t]&&p++,!n&&c[t]===a[t]||(h=!0,i._setColumnVis(e,c[t])),c[t]||m(f.aoColumns[e].colEl).detach())}),h&&(this._redrawChildren(),m(r.table().node()).trigger("responsive-resize.dt",[r,this._responsiveOnlyHidden()]),0===r.page.info().recordsDisplay)&&m("td",r.table().body()).eq(0).attr("colspan",p),i._controlClass()},_resizeAuto:function(){var t=this.s.dt,n=this.s.columns,r=this,e=t.columns().indexes().filter(function(e){return t.column(e).visible()});if(this.c.auto&&-1!==m.inArray(!0,m.map(n,function(e){return e.auto}))){for(var i=t.table().node().cloneNode(!1),s=m(t.table().header().cloneNode(!1)).appendTo(i),o=m(t.table().footer().cloneNode(!1)).appendTo(i),d=m(t.table().body()).clone(!1,!1).empty().appendTo(i),a=(i.style.width="auto",t.table().header.structure(e).forEach(e=>{e=e.filter(function(e){return!!e}).map(function(e){return m(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});m("<tr/>").append(e).appendTo(s)}),m("<tr/>").appendTo(d)),l=0;l<e.count();l++)a.append("<td/>");t.rows({page:"current"}).every(function(n){var i,e=this.node();e&&(i=e.cloneNode(!1),t.cells(n,"*").every(function(e,t){t=r.s.childNodeStore[n+"-"+t];(t?m(this.node().cloneNode(!1)).append(m(t).clone()):m(this.node()).clone(!1)).appendTo(i)}),d.append(i))}),d.find("th, td").css("display",""),t.table().footer.structure(e).forEach(e=>{e=e.filter(function(e){return!!e}).map(function(e){return m(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});m("<tr/>").append(e).appendTo(o)}),"inline"===this.c.details.type&&m(i).addClass("dtr-inline collapsed"),m(i).find("[name]").removeAttr("name"),m(i).css("position","relative");i=m("<div/>").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(i);i.insertBefore(t.table().node()),a.children().each(function(e){e=t.column.index("fromVisible",e);n[e].minWidth=this.offsetWidth||0}),i.remove()}},_responsiveOnlyHidden:function(){var n=this.s.dt;return m.map(this.s.current,function(e,t){return!1===n.column(t).visible()||e})},_setColumnVis:function(e,t){var n=this,i=this.s.dt,r=t?"":"none";this._setHeaderVis(e,t,i.table().header.structure()),this._setHeaderVis(e,t,i.table().footer.structure()),i.column(e).nodes().to$().css("display",r).toggleClass("dtr-hidden",!t),m.isEmptyObject(this.s.childNodeStore)||i.cells(null,e).indexes().each(function(e){n._childNodesRestore(i,e.row,e.column)})},_setHeaderVis:function(n,i,e){var r=this,s=i?"":"none";e.forEach(function(e){if(e[n])m(e[n].cell).css("display",s).toggleClass("dtr-hidden",!i);else for(var t=n;0<=t;){if(e[t]){e[t].cell.colSpan=r._colspan(e,t);break}t--}})},_colspan:function(e,t){for(var n=1,i=t+1;i<e.length;i++)if(null===e[i]&&this.s.current[i])n++;else if(e[i])break;return n},_tabIndexes:function(){var e=this.s.dt,t=e.cells({page:"current"}).nodes().to$(),n=e.settings()[0],i=this.c.details.target;t.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]"),("number"==typeof i?e.cells(null,i,{page:"current"}).nodes().to$():m(i="td:first-child, th:first-child"===i?">td:first-child, >th:first-child":i,e.rows({page:"current"}).nodes())).attr("tabIndex",n.iTabIndex).data("dtr-keyboard",1)}}),a.defaults={breakpoints:a.breakpoints=[{name:"desktop",width:1/0},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}],auto:!0,details:{display:(a.display={childRow:function(e,t,n){var i=m(e.node());return t?i.hasClass("dtr-expanded")?(e.child(n(),"child").show(),!0):void 0:i.hasClass("dtr-expanded")?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},childRowImmediate:function(e,t,n){var i=m(e.node());return!t&&i.hasClass("dtr-expanded")||!e.responsive.hasHidden()?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},modal:function(o){return function(e,t,n,i){n=n();if(!1===n)return!1;if(t){if(!(s=m("div.dtr-modal-content")).length||e.index()!==s.data("dtr-row-idx"))return null;s.empty().append(n)}else{var r=function(){s.remove(),m(d).off("keypress.dtr"),m(e.node()).removeClass("dtr-expanded"),i()},s=m('<div class="dtr-modal"/>').append(m('<div class="dtr-modal-display"/>').append(m('<div class="dtr-modal-content"/>').data("dtr-row-idx",e.index()).append(n)).append(m('<div class="dtr-modal-close">×</div>').click(function(){r()}))).append(m('<div class="dtr-modal-background"/>').click(function(){r()})).appendTo("body");m(e.node()).addClass("dtr-expanded"),m(d).on("keyup.dtr",function(e){27===e.keyCode&&(e.stopPropagation(),r())})}return o&&o.header&&m("div.dtr-modal-content").prepend("<h2>"+o.header(e)+"</h2>"),!0}}}).childRow,renderer:(a.renderer={listHiddenNodes:function(){return function(i,e,t){var r=this,s=m('<ul data-dtr-index="'+e+'" class="dtr-details"/>'),o=!1;return m.each(t,function(e,t){var n;t.hidden&&(n=t.className?'class="'+t.className+'"':"",m("<li "+n+' data-dtr-index="'+t.columnIndex+'" data-dt-row="'+t.rowIndex+'" data-dt-column="'+t.columnIndex+'"><span class="dtr-title">'+t.title+"</span> </li>").append(m('<span class="dtr-data"/>').append(r._childNodes(i,t.rowIndex,t.columnIndex))).appendTo(s),o=!0)}),!!o&&s}},listHidden:function(){return function(e,t,n){n=m.map(n,function(e){var t=e.className?'class="'+e.className+'"':"";return e.hidden?"<li "+t+' data-dtr-index="'+e.columnIndex+'" data-dt-row="'+e.rowIndex+'" data-dt-column="'+e.columnIndex+'"><span class="dtr-title">'+e.title+'</span> <span class="dtr-data">'+e.data+"</span></li>":""}).join("");return!!n&&m('<ul data-dtr-index="'+t+'" class="dtr-details"/>').append(n)}},tableAll:function(i){return i=m.extend({tableClass:""},i),function(e,t,n){n=m.map(n,function(e){return"<tr "+(e.className?'class="'+e.className+'"':"")+' data-dt-row="'+e.rowIndex+'" data-dt-column="'+e.columnIndex+'"><td>'+e.title+":</td> <td>"+e.data+"</td></tr>"}).join("");return m('<table class="'+i.tableClass+' dtr-details" width="100%"/>').append(n)}}}).listHidden(),target:0,type:"inline"},orthogonal:"display"},m.fn.dataTable.Api);return e.register("responsive()",function(){return this}),e.register("responsive.index()",function(e){return{column:(e=m(e)).data("dtr-index"),row:e.parent().data("dtr-index")}}),e.register("responsive.rebuild()",function(){return this.iterator("table",function(e){e._responsive&&e._responsive._classLogic()})}),e.register("responsive.recalc()",function(){return this.iterator("table",function(e){e._responsive&&(e._responsive._resizeAuto(),e._responsive._resize())})}),e.register("responsive.hasHidden()",function(){var e=this.context[0];return!!e._responsive&&-1!==m.inArray(!1,e._responsive._responsiveOnlyHidden())}),e.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(e,t){return!!e._responsive&&e._responsive._responsiveOnlyHidden()[t]},1)}),a.version="3.0.0",m.fn.dataTable.Responsive=a,m.fn.DataTable.Responsive=a,m(d).on("preInit.dt.dtr",function(e,t,n){"dt"===e.namespace&&(m(t.nTable).hasClass("responsive")||m(t.nTable).hasClass("dt-responsive")||t.oInit.responsive||i.defaults.responsive)&&!1!==(e=t.oInit.responsive)&&new a(t,m.isPlainObject(e)?e:{})}),i}); |
@@ -7,3 +7,3 @@ { | ||
"types": "./types/types.d.ts", | ||
"version": "2.5.0", | ||
"version": "3.0.0", | ||
"files": [ | ||
@@ -23,3 +23,3 @@ "js/**/*.js", | ||
"dependencies": { | ||
"datatables.net": ">=1.13.4", | ||
"datatables.net": ">=2.0.0", | ||
"jquery": ">=1.7" | ||
@@ -26,0 +26,0 @@ }, |
@@ -9,3 +9,3 @@ // Type definitions for DataTables Responsive | ||
import DataTables, {Api} from 'datatables.net'; | ||
import DataTables, {Api, ApiRow} from 'datatables.net'; | ||
@@ -42,3 +42,3 @@ export default DataTables; | ||
interface ApiColumnMethods { | ||
interface ApiColumnMethods<T> { | ||
/** | ||
@@ -50,3 +50,3 @@ * Get the responsive visibility state of a column in the table | ||
interface ApiColumnsMethods { | ||
interface ApiColumnsMethods<T> { | ||
/** | ||
@@ -58,3 +58,3 @@ * Get the responsive visibility state of columns in the table | ||
interface ApiStatic { | ||
interface DataTablesStatic { | ||
/** | ||
@@ -67,3 +67,3 @@ * Responsive class | ||
*/ | ||
new (dt: Api<any>, settings: boolean | ConfigResponsive); | ||
new (dt: Api<any>, settings: boolean | ConfigResponsive): DataTablesStatic['Responsive']; | ||
@@ -140,3 +140,3 @@ /** | ||
*/ | ||
index(li): object; | ||
index(li: HTMLElement): object; | ||
@@ -168,3 +168,3 @@ /** | ||
*/ | ||
display?(row, update, render): boolean; | ||
display?(row: ApiRow<any>, update: boolean, render: () => string): boolean; | ||
@@ -176,6 +176,6 @@ /** | ||
* @param rowIdx Row index for the row that the renderer is being asked to render. Use the row() and / or cells() methods to get information from the API about the row so the information can be rendered. | ||
* @param columns Since 2.0.0: An array of objects containing information about each column in the DataTable. The array length is exactly equal to the number of columns in the DataTable, with each column represented by a DataTable in index order. Additionally, the structure of each object in the array is: | ||
* @param columns Since 2.0.0: An array of objects containing information about each column in the DataTable. The array length is exactly equal to the number of columns in the DataTable, with each column represented by a DataTable in index order. | ||
* @returns boolean | string `false` - Do not display a child row. Or a string - The information to be shown in the details display, including any required HTML. | ||
*/ | ||
renderer?(api, rowIdx, columns): Node | false; | ||
renderer?(api: Api, rowIdx: number, columns: ResponsiveColumn): Node | false; | ||
@@ -182,0 +182,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131669
3288
Updateddatatables.net@>=2.0.0