app/assets/javascripts/dataTables/extras/dataTables.fixedColumns.js in jquery-datatables-rails-2.2.1 vs app/assets/javascripts/dataTables/extras/dataTables.fixedColumns.js in jquery-datatables-rails-2.2.2
- old
+ new
@@ -1,13 +1,13 @@
-/*! FixedColumns 3.0.1
+/*! FixedColumns 3.0.2
* ©2010-2014 SpryMedia Ltd - datatables.net/license
*/
/**
* @summary FixedColumns
* @description Freeze columns in place on a scrolling DataTable
- * @version 3.0.1
+ * @version 3.0.2
* @file dataTables.fixedColumns.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
* @copyright Copyright 2010-2014 SpryMedia Ltd.
*
@@ -481,10 +481,14 @@
that.dom.grid.right.liner.scrollTop = that.dom.scroller.scrollTop;
}
}
} );
+ var wheelType = 'onwheel' in document.createElement('div') ?
+ 'wheel.DTFC' :
+ 'mousewheel.DTFC';
+
if ( that.s.iLeftColumns > 0 ) {
// When scrolling the left column, scroll the body and right column
$(that.dom.grid.left.liner)
.on( 'mouseover.DTFC touchstart.DTFC', function () {
mouseController = 'left';
@@ -495,13 +499,15 @@
if ( that.s.iRightColumns > 0 ) {
that.dom.grid.right.liner.scrollTop = that.dom.grid.left.liner.scrollTop;
}
}
} )
- .on( "wheel.DTFC", function(e) {
+ .on( wheelType, function(e) { // xxx update the destroy as well
// Pass horizontal scrolling through
- var xDelta = -e.originalEvent.deltaX;
+ var xDelta = e.type === 'wheel' ?
+ -e.originalEvent.deltaX :
+ e.originalEvent.wheelDeltaX;
that.dom.scroller.scrollLeft -= xDelta;
} );
}
if ( that.s.iRightColumns > 0 ) {
@@ -516,13 +522,15 @@
if ( that.s.iLeftColumns > 0 ) {
that.dom.grid.left.liner.scrollTop = that.dom.grid.right.liner.scrollTop;
}
}
} )
- .on( "wheel.DTFC", function(e) {
+ .on( wheelType, function(e) {
// Pass horizontal scrolling through
- var xDelta = -e.originalEvent.deltaX;
+ var xDelta = e.type === 'wheel' ?
+ -e.originalEvent.deltaX :
+ e.originalEvent.wheelDeltaX;
that.dom.scroller.scrollLeft -= xDelta;
} );
}
$(window).on( 'resize.DTFC', function () {
@@ -550,14 +558,14 @@
jqTable.off( 'column-sizing.dt.DTFC destroy.dt.DTFC draw.dt.DTFC' );
$(that.dom.scroller).off( 'scroll.DTFC mouseover.DTFC' );
$(window).off( 'resize.DTFC' );
- $(that.dom.grid.left.liner).off( 'scroll.DTFC wheel.DTFC mouseover.DTFC' );
+ $(that.dom.grid.left.liner).off( 'scroll.DTFC mouseover.DTFC '+wheelType );
$(that.dom.grid.left.wrapper).remove();
- $(that.dom.grid.right.liner).off( 'scroll.DTFC wheel.DTFC mouseover.DTFC' );
+ $(that.dom.grid.right.liner).off( 'scroll.DTFC mouseover.DTFC '+wheelType );
$(that.dom.grid.right.wrapper).remove();
} );
/* Get things right to start with - note that due to adjusting the columns, there must be
* another redraw of the main table. It doesn't need to be a full redraw however.
@@ -581,10 +589,11 @@
this.s.aiInnerWidths = [];
this.s.aiOuterWidths = [];
$.each( this.s.dt.aoColumns, function (i, col) {
var th = $(col.nTh);
+ var border;
if ( ! th.filter(':visible').length ) {
that.s.aiInnerWidths.push( 0 );
that.s.aiOuterWidths.push( 0 );
}
@@ -596,14 +605,20 @@
// When working with the left most-cell, need to add on the
// table's border to the outerWidth, since we need to take
// account of it, but it isn't in any cell
if ( that.s.aiOuterWidths.length === 0 ) {
- var border = $(that.s.dt.nTable).css('border-left-width');
+ border = $(that.s.dt.nTable).css('border-left-width');
iWidth += typeof border === 'string' ? 1 : parseInt( border, 10 );
}
+ // Likewise with the final column on the right
+ if ( that.s.aiOuterWidths.length === that.s.dt.aoColumns.length-1 ) {
+ border = $(that.s.dt.nTable).css('border-right-width');
+ iWidth += typeof border === 'string' ? 1 : parseInt( border, 10 );
+ }
+
that.s.aiOuterWidths.push( iWidth );
that.s.aiInnerWidths.push( th.width() );
if ( i < that.s.iLeftColumns )
{
@@ -722,12 +737,12 @@
*/
"_fnGridLayout": function ()
{
var oGrid = this.dom.grid;
var iWidth = $(oGrid.wrapper).width();
- var iBodyHeight = $(this.s.dt.nTable.parentNode).height();
- var iFullHeight = $(this.s.dt.nTable.parentNode.parentNode).height();
+ var iBodyHeight = $(this.s.dt.nTable.parentNode).outerHeight();
+ var iFullHeight = $(this.s.dt.nTable.parentNode.parentNode).outerHeight();
var oOverflow = this._fnDTOverflow();
var
iLeftWidth = this.s.iLeftWidth,
iRightWidth = this.s.iRightWidth,
iRight;
@@ -1335,11 +1350,11 @@
* @name FixedColumns.version
* @type String
* @default See code
* @static
*/
-FixedColumns.version = "3.0.1";
+FixedColumns.version = "3.0.2";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Fired events (for documentation)
@@ -1366,10 +1381,14 @@
}; // /factory
// Define as an AMD module if possible
if ( typeof define === 'function' && define.amd ) {
- define( 'datatables-fixedcolumns', ['jquery', 'datatables'], factory );
+ define( ['jquery', 'datatables'], factory );
+}
+else if ( typeof exports === 'object' ) {
+ // Node/CommonJS
+ factory( require('jquery'), require('datatables') );
}
else if ( jQuery && !jQuery.fn.dataTable.FixedColumns ) {
// Otherwise simply initialise as normal, stopping multiple evaluation
factory( jQuery, jQuery.fn.dataTable );
}