datatables.net-responsive
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -1,3 +0,3 @@ | ||
/*! Responsive 2.1.1 | ||
* 2014-2016 SpryMedia Ltd - datatables.net/license | ||
/*! Responsive 2.2.0 | ||
* 2014-2017 SpryMedia Ltd - datatables.net/license | ||
*/ | ||
@@ -8,7 +8,7 @@ | ||
* @description Responsive tables plug-in for DataTables | ||
* @version 2.1.1 | ||
* @version 2.2.0 | ||
* @file dataTables.responsive.js | ||
* @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
* @contact www.sprymedia.co.uk/contact | ||
* @copyright Copyright 2014-2016 SpryMedia Ltd. | ||
* @copyright Copyright 2014-2017 SpryMedia Ltd. | ||
* | ||
@@ -779,2 +779,7 @@ * This source file is free software, available under the following license: | ||
$(dt.table().node()).trigger( 'responsive-resize.dt', [dt, this.s.current] ); | ||
// If no records, update the "No records" display element | ||
if ( dt.page.info().recordsDisplay === 0 ) { | ||
dt.draw(); | ||
} | ||
} | ||
@@ -808,2 +813,11 @@ }, | ||
// Need to restore all children. They will be reinstated by a re-render | ||
if ( ! $.isEmptyObject( _childNodeStore ) ) { | ||
$.each( _childNodeStore, function ( key ) { | ||
var idx = key.split('-'); | ||
_childNodesRestore( dt, idx[0]*1, idx[1]*1 ); | ||
} ); | ||
} | ||
// Clone the table with the current data in it | ||
@@ -870,3 +884,4 @@ var tableWidth = dt.table().node().offsetWidth; | ||
height: 1, | ||
overflow: 'hidden' | ||
overflow: 'hidden', | ||
clear: 'both' | ||
} ) | ||
@@ -906,2 +921,9 @@ .append( clonedTable ); | ||
dt.column( col ).nodes().to$().css( 'display', display ); | ||
// If the are child nodes stored, we might need to reinsert them | ||
if ( ! $.isEmptyObject( _childNodeStore ) ) { | ||
dt.cells( null, col ).indexes().each( function (idx) { | ||
_childNodesRestore( dt, idx.row, idx.column ); | ||
} ); | ||
} | ||
}, | ||
@@ -1068,2 +1090,48 @@ | ||
var _childNodeStore = {}; | ||
function _childNodes( dt, row, col ) { | ||
var name = row+'-'+col; | ||
if ( _childNodeStore[ name ] ) { | ||
return _childNodeStore[ name ]; | ||
} | ||
// https://jsperf.com/childnodes-array-slice-vs-loop | ||
var nodes = []; | ||
var children = dt.cell( row, col ).node().childNodes; | ||
for ( var i=0, ien=children.length ; i<ien ; i++ ) { | ||
nodes.push( children[i] ); | ||
} | ||
_childNodeStore[ name ] = nodes; | ||
return nodes; | ||
} | ||
function _childNodesRestore( dt, row, col ) { | ||
var name = row+'-'+col; | ||
if ( ! _childNodeStore[ name ] ) { | ||
return; | ||
} | ||
var node = dt.cell( row, col ).node(); | ||
var store = _childNodeStore[ name ]; | ||
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 j=0, jen=a.length ; j<jen ; j++ ) { | ||
node.appendChild( a[j] ); | ||
} | ||
_childNodeStore[ name ] = undefined; | ||
} | ||
/** | ||
@@ -1078,2 +1146,29 @@ * Display methods - functions which define how the hidden data should be shown | ||
Responsive.renderer = { | ||
listHiddenNodes: function () { | ||
return function ( api, rowIdx, columns ) { | ||
var ul = $('<ul data-dtr-index="'+rowIdx+'" class="dtr-details"/>'); | ||
var found = false; | ||
var data = $.each( columns, function ( i, col ) { | ||
if ( col.hidden ) { | ||
$( | ||
'<li data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+ | ||
'<span class="dtr-title">'+ | ||
col.title+ | ||
'</span> '+ | ||
'</li>' | ||
) | ||
.append( $('<span class="dtr-data"/>').append( _childNodes( api, col.rowIndex, col.columnIndex ) ) )// api.cell( col.rowIndex, col.columnIndex ).node().childNodes ) ) | ||
.appendTo( ul ); | ||
found = true; | ||
} | ||
} ); | ||
return found ? | ||
ul : | ||
false; | ||
}; | ||
}, | ||
listHidden: function () { | ||
@@ -1234,3 +1329,3 @@ return function ( api, rowIdx, columns ) { | ||
*/ | ||
Responsive.version = '2.1.1'; | ||
Responsive.version = '2.2.0'; | ||
@@ -1237,0 +1332,0 @@ |
{ | ||
"name": "datatables.net-responsive", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Responsive for DataTables ", | ||
"files": [ | ||
"js/dataTables.responsive.js" | ||
"js/**/*.js" | ||
], | ||
@@ -25,3 +25,3 @@ "main": "./js/dataTables.responsive.js", | ||
"jquery": ">=1.7", | ||
"datatables.net": ">=1.10.9" | ||
"datatables.net": "^1.10.15" | ||
}, | ||
@@ -28,0 +28,0 @@ "repository": { |
# Responsive for DataTables | ||
This package contains distribution files for the [Responsive extension](https://datatables.net/extensions/responsive) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for Responsive must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getboostrap.com) and [Foundation](http://foundation.zurb.com/). | ||
This package contains distribution files for the [Responsive extension](https://datatables.net/extensions/responsive) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for Responsive must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getbootstrap.com) and [Foundation](http://foundation.zurb.com/). | ||
@@ -5,0 +5,0 @@ In the modern world of responsive web design tables can often cause a particular problem for designers due to their row based layout. Responsive is an extension for DataTables that resolves that problem by optimising the table's layout for different screen sizes through the dynamic insertion and removal of columns from the table. |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
52975
4
1215
1
+ Addeddatatables.net@1.13.11(transitive)
- Removeddatatables.net@2.1.7(transitive)
Updateddatatables.net@^1.10.15