mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-10 19:41:26 +01:00
Last version of JQuery 1.12 and DataTables Componenent with working
export Excel,CVS,PDF, etc..
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/*! FixedColumns 3.0.4
|
||||
* ©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
/*! FixedColumns 3.2.1
|
||||
* ©2010-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary FixedColumns
|
||||
* @description Freeze columns in place on a scrolling DataTable
|
||||
* @version 3.0.4
|
||||
* @version 3.2.1
|
||||
* @file dataTables.fixedColumns.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
* @copyright Copyright 2010-2014 SpryMedia Ltd.
|
||||
* @copyright Copyright 2010-2016 SpryMedia Ltd.
|
||||
*
|
||||
* This source file is free software, available under the following license:
|
||||
* MIT license - http://datatables.net/license/mit
|
||||
@@ -20,13 +20,35 @@
|
||||
*
|
||||
* For details please refer to: http://www.datatables.net
|
||||
*/
|
||||
(function( factory ){
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( ['jquery', 'datatables.net'], function ( $ ) {
|
||||
return factory( $, window, document );
|
||||
} );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// CommonJS
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
root = window;
|
||||
}
|
||||
|
||||
if ( ! $ || ! $.fn.dataTable ) {
|
||||
$ = require('datatables.net')(root, $).$;
|
||||
}
|
||||
|
||||
(function(window, document, undefined) {
|
||||
|
||||
|
||||
var factory = function( $, DataTable ) {
|
||||
"use strict";
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document, undefined ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
var _firefoxScroll;
|
||||
|
||||
/**
|
||||
* When making use of DataTables' x-axis scrolling feature, you may wish to
|
||||
@@ -62,14 +84,12 @@ var FixedColumns = function ( dt, init ) {
|
||||
var that = this;
|
||||
|
||||
/* Sanity check - you just know it will happen */
|
||||
if ( ! ( this instanceof FixedColumns ) )
|
||||
{
|
||||
if ( ! ( this instanceof FixedColumns ) ) {
|
||||
alert( "FixedColumns warning: FixedColumns must be initialised with the 'new' keyword." );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( typeof init == 'undefined' )
|
||||
{
|
||||
if ( init === undefined || init === true ) {
|
||||
init = {};
|
||||
}
|
||||
|
||||
@@ -82,9 +102,7 @@ var FixedColumns = function ( dt, init ) {
|
||||
}
|
||||
|
||||
// v1.10 allows the settings object to be got form a number of sources
|
||||
var dtSettings = $.fn.dataTable.Api ?
|
||||
new $.fn.dataTable.Api( dt ).settings()[0] :
|
||||
dt.fnSettings();
|
||||
var dtSettings = new $.fn.dataTable.Api( dt ).settings()[0];
|
||||
|
||||
/**
|
||||
* Settings object which contains customisable information for FixedColumns instance
|
||||
@@ -265,6 +283,10 @@ var FixedColumns = function ( dt, init ) {
|
||||
}
|
||||
};
|
||||
|
||||
if ( dtSettings._oFixedColumns ) {
|
||||
throw 'FixedColumns already initialised on this table';
|
||||
}
|
||||
|
||||
/* Attach the instance to the DataTables instance so it can be accessed easily */
|
||||
dtSettings._oFixedColumns = this;
|
||||
|
||||
@@ -283,7 +305,7 @@ var FixedColumns = function ( dt, init ) {
|
||||
|
||||
|
||||
|
||||
FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
$.extend( FixedColumns.prototype , {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
@@ -468,13 +490,30 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
/* Event handlers */
|
||||
var mouseController;
|
||||
var mouseDown = false;
|
||||
|
||||
// When the mouse is down (drag scroll) the mouse controller cannot
|
||||
// change, as the browser keeps the original element as the scrolling one
|
||||
$(this.s.dt.nTableWrapper).on( 'mousedown.DTFC', function () {
|
||||
mouseDown = true;
|
||||
|
||||
$(document).one( 'mouseup', function () {
|
||||
mouseDown = false;
|
||||
} );
|
||||
} );
|
||||
|
||||
// When the body is scrolled - scroll the left and right columns
|
||||
$(this.dom.scroller)
|
||||
.on( 'mouseover.DTFC touchstart.DTFC', function () {
|
||||
mouseController = 'main';
|
||||
if ( ! mouseDown ) {
|
||||
mouseController = 'main';
|
||||
}
|
||||
} )
|
||||
.on( 'scroll.DTFC', function () {
|
||||
.on( 'scroll.DTFC', function (e) {
|
||||
if ( ! mouseController && e.originalEvent ) {
|
||||
mouseController = 'main';
|
||||
}
|
||||
|
||||
if ( mouseController === 'main' ) {
|
||||
if ( that.s.iLeftColumns > 0 ) {
|
||||
that.dom.grid.left.liner.scrollTop = that.dom.scroller.scrollTop;
|
||||
@@ -493,9 +532,15 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
// When scrolling the left column, scroll the body and right column
|
||||
$(that.dom.grid.left.liner)
|
||||
.on( 'mouseover.DTFC touchstart.DTFC', function () {
|
||||
mouseController = 'left';
|
||||
if ( ! mouseDown ) {
|
||||
mouseController = 'left';
|
||||
}
|
||||
} )
|
||||
.on( 'scroll.DTFC', function () {
|
||||
.on( 'scroll.DTFC', function ( e ) {
|
||||
if ( ! mouseController && e.originalEvent ) {
|
||||
mouseController = 'left';
|
||||
}
|
||||
|
||||
if ( mouseController === 'left' ) {
|
||||
that.dom.scroller.scrollTop = that.dom.grid.left.liner.scrollTop;
|
||||
if ( that.s.iRightColumns > 0 ) {
|
||||
@@ -503,7 +548,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
}
|
||||
}
|
||||
} )
|
||||
.on( wheelType, function(e) { // xxx update the destroy as well
|
||||
.on( wheelType, function(e) {
|
||||
// Pass horizontal scrolling through
|
||||
var xDelta = e.type === 'wheel' ?
|
||||
-e.originalEvent.deltaX :
|
||||
@@ -516,9 +561,15 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
// When scrolling the right column, scroll the body and the left column
|
||||
$(that.dom.grid.right.liner)
|
||||
.on( 'mouseover.DTFC touchstart.DTFC', function () {
|
||||
mouseController = 'right';
|
||||
if ( ! mouseDown ) {
|
||||
mouseController = 'right';
|
||||
}
|
||||
} )
|
||||
.on( 'scroll.DTFC', function () {
|
||||
.on( 'scroll.DTFC', function ( e ) {
|
||||
if ( ! mouseController && e.originalEvent ) {
|
||||
mouseController = 'right';
|
||||
}
|
||||
|
||||
if ( mouseController === 'right' ) {
|
||||
that.dom.scroller.scrollTop = that.dom.grid.right.liner.scrollTop;
|
||||
if ( that.s.iLeftColumns > 0 ) {
|
||||
@@ -544,6 +595,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
jqTable
|
||||
.on( 'draw.dt.DTFC', function () {
|
||||
that._fnColCalc();
|
||||
that._fnDraw.call( that, bFirstDraw );
|
||||
bFirstDraw = false;
|
||||
} )
|
||||
@@ -551,21 +603,27 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
that._fnColCalc();
|
||||
that._fnGridLayout( that );
|
||||
} )
|
||||
.on( 'column-visibility.dt.DTFC', function () {
|
||||
that._fnColCalc();
|
||||
that._fnGridLayout( that );
|
||||
that._fnDraw( true );
|
||||
.on( 'column-visibility.dt.DTFC', function ( e, settings, column, vis, recalc ) {
|
||||
if ( recalc === undefined || recalc ) {
|
||||
that._fnColCalc();
|
||||
that._fnGridLayout( that );
|
||||
that._fnDraw( true );
|
||||
}
|
||||
} )
|
||||
.on( 'select.dt.DTFC deselect.dt.DTFC', function ( e, dt, type, indexes ) {
|
||||
that._fnDraw( false );
|
||||
} )
|
||||
.on( 'destroy.dt.DTFC', function () {
|
||||
jqTable.off( 'column-sizing.dt.DTFC destroy.dt.DTFC draw.dt.DTFC' );
|
||||
jqTable.off( '.DTFC' );
|
||||
|
||||
$(that.dom.scroller).off( 'scroll.DTFC mouseover.DTFC' );
|
||||
$(window).off( 'resize.DTFC' );
|
||||
$(that.dom.scroller).off( '.DTFC' );
|
||||
$(window).off( '.DTFC' );
|
||||
$(this.s.dt.nTableWrapper).off( '.DTFC' );
|
||||
|
||||
$(that.dom.grid.left.liner).off( 'scroll.DTFC mouseover.DTFC '+wheelType );
|
||||
$(that.dom.grid.left.liner).off( '.DTFC '+wheelType );
|
||||
$(that.dom.grid.left.wrapper).remove();
|
||||
|
||||
$(that.dom.grid.right.liner).off( 'scroll.DTFC mouseover.DTFC '+wheelType );
|
||||
$(that.dom.grid.right.liner).off( '.DTFC '+wheelType );
|
||||
$(that.dom.grid.right.wrapper).remove();
|
||||
} );
|
||||
|
||||
@@ -667,7 +725,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
'</div>'+
|
||||
'<div class="DTFC_LeftFootWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div>'+
|
||||
'</div>'+
|
||||
'<div class="DTFC_RightWrapper" style="position:absolute; top:0; left:0;">'+
|
||||
'<div class="DTFC_RightWrapper" style="position:absolute; top:0; right:0;">'+
|
||||
'<div class="DTFC_RightHeadWrapper" style="position:relative; top:0; left:0;">'+
|
||||
'<div class="DTFC_RightHeadBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div>'+
|
||||
'</div>'+
|
||||
@@ -704,6 +762,8 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
this.dom.grid.right.body = nRight.childNodes[1];
|
||||
this.dom.grid.right.liner = $('div.DTFC_RightBodyLiner', nSWrapper)[0];
|
||||
|
||||
nRight.style.right = oOverflow.bar+"px";
|
||||
|
||||
block = $('div.DTFC_RightHeadBlocker', nSWrapper)[0];
|
||||
block.style.width = oOverflow.bar+"px";
|
||||
block.style.right = -oOverflow.bar+"px";
|
||||
@@ -729,6 +789,24 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
this.dom.grid.right.foot = nRight.childNodes[2];
|
||||
}
|
||||
}
|
||||
|
||||
// RTL support - swap the position of the left and right columns (#48)
|
||||
if ( $(this.dom.body).css('direction') === 'rtl' ) {
|
||||
$(nLeft).css( {
|
||||
left: '',
|
||||
right: 0
|
||||
} );
|
||||
|
||||
$(nRight).css( {
|
||||
left: oOverflow.bar+"px",
|
||||
right: ''
|
||||
} );
|
||||
|
||||
$('div.DTFC_RightHeadBlocker', nSWrapper).css( {
|
||||
left: -oOverflow.bar+'px',
|
||||
right: ''
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -739,6 +817,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
*/
|
||||
"_fnGridLayout": function ()
|
||||
{
|
||||
var that = this;
|
||||
var oGrid = this.dom.grid;
|
||||
var iWidth = $(oGrid.wrapper).width();
|
||||
var iBodyHeight = $(this.s.dt.nTable.parentNode).outerHeight();
|
||||
@@ -755,6 +834,12 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
node.style.paddingRight = "20px";
|
||||
node.style.boxSizing = "border-box";
|
||||
}
|
||||
else if ( that._firefoxScrollError() ) {
|
||||
// See the above function for why this is required
|
||||
if ( $(node).height() > 34 ) {
|
||||
node.style.width = (width+oOverflow.bar)+"px";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Otherwise just overflow by the scrollbar
|
||||
node.style.width = (width+oOverflow.bar)+"px";
|
||||
@@ -791,7 +876,6 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
}
|
||||
|
||||
oGrid.right.wrapper.style.width = iRightWidth+"px";
|
||||
oGrid.right.wrapper.style.left = iRight+"px";
|
||||
oGrid.right.wrapper.style.height = "1px";
|
||||
oGrid.right.body.style.height = iBodyHeight+"px";
|
||||
if ( oGrid.right.foot ) {
|
||||
@@ -922,9 +1006,10 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
* @returns {Array} Copy of the layout array
|
||||
* @param {Object} aoOriginal Layout array from DataTables (aoHeader or aoFooter)
|
||||
* @param {Object} aiColumns Columns to copy
|
||||
* @param {boolean} events Copy cell events or not
|
||||
* @private
|
||||
*/
|
||||
"_fnCopyLayout": function ( aoOriginal, aiColumns )
|
||||
"_fnCopyLayout": function ( aoOriginal, aiColumns, events )
|
||||
{
|
||||
var aReturn = [];
|
||||
var aClones = [];
|
||||
@@ -933,7 +1018,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
for ( var i=0, iLen=aoOriginal.length ; i<iLen ; i++ )
|
||||
{
|
||||
var aRow = [];
|
||||
aRow.nTr = $(aoOriginal[i].nTr).clone(true, true)[0];
|
||||
aRow.nTr = $(aoOriginal[i].nTr).clone(events, false)[0];
|
||||
|
||||
for ( var j=0, jLen=this.s.iTableColumns ; j<jLen ; j++ )
|
||||
{
|
||||
@@ -945,7 +1030,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
var iCloned = $.inArray( aoOriginal[i][j].cell, aCloned );
|
||||
if ( iCloned === -1 )
|
||||
{
|
||||
var nClone = $(aoOriginal[i][j].cell).clone(true, true)[0];
|
||||
var nClone = $(aoOriginal[i][j].cell).clone(events, false)[0];
|
||||
aClones.push( nClone );
|
||||
aCloned.push( aoOriginal[i][j].cell );
|
||||
|
||||
@@ -992,17 +1077,15 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
*/
|
||||
if ( bAll )
|
||||
{
|
||||
if ( oClone.header !== null )
|
||||
{
|
||||
oClone.header.parentNode.removeChild( oClone.header );
|
||||
}
|
||||
oClone.header = $(this.dom.header).clone(true, true)[0];
|
||||
$(oClone.header).remove();
|
||||
|
||||
oClone.header = $(this.dom.header).clone(true, false)[0];
|
||||
oClone.header.className += " DTFC_Cloned";
|
||||
oClone.header.style.width = "100%";
|
||||
oGrid.head.appendChild( oClone.header );
|
||||
|
||||
/* Copy the DataTables layout cache for the header for our floating column */
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns, true );
|
||||
jqCloneThead = $('>thead', oClone.header);
|
||||
jqCloneThead.empty();
|
||||
|
||||
@@ -1024,7 +1107,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
* cloned cells, just copy the classes across. To get the matching layout for the
|
||||
* fixed component, we use the DataTables _fnDetectHeader method, allowing 1:1 mapping
|
||||
*/
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns, false );
|
||||
aoFixedHeader=[];
|
||||
|
||||
dt.oApi._fnDetectHeader( aoFixedHeader, $('>thead', oClone.header)[0] );
|
||||
@@ -1055,7 +1138,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
if ( oClone.body !== null )
|
||||
{
|
||||
oClone.body.parentNode.removeChild( oClone.body );
|
||||
$(oClone.body).remove();
|
||||
oClone.body = null;
|
||||
}
|
||||
|
||||
@@ -1100,12 +1183,14 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
/* Add in the tbody elements, cloning form the master table */
|
||||
$('>tbody>tr', that.dom.body).each( function (z) {
|
||||
var n = this.cloneNode(false);
|
||||
n.removeAttribute('id');
|
||||
var i = that.s.dt.oFeatures.bServerSide===false ?
|
||||
that.s.dt.aiDisplay[ that.s.dt._iDisplayStart+z ] : z;
|
||||
var aTds = that.s.dt.aoData[ i ].anCells || $(this).children('td, th');
|
||||
|
||||
var n = this.cloneNode(false);
|
||||
n.removeAttribute('id');
|
||||
n.setAttribute( 'data-dt-row', i );
|
||||
|
||||
for ( iIndex=0 ; iIndex<aiColumns.length ; iIndex++ )
|
||||
{
|
||||
iColumn = aiColumns[iIndex];
|
||||
@@ -1113,6 +1198,8 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
if ( aTds.length > 0 )
|
||||
{
|
||||
nClone = $( aTds[iColumn] ).clone(true, true)[0];
|
||||
nClone.setAttribute( 'data-dt-row', i );
|
||||
nClone.setAttribute( 'data-dt-column', iIndex );
|
||||
n.appendChild( nClone );
|
||||
}
|
||||
}
|
||||
@@ -1169,7 +1256,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
oGrid.foot.appendChild( oClone.footer );
|
||||
|
||||
/* Copy the footer just like we do for the header */
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns, true );
|
||||
var jqCloneTfoot = $('>tfoot', oClone.footer);
|
||||
jqCloneTfoot.empty();
|
||||
|
||||
@@ -1181,7 +1268,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
}
|
||||
else
|
||||
{
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns, false );
|
||||
var aoCurrFooter=[];
|
||||
|
||||
dt.oApi._fnDetectHeader( aoCurrFooter, $('>tfoot', oClone.footer)[0] );
|
||||
@@ -1279,8 +1366,43 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
anClone[i].style.height = heights[i]+"px";
|
||||
anOriginal[i].style.height = heights[i]+"px";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if the UA suffers from Firefox's overflow:scroll scrollbars
|
||||
* not being shown bug.
|
||||
*
|
||||
* Firefox doesn't draw scrollbars, even if it is told to using
|
||||
* overflow:scroll, if the div is less than 34px height. See bugs 292284 and
|
||||
* 781885. Using UA detection here since this is particularly hard to detect
|
||||
* using objects - its a straight up rendering error in Firefox.
|
||||
*
|
||||
* @return {boolean} True if Firefox error is present, false otherwise
|
||||
*/
|
||||
_firefoxScrollError: function () {
|
||||
if ( _firefoxScroll === undefined ) {
|
||||
var test = $('<div/>')
|
||||
.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
height: 10,
|
||||
width: 50,
|
||||
overflow: 'scroll'
|
||||
} )
|
||||
.appendTo( 'body' );
|
||||
|
||||
// Make sure this doesn't apply on Macs with 0 width scrollbars
|
||||
_firefoxScroll = (
|
||||
test[0].clientWidth === test[0].offsetWidth && this._fnDTOverflow().bar !== 0
|
||||
);
|
||||
|
||||
test.remove();
|
||||
}
|
||||
|
||||
return _firefoxScroll;
|
||||
}
|
||||
};
|
||||
} );
|
||||
|
||||
|
||||
|
||||
@@ -1376,48 +1498,108 @@ FixedColumns.defaults = /** @lends FixedColumns.defaults */{
|
||||
* @default See code
|
||||
* @static
|
||||
*/
|
||||
FixedColumns.version = "3.0.4";
|
||||
FixedColumns.version = "3.2.1";
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Fired events (for documentation)
|
||||
* DataTables API integration
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
DataTable.Api.register( 'fixedColumns()', function () {
|
||||
return this;
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().update()', function () {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx._oFixedColumns ) {
|
||||
ctx._oFixedColumns.fnUpdate();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().relayout()', function () {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx._oFixedColumns ) {
|
||||
ctx._oFixedColumns.fnRedrawLayout();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'rows().recalcHeight()', function () {
|
||||
return this.iterator( 'row', function ( ctx, idx ) {
|
||||
if ( ctx._oFixedColumns ) {
|
||||
ctx._oFixedColumns.fnRecalculateHeight( this.row(idx).node() );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().rowIndex()', function ( row ) {
|
||||
row = $(row);
|
||||
|
||||
return row.parents('.DTFC_Cloned').length ?
|
||||
this.rows( { page: 'current' } ).indexes()[ row.index() ] :
|
||||
this.row( row ).index();
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().cellIndex()', function ( cell ) {
|
||||
cell = $(cell);
|
||||
|
||||
if ( cell.parents('.DTFC_Cloned').length ) {
|
||||
var rowClonedIdx = cell.parent().index();
|
||||
var rowIdx = this.rows( { page: 'current' } ).indexes()[ rowClonedIdx ];
|
||||
var columnIdx;
|
||||
|
||||
if ( cell.parents('.DTFC_LeftWrapper').length ) {
|
||||
columnIdx = cell.index();
|
||||
}
|
||||
else {
|
||||
var columns = this.columns().flatten().length;
|
||||
columnIdx = columns - this.context[0]._oFixedColumns.s.iRightColumns + cell.index();
|
||||
}
|
||||
|
||||
return {
|
||||
row: rowIdx,
|
||||
column: this.column.index( 'toData', columnIdx ),
|
||||
columnVisible: columnIdx
|
||||
};
|
||||
}
|
||||
else {
|
||||
return this.cell( cell ).index();
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Initialisation
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
// Attach a listener to the document which listens for DataTables initialisation
|
||||
// events so we can automatically initialise
|
||||
$(document).on( 'init.dt.fixedColumns', function (e, settings) {
|
||||
if ( e.namespace !== 'dt' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var init = settings.oInit.fixedColumns;
|
||||
var defaults = DataTable.defaults.fixedColumns;
|
||||
|
||||
if ( init || defaults ) {
|
||||
var opts = $.extend( {}, init, defaults );
|
||||
|
||||
if ( init !== false ) {
|
||||
new FixedColumns( settings, opts );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Event fired whenever FixedColumns redraws the fixed columns (i.e. clones the table elements from the main DataTable). This will occur whenever the DataTable that the FixedColumns instance is attached does its own draw.
|
||||
* @name FixedColumns#draw.dtfc
|
||||
* @event
|
||||
* @param {event} e jQuery event object
|
||||
* @param {object} o Event parameters from FixedColumns
|
||||
* @param {object} o.leftClone Instance's object dom.clone.left for easy reference. This object contains references to the left fixed clumn column's nodes
|
||||
* @param {object} o.rightClone Instance's object dom.clone.right for easy reference. This object contains references to the right fixed clumn column's nodes
|
||||
*/
|
||||
|
||||
|
||||
// Make FixedColumns accessible from the DataTables instance
|
||||
$.fn.dataTable.FixedColumns = FixedColumns;
|
||||
$.fn.DataTable.FixedColumns = FixedColumns;
|
||||
|
||||
|
||||
return FixedColumns;
|
||||
}; // /factory
|
||||
|
||||
|
||||
// Define as an AMD module if possible
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
})(window, document);
|
||||
|
||||
}));
|
||||
Reference in New Issue
Block a user