vendor/assets/javascripts/dataTables.responsive.js in bootswatch_rails-3.3.6.2 vs vendor/assets/javascripts/dataTables.responsive.js in bootswatch_rails-3.3.7.0

- old
+ new

@@ -1,13 +1,13 @@ -/*! Responsive 2.0.2 +/*! Responsive 2.1.0 * 2014-2016 SpryMedia Ltd - datatables.net/license */ /** * @summary Responsive * @description Responsive tables plug-in for DataTables - * @version 2.0.2 + * @version 2.1.0 * @file dataTables.responsive.js * @author SpryMedia Ltd (www.sprymedia.co.uk) * @contact www.sprymedia.co.uk/contact * @copyright Copyright 2014-2016 SpryMedia Ltd. * @@ -230,10 +230,11 @@ that._resize(); } ); // Change in column sizes means we need to calc dt.on( 'column-sizing.dtr', function () { + that._resizeAuto(); that._resize(); }); dt.on( 'init.dtr', function (e, settings, details) { that._resizeAuto(); @@ -539,11 +540,11 @@ { var that = this; var dt = this.s.dt; var details = this.c.details; - if ( details && details.type ) { + if ( details && details.type !== false ) { var res = details.display( row, update, function () { return details.renderer( dt, row[0], that._detailsObj(row[0]) ); } ); @@ -644,11 +645,12 @@ { var that = this; var dt = this.s.dt; return $.map( this.s.columns, function( col, i ) { - if ( col.never ) { + // Never and control columns should not be passed to the renderer + if ( col.never || col.control ) { return; } return { title: dt.settings()[0].aoColumns[ i ].sTitle, @@ -810,11 +812,11 @@ // Footer var footer = dt.table().footer(); if ( footer ) { var clonedFooter = $( footer.cloneNode( false ) ).appendTo( clonedTable ); var footerCells = dt.columns() - .header() + .footer() .filter( function (idx) { return dt.column(idx).visible(); } ) .to$() .clone( false ) @@ -833,11 +835,16 @@ // give space for the show / hide icon. We need to use this in the // calculation if ( this.c.details.type === 'inline' ) { $(clonedTable).addClass( 'dtr-inline collapsed' ); } - + + // It is unsafe to insert elements with the same name into the DOM + // multiple times. For example, cloning and inserting a checked radio + // clears the chcecked state of the original radio. + $( clonedTable ).find( '[name]' ).removeAttr( 'name' ); + var inserted = $('<div/>') .css( { width: 1, height: 1, overflow: 'hidden' @@ -1029,10 +1036,58 @@ } }; /** + * Display methods - functions which define how the hidden data should be shown + * in the table. + * + * @namespace + * @name Responsive.defaults + * @static + */ +Responsive.renderer = { + listHidden: function () { + return function ( api, rowIdx, columns ) { + var data = $.map( columns, function ( col ) { + return 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> '+ + '<span class="dtr-data">'+ + col.data+ + '</span>'+ + '</li>' : + ''; + } ).join(''); + + return data ? + $('<ul data-dtr-index="'+rowIdx+'"/>').append( data ) : + false; + } + }, + + tableAll: function ( options ) { + options = $.extend( { + tableClass: '' + }, options ); + + return function ( api, rowIdx, columns ) { + var data = $.map( columns, function ( col ) { + return '<tr data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+ + '<td>'+col.title+':'+'</td> '+ + '<td>'+col.data+'</td>'+ + '</tr>'; + } ).join(''); + + return $('<table class="'+options.tableClass+'" width="100%"/>').append( data ); + } + } +}; + +/** * Responsive default settings for initialisation * * @namespace * @name Responsive.defaults * @static @@ -1076,29 +1131,12 @@ * @type {Object|string} */ details: { display: Responsive.display.childRow, - renderer: function ( api, rowIdx, columns ) { - var data = $.map( columns, function ( col, i ) { - return 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> '+ - '<span class="dtr-data">'+ - col.data+ - '</span>'+ - '</li>' : - ''; - } ).join(''); + renderer: Responsive.renderer.listHidden(), - return data ? - $('<ul data-dtr-index="'+rowIdx+'"/>').append( data ) : - false; - }, - target: 0, type: 'inline' }, @@ -1161,10 +1199,10 @@ * Version information * * @name Responsive.version * @static */ -Responsive.version = '2.0.2'; +Responsive.version = '2.1.0'; $.fn.dataTable.Responsive = Responsive; $.fn.DataTable.Responsive = Responsive;