datatables.net-responsive
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -1,2 +0,2 @@ | ||
/*! Responsive 2.0.0 | ||
/*! Responsive 2.0.1 | ||
* 2014-2015 SpryMedia Ltd - datatables.net/license | ||
@@ -8,3 +8,3 @@ */ | ||
* @description Responsive tables plug-in for DataTables | ||
* @version 2.0.0 | ||
* @version 2.0.1 | ||
* @file dataTables.responsive.js | ||
@@ -141,2 +141,3 @@ * @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
var dtPrivateSettings = dt.settings()[0]; | ||
var oldWindowWidth = $(window).width(); | ||
@@ -148,3 +149,10 @@ dt.settings()[0]._responsive = this; | ||
$(window).on( 'resize.dtr orientationchange.dtr', DataTable.util.throttle( function () { | ||
that._resize(); | ||
// iOS has a bug whereby resize can fire when only scrolling | ||
// See: http://stackoverflow.com/questions/8898412 | ||
var width = $(window).width(); | ||
if ( width !== oldWindowWidth ) { | ||
that._resize(); | ||
oldWindowWidth = width; | ||
} | ||
} ) ); | ||
@@ -193,2 +201,3 @@ | ||
var details = this.c.details; | ||
if ( details.type !== false ) { | ||
@@ -224,2 +233,18 @@ that._detailsInit(); | ||
// Change in column sizes means we need to calc | ||
dt.on( 'column-sizing.dtr', function () { | ||
that._resize(); | ||
}); | ||
dt.on( 'init.dtr', function (e, settings, details) { | ||
that._resizeAuto(); | ||
that._resize(); | ||
// If columns were hidden, then DataTables needs to adjust the | ||
// column sizing | ||
if ( $.inArray( false, that.s.current ) ) { | ||
dt.columns.adjust(); | ||
} | ||
} ); | ||
// First pass - draw the table for the current viewport size | ||
@@ -383,4 +408,6 @@ this._resize(); | ||
if ( priority === undefined ) { | ||
priority = $(column.header).data('priority') !== undefined ? | ||
$(column.header).data('priority') * 1 : | ||
var dataPriority = $(column.header()).data('priority'); | ||
priority = dataPriority !== undefined ? | ||
dataPriority * 1 : | ||
10000; | ||
@@ -518,11 +545,14 @@ } | ||
var dt = this.s.dt; | ||
var details = this.c.details; | ||
var res = this.c.details.display( row, update, function () { | ||
return that.c.details.renderer( | ||
dt, row[0], that._detailsObj(row[0]) | ||
); | ||
} ); | ||
if ( details && details.type ) { | ||
var res = details.display( row, update, function () { | ||
return details.renderer( | ||
dt, row[0], that._detailsObj(row[0]) | ||
); | ||
} ); | ||
if ( res === true || res === false ) { | ||
$(dt.table().node()).triggerHandler( 'responsive-display.dt', [dt, row, res, update] ); | ||
if ( res === true || res === false ) { | ||
$(dt.table().node()).triggerHandler( 'responsive-display.dt', [dt, row, res, update] ); | ||
} | ||
} | ||
@@ -545,3 +575,3 @@ }, | ||
if ( details.type === 'inline' ) { | ||
details.target = 'td:first-child'; | ||
details.target = 'td:first-child, th:first-child'; | ||
} | ||
@@ -555,3 +585,3 @@ | ||
$( dt.table().body() ).on( 'keyup.dtr', 'td', function (e) { | ||
$( dt.table().body() ).on( 'keyup.dtr', 'td, th', function (e) { | ||
if ( e.keyCode === 13 && $(this).data('dtr-keyboard') ) { | ||
@@ -564,11 +594,7 @@ $(this).click(); | ||
var target = details.target; | ||
var selector = typeof target === 'string' ? target : 'td'; | ||
var selector = typeof target === 'string' ? target : 'td, th'; | ||
// Click handler to show / hide the details rows when they are available | ||
$( dt.table().body() ) | ||
.on( 'mousedown.dtr', selector, function (e) { | ||
// For mouse users, prevent the focus ring from showing | ||
e.preventDefault(); | ||
} ) | ||
.on( 'click.dtr', selector, function () { | ||
.on( 'click.dtr mousedown.dtr mouseup.dtr', selector, function (e) { | ||
// If the table is not collapsed (i.e. there is no hidden columns) | ||
@@ -600,6 +626,17 @@ // then take no action | ||
// 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).blur().css('outline', ''); | ||
} | ||
} ); | ||
@@ -625,5 +662,6 @@ }, | ||
return { | ||
title: dt.settings()[0].aoColumns[ i ].sTitle, | ||
data: dt.cell( rowIdx, i ).render( that.c.orthogonal ), | ||
hidden: dt.column( i ).visible() && !that.s.current[ i ] | ||
title: dt.settings()[0].aoColumns[ i ].sTitle, | ||
data: dt.cell( rowIdx, i ).render( that.c.orthogonal ), | ||
hidden: dt.column( i ).visible() && !that.s.current[ i ], | ||
columnIndex: i | ||
}; | ||
@@ -707,3 +745,3 @@ } ); | ||
for ( i=0, ien=columns.length ; i<ien ; i++ ) { | ||
if ( columnsVis[i] === false && ! columns[i].never ) { | ||
if ( columnsVis[i] === false && ! columns[i].never && ! columns[i].control ) { | ||
collapsedClass = true; | ||
@@ -727,2 +765,5 @@ break; | ||
this._redrawChildren(); | ||
// Inform listeners of the change | ||
$(dt.table().node()).trigger( 'responsive-resize.dt', [dt, this.s.current] ); | ||
} | ||
@@ -761,3 +802,3 @@ }, | ||
var clonedHeader = $( dt.table().header().cloneNode( false ) ).appendTo( clonedTable ); | ||
var clonedBody = $( dt.table().body().cloneNode( false ) ).appendTo( clonedTable ); | ||
var clonedBody = $( dt.table().body() ).clone( false, false ).empty().appendTo( clonedTable ); // use jQuery because of IE8 | ||
@@ -979,8 +1020,2 @@ // Header | ||
if ( options && options.header ) { | ||
modal.find( 'div.dtr-modal-content' ).prepend( | ||
'<h2>'+options.header( row )+'</h2>' | ||
); | ||
} | ||
$(document).on( 'keyup.dtr', function (e) { | ||
@@ -999,2 +1034,8 @@ if ( e.keyCode === 27 ) { | ||
} | ||
if ( options && options.header ) { | ||
$('div.dtr-modal-content').prepend( | ||
'<h2>'+options.header( row )+'</h2>' | ||
); | ||
} | ||
}; | ||
@@ -1056,3 +1097,3 @@ } | ||
return col.hidden ? | ||
'<li data-dtr-index="'+i+'">'+ | ||
'<li data-dtr-index="'+col.columnIndex+'">'+ | ||
'<span class="dtr-title">'+ | ||
@@ -1139,3 +1180,3 @@ col.title+ | ||
*/ | ||
Responsive.version = '2.0.0'; | ||
Responsive.version = '2.0.1'; | ||
@@ -1148,3 +1189,3 @@ | ||
// events so we can automatically initialise | ||
$(document).on( 'init.dt.dtr', function (e, settings, json) { | ||
$(document).on( 'preInit.dt.dtr', function (e, settings, json) { | ||
if ( e.namespace !== 'dt' ) { | ||
@@ -1151,0 +1192,0 @@ return; |
{ | ||
"name": "datatables.net-responsive", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Responsive for DataTables ", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
36134
1023
100679