12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688 |
- (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' || mouseController === 'key' ) {
- 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 !== 'key' ) {
- 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) {
- mouseController = 'left';
-
- var xDelta = e.type === 'wheel' ?
- -e.originalEvent.deltaX :
- e.originalEvent.wheelDeltaX;
- that.dom.scroller.scrollLeft -= xDelta;
- } );
-
- $(that.dom.grid.left.head).on( 'mouseover.DTFC touchstart.DTFC', function () {
- mouseController = 'main';
- });
- }
- if ( that.s.iRightColumns > 0 ) {
-
- $(that.dom.grid.right.liner)
- .on( 'mouseover.DTFC touchstart.DTFC', function () {
- if ( ! mouseDown && mouseController !== 'key' ) {
- 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) {
- mouseController = 'right';
-
- var xDelta = e.type === 'wheel' ?
- -e.originalEvent.deltaX :
- e.originalEvent.wheelDeltaX;
- that.dom.scroller.scrollLeft -= xDelta;
- } );
- $(that.dom.grid.right.head).on( 'mouseover.DTFC touchstart.DTFC', function () {
- mouseController = 'main';
- });
- }
- $(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('key-focus.dt.DTFC', function () {
-
- mouseController = 'key';
- })
- .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( 'position.dts.dt.DTFC', function (e, tableTop) {
-
- if (that.dom.grid.left.body) {
- $(that.dom.grid.left.body).find('table').eq(0).css('top', tableTop);
- }
- if (that.dom.grid.right.body) {
- $(that.dom.grid.right.body).find('table').eq(0).css('top', tableTop);
- }
- } )
- .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 );
- $(this.dom.scroller).trigger('scroll');
-
- 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.3.3";
- 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.cell(row, column).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;
- }));
|