app/assets/javascripts/datatables/extensions/Responsive/dataTables.responsive.js in jquery-datatables-1.10.12 vs app/assets/javascripts/datatables/extensions/Responsive/dataTables.responsive.js in jquery-datatables-1.10.13
- old
+ new
@@ -1,13 +1,13 @@
-/*! Responsive 2.1.0
+/*! Responsive 2.1.1
* 2014-2016 SpryMedia Ltd - datatables.net/license
*/
/**
* @summary Responsive
* @description Responsive tables plug-in for DataTables
- * @version 2.1.0
+ * @version 2.1.1
* @file dataTables.responsive.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
* @copyright Copyright 2014-2016 SpryMedia Ltd.
*
@@ -164,11 +164,11 @@
// 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 ) {
+ $('>td, >th', tr).each( function ( i ) {
var idx = dt.column.index( 'toData', i );
if ( that.s.current[idx] === false ) {
$(this).css('display', 'none');
}
@@ -234,10 +234,27 @@
dt.on( 'column-sizing.dtr', function () {
that._resizeAuto();
that._resize();
});
+ // On Ajax reload we want to reopen any child rows which are displayed
+ // by responsive
+ dt.on( 'preXhr.dtr', function () {
+ var rowIds = [];
+ dt.rows().every( function () {
+ if ( this.child.isShown() ) {
+ rowIds.push( this.id(true) );
+ }
+ } );
+
+ dt.one( 'draw.dtr', function () {
+ dt.rows( rowIds ).every( function () {
+ that._detailsDisplay( this, false );
+ } );
+ } );
+ });
+
dt.on( 'init.dtr', function (e, settings, details) {
that._resizeAuto();
that._resize();
// If columns were hidden, then DataTables needs to adjust the
@@ -596,11 +613,11 @@
if ( ! $(dt.table().node()).hasClass('collapsed' ) ) {
return;
}
// Check that the row is actually a DataTable's controlled node
- if ( ! dt.row( $(this).closest('tr') ).length ) {
+ 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
@@ -905,10 +922,16 @@
var selector = typeof target === 'number' ?
':eq('+target+')' :
target;
+ // This is a bit of a hack - we need to limit the selected nodes to just
+ // those of this table
+ if ( selector === 'td:first-child, th:first-child' ) {
+ selector = '>td:first-child, >th:first-child';
+ }
+
$( selector, dt.rows( { page: 'current' } ).nodes() )
.attr( 'tabIndex', ctx.iTabIndex )
.data( 'dtr-keyboard', 1 );
}
} );
@@ -1060,11 +1083,11 @@
'</li>' :
'';
} ).join('');
return data ?
- $('<ul data-dtr-index="'+rowIdx+'"/>').append( data ) :
+ $('<ul data-dtr-index="'+rowIdx+'" class="dtr-details"/>').append( data ) :
false;
}
},
tableAll: function ( options ) {
@@ -1078,11 +1101,11 @@
'<td>'+col.title+':'+'</td> '+
'<td>'+col.data+'</td>'+
'</tr>';
} ).join('');
- return $('<table class="'+options.tableClass+'" width="100%"/>').append( data );
+ return $('<table class="'+options.tableClass+' dtr-details" width="100%"/>').append( data );
}
}
};
/**
@@ -1199,10 +1222,10 @@
* Version information
*
* @name Responsive.version
* @static
*/
-Responsive.version = '2.1.0';
+Responsive.version = '2.1.1';
$.fn.dataTable.Responsive = Responsive;
$.fn.DataTable.Responsive = Responsive;