123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659 |
- (function( factory ){
- if ( typeof define === 'function' && define.amd ) {
-
- define( ['jquery', 'datatables.net'], function ( $ ) {
- return factory( $, window, document );
- } );
- }
- else if ( typeof exports === 'object' ) {
-
- module.exports = function (root, $) {
- if ( ! root ) {
- root = window;
- }
- if ( ! $ || ! $.fn.dataTable ) {
- $ = require('datatables.net')(root, $).$;
- }
- return factory( $, root, root.document );
- };
- }
- else {
-
- factory( jQuery, window, document );
- }
- }(function( $, window, document, undefined ) {
- 'use strict';
- var DataTable = $.fn.dataTable;
- var _firefoxScroll;
- var FixedColumns = function ( dt, init ) {
- var that = this;
-
- if ( ! ( this instanceof FixedColumns ) ) {
- alert( "FixedColumns warning: FixedColumns must be initialised with the 'new' keyword." );
- return;
- }
- if ( init === undefined || init === true ) {
- init = {};
- }
-
-
- var camelToHungarian = $.fn.dataTable.camelToHungarian;
- if ( camelToHungarian ) {
- camelToHungarian( FixedColumns.defaults, FixedColumns.defaults, true );
- camelToHungarian( FixedColumns.defaults, init );
- }
-
- var dtSettings = new $.fn.dataTable.Api( dt ).settings()[0];
-
- this.s = {
-
- "dt": dtSettings,
-
- "iTableColumns": dtSettings.aoColumns.length,
-
- "aiOuterWidths": [],
-
- "aiInnerWidths": [],
-
- rtl: $(dtSettings.nTable).css('direction') === 'rtl'
- };
-
- this.dom = {
-
- "scroller": null,
-
- "header": null,
-
- "body": null,
-
- "footer": null,
-
- "grid": {
-
- "wrapper": null,
-
- "dt": null,
-
- "left": {
- "wrapper": null,
- "head": null,
- "body": null,
- "foot": null
- },
-
- "right": {
- "wrapper": null,
- "head": null,
- "body": null,
- "foot": null
- }
- },
-
- "clone": {
-
- "left": {
-
- "header": null,
-
- "body": null,
-
- "footer": null
- },
-
- "right": {
-
- "header": null,
-
- "body": null,
-
- "footer": null
- }
- }
- };
- if ( dtSettings._oFixedColumns ) {
- throw 'FixedColumns already initialised on this table';
- }
-
- dtSettings._oFixedColumns = this;
-
- if ( ! dtSettings._bInitComplete )
- {
- dtSettings.oApi._fnCallbackReg( dtSettings, 'aoInitComplete', function () {
- that._fnConstruct( init );
- }, 'FixedColumns' );
- }
- else
- {
- this._fnConstruct( init );
- }
- };
- $.extend( FixedColumns.prototype , {
-
-
- "fnUpdate": function ()
- {
- this._fnDraw( true );
- },
-
- "fnRedrawLayout": function ()
- {
- this._fnColCalc();
- this._fnGridLayout();
- this.fnUpdate();
- },
-
- "fnRecalculateHeight": function ( nTr )
- {
- delete nTr._DTTC_iHeight;
- nTr.style.height = 'auto';
- },
-
- "fnSetRowHeight": function ( nTarget, iHeight )
- {
- nTarget.style.height = iHeight+"px";
- },
-
- "fnGetPosition": function ( node )
- {
- var idx;
- var inst = this.s.dt.oInstance;
- if ( ! $(node).parents('.DTFC_Cloned').length )
- {
-
- return inst.fnGetPosition( node );
- }
- else
- {
-
- if ( node.nodeName.toLowerCase() === 'tr' ) {
- idx = $(node).index();
- return inst.fnGetPosition( $('tr', this.s.dt.nTBody)[ idx ] );
- }
- else
- {
- var colIdx = $(node).index();
- idx = $(node.parentNode).index();
- var row = inst.fnGetPosition( $('tr', this.s.dt.nTBody)[ idx ] );
- return [
- row,
- colIdx,
- inst.oApi._fnVisibleToColumnIndex( this.s.dt, colIdx )
- ];
- }
- }
- },
- fnToFixedNode: function ( rowIdx, colIdx )
- {
- var found;
- if ( colIdx < this.s.iLeftColumns ) {
- found = $(this.dom.clone.left.body).find('[data-dt-row='+rowIdx+'][data-dt-column='+colIdx+']');
- }
- else if ( colIdx >= this.s.iRightColumns ) {
- found = $(this.dom.clone.right.body).find('[data-dt-row='+rowIdx+'][data-dt-column='+colIdx+']');
- }
- if ( found && found.length ) {
- return found[0];
- }
-
- var table = new $.fn.dataTable.Api(this.s.dt);
- return table.cell(rowIdx, colIdx).node();
- },
-
-
- "_fnConstruct": function ( oInit )
- {
- var i, iLen, iWidth,
- that = this;
-
- if ( typeof this.s.dt.oInstance.fnVersionCheck != 'function' ||
- this.s.dt.oInstance.fnVersionCheck( '1.8.0' ) !== true )
- {
- alert( "FixedColumns "+FixedColumns.VERSION+" required DataTables 1.8.0 or later. "+
- "Please upgrade your DataTables installation" );
- return;
- }
- if ( this.s.dt.oScroll.sX === "" )
- {
- this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "FixedColumns is not needed (no "+
- "x-scrolling in DataTables enabled), so no action will be taken. Use 'FixedHeader' for "+
- "column fixing when scrolling is not enabled" );
- return;
- }
-
- this.s = $.extend( true, this.s, FixedColumns.defaults, oInit );
-
- var classes = this.s.dt.oClasses;
- this.dom.grid.dt = $(this.s.dt.nTable).parents('div.'+classes.sScrollWrapper)[0];
- this.dom.scroller = $('div.'+classes.sScrollBody, this.dom.grid.dt )[0];
-
- this._fnColCalc();
- this._fnGridSetup();
-
- var mouseController;
- var mouseDown = false;
-
-
- $(this.s.dt.nTableWrapper).on( 'mousedown.DTFC', function (e) {
- if ( e.button === 0 ) {
- mouseDown = true;
- $(document).one( 'mouseup', function () {
- mouseDown = false;
- } );
- }
- } );
-
- $(this.dom.scroller)
- .on( 'mouseover.DTFC touchstart.DTFC', function () {
- if ( ! mouseDown ) {
- mouseController = 'main';
- }
- } )
- .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;
- }
- if ( that.s.iRightColumns > 0 ) {
- 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 ) {
-
- $(that.dom.grid.left.liner)
- .on( 'mouseover.DTFC touchstart.DTFC', function () {
- if ( ! mouseDown ) {
- mouseController = 'left';
- }
- } )
- .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 ) {
- that.dom.grid.right.liner.scrollTop = that.dom.grid.left.liner.scrollTop;
- }
- }
- } )
- .on( wheelType, function(e) {
-
- var xDelta = e.type === 'wheel' ?
- -e.originalEvent.deltaX :
- e.originalEvent.wheelDeltaX;
- that.dom.scroller.scrollLeft -= xDelta;
- } );
- }
- if ( that.s.iRightColumns > 0 ) {
-
- $(that.dom.grid.right.liner)
- .on( 'mouseover.DTFC touchstart.DTFC', function () {
- if ( ! mouseDown ) {
- mouseController = 'right';
- }
- } )
- .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 ) {
- that.dom.grid.left.liner.scrollTop = that.dom.grid.right.liner.scrollTop;
- }
- }
- } )
- .on( wheelType, function(e) {
-
- var xDelta = e.type === 'wheel' ?
- -e.originalEvent.deltaX :
- e.originalEvent.wheelDeltaX;
- that.dom.scroller.scrollLeft -= xDelta;
- } );
- }
- $(window).on( 'resize.DTFC', function () {
- that._fnGridLayout.call( that );
- } );
- var bFirstDraw = true;
- var jqTable = $(this.s.dt.nTable);
- jqTable
- .on( 'draw.dt.DTFC', function () {
- that._fnColCalc();
- that._fnDraw.call( that, bFirstDraw );
- bFirstDraw = false;
- } )
- .on( 'column-sizing.dt.DTFC', function () {
- that._fnColCalc();
- that._fnGridLayout( that );
- } )
- .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 ) {
- if ( e.namespace === 'dt' ) {
- that._fnDraw( false );
- }
- } )
- .on( 'destroy.dt.DTFC', function () {
- jqTable.off( '.DTFC' );
- $(that.dom.scroller).off( '.DTFC' );
- $(window).off( '.DTFC' );
- $(that.s.dt.nTableWrapper).off( '.DTFC' );
- $(that.dom.grid.left.liner).off( '.DTFC '+wheelType );
- $(that.dom.grid.left.wrapper).remove();
- $(that.dom.grid.right.liner).off( '.DTFC '+wheelType );
- $(that.dom.grid.right.wrapper).remove();
- } );
-
- this._fnGridLayout();
- this.s.dt.oInstance.fnDraw(false);
- },
-
- "_fnColCalc": function ()
- {
- var that = this;
- var iLeftWidth = 0;
- var iRightWidth = 0;
- 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 );
- }
- else
- {
-
-
- var iWidth = th.outerWidth();
-
-
-
- if ( that.s.aiOuterWidths.length === 0 ) {
- border = $(that.s.dt.nTable).css('border-left-width');
- iWidth += typeof border === 'string' && border.indexOf('px') === -1 ?
- 1 :
- parseInt( border, 10 );
- }
-
- if ( that.s.aiOuterWidths.length === that.s.dt.aoColumns.length-1 ) {
- border = $(that.s.dt.nTable).css('border-right-width');
- iWidth += typeof border === 'string' && border.indexOf('px') === -1 ?
- 1 :
- parseInt( border, 10 );
- }
- that.s.aiOuterWidths.push( iWidth );
- that.s.aiInnerWidths.push( th.width() );
- if ( i < that.s.iLeftColumns )
- {
- iLeftWidth += iWidth;
- }
- if ( that.s.iTableColumns-that.s.iRightColumns <= i )
- {
- iRightWidth += iWidth;
- }
- }
- } );
- this.s.iLeftWidth = iLeftWidth;
- this.s.iRightWidth = iRightWidth;
- },
-
- "_fnGridSetup": function ()
- {
- var that = this;
- var oOverflow = this._fnDTOverflow();
- var block;
- this.dom.body = this.s.dt.nTable;
- this.dom.header = this.s.dt.nTHead.parentNode;
- this.dom.header.parentNode.parentNode.style.position = "relative";
- var nSWrapper =
- $('<div class="DTFC_ScrollWrapper" style="position:relative; clear:both;">'+
- '<div class="DTFC_LeftWrapper" style="position:absolute; top:0; left:0;" aria-hidden="true">'+
- '<div class="DTFC_LeftHeadWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div>'+
- '<div class="DTFC_LeftBodyWrapper" style="position:relative; top:0; left:0; height:0; overflow:hidden;">'+
- '<div class="DTFC_LeftBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div>'+
- '</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; right:0;" aria-hidden="true">'+
- '<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>'+
- '<div class="DTFC_RightBodyWrapper" style="position:relative; top:0; left:0; height:0; overflow:hidden;">'+
- '<div class="DTFC_RightBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div>'+
- '</div>'+
- '<div class="DTFC_RightFootWrapper" style="position:relative; top:0; left:0;">'+
- '<div class="DTFC_RightFootBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div>'+
- '</div>'+
- '</div>'+
- '</div>')[0];
- var nLeft = nSWrapper.childNodes[0];
- var nRight = nSWrapper.childNodes[1];
- this.dom.grid.dt.parentNode.insertBefore( nSWrapper, this.dom.grid.dt );
- nSWrapper.appendChild( this.dom.grid.dt );
- this.dom.grid.wrapper = nSWrapper;
- if ( this.s.iLeftColumns > 0 )
- {
- this.dom.grid.left.wrapper = nLeft;
- this.dom.grid.left.head = nLeft.childNodes[0];
- this.dom.grid.left.body = nLeft.childNodes[1];
- this.dom.grid.left.liner = $('div.DTFC_LeftBodyLiner', nSWrapper)[0];
- nSWrapper.appendChild( nLeft );
- }
- if ( this.s.iRightColumns > 0 )
- {
- this.dom.grid.right.wrapper = nRight;
- this.dom.grid.right.head = nRight.childNodes[0];
- 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";
- this.dom.grid.right.headBlock = block;
- block = $('div.DTFC_RightFootBlocker', nSWrapper)[0];
- block.style.width = oOverflow.bar+"px";
- block.style.right = -oOverflow.bar+"px";
- this.dom.grid.right.footBlock = block;
- nSWrapper.appendChild( nRight );
- }
- if ( this.s.dt.nTFoot )
- {
- this.dom.footer = this.s.dt.nTFoot.parentNode;
- if ( this.s.iLeftColumns > 0 )
- {
- this.dom.grid.left.foot = nLeft.childNodes[2];
- }
- if ( this.s.iRightColumns > 0 )
- {
- this.dom.grid.right.foot = nRight.childNodes[2];
- }
- }
-
- if ( this.s.rtl ) {
- $('div.DTFC_RightHeadBlocker', nSWrapper).css( {
- left: -oOverflow.bar+'px',
- right: ''
- } );
- }
- },
-
- "_fnGridLayout": function ()
- {
- var that = this;
- var oGrid = this.dom.grid;
- var iWidth = $(oGrid.wrapper).width();
- var iBodyHeight = this.s.dt.nTable.parentNode.offsetHeight;
- var iFullHeight = this.s.dt.nTable.parentNode.parentNode.offsetHeight;
- var oOverflow = this._fnDTOverflow();
- var iLeftWidth = this.s.iLeftWidth;
- var iRightWidth = this.s.iRightWidth;
- var rtl = $(this.dom.body).css('direction') === 'rtl';
- var wrapper;
- var scrollbarAdjust = function ( node, width ) {
- if ( ! oOverflow.bar ) {
-
- node.style.width = (width+20)+"px";
- node.style.paddingRight = "20px";
- node.style.boxSizing = "border-box";
- }
- else if ( that._firefoxScrollError() ) {
-
- if ( $(node).height() > 34 ) {
- node.style.width = (width+oOverflow.bar)+"px";
- }
- }
- else {
-
- node.style.width = (width+oOverflow.bar)+"px";
- }
- };
-
- if ( oOverflow.x )
- {
- iBodyHeight -= oOverflow.bar;
- }
- oGrid.wrapper.style.height = iFullHeight+"px";
- if ( this.s.iLeftColumns > 0 )
- {
- wrapper = oGrid.left.wrapper;
- wrapper.style.width = iLeftWidth+'px';
- wrapper.style.height = '1px';
-
-
- if ( rtl ) {
- wrapper.style.left = '';
- wrapper.style.right = 0;
- }
- else {
- wrapper.style.left = 0;
- wrapper.style.right = '';
- }
- oGrid.left.body.style.height = iBodyHeight+"px";
- if ( oGrid.left.foot ) {
- oGrid.left.foot.style.top = (oOverflow.x ? oOverflow.bar : 0)+"px";
- }
- scrollbarAdjust( oGrid.left.liner, iLeftWidth );
- oGrid.left.liner.style.height = iBodyHeight+"px";
- oGrid.left.liner.style.maxHeight = iBodyHeight+"px";
- }
- if ( this.s.iRightColumns > 0 )
- {
- wrapper = oGrid.right.wrapper;
- wrapper.style.width = iRightWidth+'px';
- wrapper.style.height = '1px';
-
- if ( this.s.rtl ) {
- wrapper.style.left = oOverflow.y ? oOverflow.bar+'px' : 0;
- wrapper.style.right = '';
- }
- else {
- wrapper.style.left = '';
- wrapper.style.right = oOverflow.y ? oOverflow.bar+'px' : 0;
- }
- oGrid.right.body.style.height = iBodyHeight+"px";
- if ( oGrid.right.foot ) {
- oGrid.right.foot.style.top = (oOverflow.x ? oOverflow.bar : 0)+"px";
- }
- scrollbarAdjust( oGrid.right.liner, iRightWidth );
- oGrid.right.liner.style.height = iBodyHeight+"px";
- oGrid.right.liner.style.maxHeight = iBodyHeight+"px";
- oGrid.right.headBlock.style.display = oOverflow.y ? 'block' : 'none';
- oGrid.right.footBlock.style.display = oOverflow.y ? 'block' : 'none';
- }
- },
-
- "_fnDTOverflow": function ()
- {
- var nTable = this.s.dt.nTable;
- var nTableScrollBody = nTable.parentNode;
- var out = {
- "x": false,
- "y": false,
- "bar": this.s.dt.oScroll.iBarWidth
- };
- if ( nTable.offsetWidth > nTableScrollBody.clientWidth )
- {
- out.x = true;
- }
- if ( nTable.offsetHeight > nTableScrollBody.clientHeight )
- {
- out.y = true;
- }
- return out;
- },
-
- "_fnDraw": function ( bAll )
- {
- this._fnGridLayout();
- this._fnCloneLeft( bAll );
- this._fnCloneRight( bAll );
-
- if ( this.s.fnDrawCallback !== null )
- {
- this.s.fnDrawCallback.call( this, this.dom.clone.left, this.dom.clone.right );
- }
-
- $(this).trigger( 'draw.dtfc', {
- "leftClone": this.dom.clone.left,
- "rightClone": this.dom.clone.right
- } );
- },
-
- "_fnCloneRight": function ( bAll )
- {
- if ( this.s.iRightColumns <= 0 ) {
- return;
- }
- var that = this,
- i, jq,
- aiColumns = [];
- for ( i=this.s.iTableColumns-this.s.iRightColumns ; i<this.s.iTableColumns ; i++ ) {
- if ( this.s.dt.aoColumns[i].bVisible ) {
- aiColumns.push( i );
- }
- }
- this._fnClone( this.dom.clone.right, this.dom.grid.right, aiColumns, bAll );
- },
-
- "_fnCloneLeft": function ( bAll )
- {
- if ( this.s.iLeftColumns <= 0 ) {
- return;
- }
- var that = this,
- i, jq,
- aiColumns = [];
- for ( i=0 ; i<this.s.iLeftColumns ; i++ ) {
- if ( this.s.dt.aoColumns[i].bVisible ) {
- aiColumns.push( i );
- }
- }
- this._fnClone( this.dom.clone.left, this.dom.grid.left, aiColumns, bAll );
- },
-
- "_fnCopyLayout": function ( aoOriginal, aiColumns, events )
- {
- var aReturn = [];
- var aClones = [];
- var aCloned = [];
- for ( var i=0, iLen=aoOriginal.length ; i<iLen ; i++ )
- {
- var aRow = [];
- aRow.nTr = $(aoOriginal[i].nTr).clone(events, false)[0];
- for ( var j=0, jLen=this.s.iTableColumns ; j<jLen ; j++ )
- {
- if ( $.inArray( j, aiColumns ) === -1 )
- {
- continue;
- }
- var iCloned = $.inArray( aoOriginal[i][j].cell, aCloned );
- if ( iCloned === -1 )
- {
- var nClone = $(aoOriginal[i][j].cell).clone(events, false)[0];
- aClones.push( nClone );
- aCloned.push( aoOriginal[i][j].cell );
- aRow.push( {
- "cell": nClone,
- "unique": aoOriginal[i][j].unique
- } );
- }
- else
- {
- aRow.push( {
- "cell": aClones[ iCloned ],
- "unique": aoOriginal[i][j].unique
- } );
- }
- }
- aReturn.push( aRow );
- }
- return aReturn;
- },
-
- "_fnClone": function ( oClone, oGrid, aiColumns, bAll )
- {
- var that = this,
- i, iLen, j, jLen, jq, nTarget, iColumn, nClone, iIndex, aoCloneLayout,
- jqCloneThead, aoFixedHeader,
- dt = this.s.dt;
-
- if ( bAll )
- {
- $(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 );
-
- aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns, true );
- jqCloneThead = $('>thead', oClone.header);
- jqCloneThead.empty();
-
- for ( i=0, iLen=aoCloneLayout.length ; i<iLen ; i++ )
- {
- jqCloneThead[0].appendChild( aoCloneLayout[i].nTr );
- }
-
- dt.oApi._fnDrawHead( dt, aoCloneLayout, true );
- }
- else
- {
-
- aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns, false );
- aoFixedHeader=[];
- dt.oApi._fnDetectHeader( aoFixedHeader, $('>thead', oClone.header)[0] );
- for ( i=0, iLen=aoCloneLayout.length ; i<iLen ; i++ )
- {
- for ( j=0, jLen=aoCloneLayout[i].length ; j<jLen ; j++ )
- {
- aoFixedHeader[i][j].cell.className = aoCloneLayout[i][j].cell.className;
-
- $('span.DataTables_sort_icon', aoFixedHeader[i][j].cell).each( function () {
- this.className = $('span.DataTables_sort_icon', aoCloneLayout[i][j].cell)[0].className;
- } );
- }
- }
- }
- this._fnEqualiseHeights( 'thead', this.dom.header, oClone.header );
-
- if ( this.s.sHeightMatch == 'auto' )
- {
-
- $('>tbody>tr', that.dom.body).css('height', 'auto');
- }
- if ( oClone.body !== null )
- {
- $(oClone.body).remove();
- oClone.body = null;
- }
- oClone.body = $(this.dom.body).clone(true)[0];
- oClone.body.className += " DTFC_Cloned";
- oClone.body.style.paddingBottom = dt.oScroll.iBarWidth+"px";
- oClone.body.style.marginBottom = (dt.oScroll.iBarWidth*2)+"px";
- if ( oClone.body.getAttribute('id') !== null )
- {
- oClone.body.removeAttribute('id');
- }
- $('>thead>tr', oClone.body).empty();
- $('>tfoot', oClone.body).remove();
- var nBody = $('tbody', oClone.body)[0];
- $(nBody).empty();
- if ( dt.aiDisplay.length > 0 )
- {
-
- var nInnerThead = $('>thead>tr', oClone.body)[0];
- for ( iIndex=0 ; iIndex<aiColumns.length ; iIndex++ )
- {
- iColumn = aiColumns[iIndex];
- nClone = $(dt.aoColumns[iColumn].nTh).clone(true)[0];
- nClone.innerHTML = "";
- var oStyle = nClone.style;
- oStyle.paddingTop = "0";
- oStyle.paddingBottom = "0";
- oStyle.borderTopWidth = "0";
- oStyle.borderBottomWidth = "0";
- oStyle.height = 0;
- oStyle.width = that.s.aiInnerWidths[iColumn]+"px";
- nInnerThead.appendChild( nClone );
- }
-
- $('>tbody>tr', that.dom.body).each( function (z) {
- 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];
- if ( aTds.length > 0 )
- {
- nClone = $( aTds[iColumn] ).clone(true, true)[0];
- nClone.removeAttribute( 'id' );
- nClone.setAttribute( 'data-dt-row', i );
- nClone.setAttribute( 'data-dt-column', iColumn );
- n.appendChild( nClone );
- }
- }
- nBody.appendChild( n );
- } );
- }
- else
- {
- $('>tbody>tr', that.dom.body).each( function (z) {
- nClone = this.cloneNode(true);
- nClone.className += ' DTFC_NoData';
- $('td', nClone).html('');
- nBody.appendChild( nClone );
- } );
- }
- oClone.body.style.width = "100%";
- oClone.body.style.margin = "0";
- oClone.body.style.padding = "0";
-
-
- if ( dt.oScroller !== undefined )
- {
- var scrollerForcer = dt.oScroller.dom.force;
- if ( ! oGrid.forcer ) {
- oGrid.forcer = scrollerForcer.cloneNode( true );
- oGrid.liner.appendChild( oGrid.forcer );
- }
- else {
- oGrid.forcer.style.height = scrollerForcer.style.height;
- }
- }
- oGrid.liner.appendChild( oClone.body );
- this._fnEqualiseHeights( 'tbody', that.dom.body, oClone.body );
-
- if ( dt.nTFoot !== null )
- {
- if ( bAll )
- {
- if ( oClone.footer !== null )
- {
- oClone.footer.parentNode.removeChild( oClone.footer );
- }
- oClone.footer = $(this.dom.footer).clone(true, true)[0];
- oClone.footer.className += " DTFC_Cloned";
- oClone.footer.style.width = "100%";
- oGrid.foot.appendChild( oClone.footer );
-
- aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns, true );
- var jqCloneTfoot = $('>tfoot', oClone.footer);
- jqCloneTfoot.empty();
- for ( i=0, iLen=aoCloneLayout.length ; i<iLen ; i++ )
- {
- jqCloneTfoot[0].appendChild( aoCloneLayout[i].nTr );
- }
- dt.oApi._fnDrawHead( dt, aoCloneLayout, true );
- }
- else
- {
- aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns, false );
- var aoCurrFooter=[];
- dt.oApi._fnDetectHeader( aoCurrFooter, $('>tfoot', oClone.footer)[0] );
- for ( i=0, iLen=aoCloneLayout.length ; i<iLen ; i++ )
- {
- for ( j=0, jLen=aoCloneLayout[i].length ; j<jLen ; j++ )
- {
- aoCurrFooter[i][j].cell.className = aoCloneLayout[i][j].cell.className;
- }
- }
- }
- this._fnEqualiseHeights( 'tfoot', this.dom.footer, oClone.footer );
- }
-
- var anUnique = dt.oApi._fnGetUniqueThs( dt, $('>thead', oClone.header)[0] );
- $(anUnique).each( function (i) {
- iColumn = aiColumns[i];
- this.style.width = that.s.aiInnerWidths[iColumn]+"px";
- } );
- if ( that.s.dt.nTFoot !== null )
- {
- anUnique = dt.oApi._fnGetUniqueThs( dt, $('>tfoot', oClone.footer)[0] );
- $(anUnique).each( function (i) {
- iColumn = aiColumns[i];
- this.style.width = that.s.aiInnerWidths[iColumn]+"px";
- } );
- }
- },
-
- "_fnGetTrNodes": function ( nIn )
- {
- var aOut = [];
- for ( var i=0, iLen=nIn.childNodes.length ; i<iLen ; i++ )
- {
- if ( nIn.childNodes[i].nodeName.toUpperCase() == "TR" )
- {
- aOut.push( nIn.childNodes[i] );
- }
- }
- return aOut;
- },
-
- "_fnEqualiseHeights": function ( nodeName, original, clone )
- {
- if ( this.s.sHeightMatch == 'none' && nodeName !== 'thead' && nodeName !== 'tfoot' )
- {
- return;
- }
- var that = this,
- i, iLen, iHeight, iHeight2, iHeightOriginal, iHeightClone,
- rootOriginal = original.getElementsByTagName(nodeName)[0],
- rootClone = clone.getElementsByTagName(nodeName)[0],
- jqBoxHack = $('>'+nodeName+'>tr:eq(0)', original).children(':first'),
- iBoxHack = jqBoxHack.outerHeight() - jqBoxHack.height(),
- anOriginal = this._fnGetTrNodes( rootOriginal ),
- anClone = this._fnGetTrNodes( rootClone ),
- heights = [];
- for ( i=0, iLen=anClone.length ; i<iLen ; i++ )
- {
- iHeightOriginal = anOriginal[i].offsetHeight;
- iHeightClone = anClone[i].offsetHeight;
- iHeight = iHeightClone > iHeightOriginal ? iHeightClone : iHeightOriginal;
- if ( this.s.sHeightMatch == 'semiauto' )
- {
- anOriginal[i]._DTTC_iHeight = iHeight;
- }
- heights.push( iHeight );
- }
- for ( i=0, iLen=anClone.length ; i<iLen ; i++ )
- {
- anClone[i].style.height = heights[i]+"px";
- anOriginal[i].style.height = heights[i]+"px";
- }
- },
-
- _firefoxScrollError: function () {
- if ( _firefoxScroll === undefined ) {
- var test = $('<div/>')
- .css( {
- position: 'absolute',
- top: 0,
- left: 0,
- height: 10,
- width: 50,
- overflow: 'scroll'
- } )
- .appendTo( 'body' );
-
- _firefoxScroll = (
- test[0].clientWidth === test[0].offsetWidth && this._fnDTOverflow().bar !== 0
- );
- test.remove();
- }
- return _firefoxScroll;
- }
- } );
- FixedColumns.defaults = {
-
- "iLeftColumns": 1,
-
- "iRightColumns": 0,
-
- "fnDrawCallback": null,
-
- "sHeightMatch": "semiauto"
- };
- FixedColumns.version = "3.8.0";
- 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();
- }
- } );
- DataTable.Api.registerPlural( 'cells().fixedNodes()', 'cell().fixedNode()', function () {
- return this.iterator( 'cell', function ( settings, row, column ) {
- return settings._oFixedColumns
- ? settings._oFixedColumns.fnToFixedNode( row, column )
- : this.node();
- }, 1 );
- } );
- $(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 );
- }
- }
- } );
- $.fn.dataTable.FixedColumns = FixedColumns;
- $.fn.DataTable.FixedColumns = FixedColumns;
- return FixedColumns;
- }));
|