1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372 |
- (function(window, document, undefined) {
- function fnInvertKeyValues( aIn )
- {
- var aRet=[];
- for ( var i=0, iLen=aIn.length ; i<iLen ; i++ )
- {
- aRet[ aIn[i] ] = i;
- }
- return aRet;
- }
- function fnArraySwitch( aArray, iFrom, iTo )
- {
- var mStore = aArray.splice( iFrom, 1 )[0];
- aArray.splice( iTo, 0, mStore );
- }
- function fnDomSwitch( nParent, iFrom, iTo )
- {
- var anTags = [];
- for ( var i=0, iLen=nParent.childNodes.length ; i<iLen ; i++ )
- {
- if ( nParent.childNodes[i].nodeType == 1 )
- {
- anTags.push( nParent.childNodes[i] );
- }
- }
- var nStore = anTags[ iFrom ];
- if ( iTo !== null )
- {
- nParent.insertBefore( nStore, anTags[iTo] );
- }
- else
- {
- nParent.appendChild( nStore );
- }
- }
- var factory = function( $, DataTable ) {
- "use strict";
- $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
- {
- var v110 = $.fn.dataTable.Api ? true : false;
- var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
- var attrMap = function ( obj, prop, mapping ) {
- if ( ! obj[ prop ] ) {
- return;
- }
- var a = obj[ prop ].split('.');
- var num = a.shift();
- if ( isNaN( num*1 ) ) {
- return;
- }
- obj[ prop ] = mapping[ num*1 ]+'.'+a.join('.');
- };
-
- if ( iFrom == iTo )
- {
-
- return;
- }
- if ( iFrom < 0 || iFrom >= iCols )
- {
- this.oApi._fnLog( oSettings, 1, "ColReorder 'from' index is out of bounds: "+iFrom );
- return;
- }
- if ( iTo < 0 || iTo >= iCols )
- {
- this.oApi._fnLog( oSettings, 1, "ColReorder 'to' index is out of bounds: "+iTo );
- return;
- }
-
- var aiMapping = [];
- for ( i=0, iLen=iCols ; i<iLen ; i++ )
- {
- aiMapping[i] = i;
- }
- fnArraySwitch( aiMapping, iFrom, iTo );
- var aiInvertMapping = fnInvertKeyValues( aiMapping );
-
-
- for ( i=0, iLen=oSettings.aaSorting.length ; i<iLen ; i++ )
- {
- oSettings.aaSorting[i][0] = aiInvertMapping[ oSettings.aaSorting[i][0] ];
- }
-
- if ( oSettings.aaSortingFixed !== null )
- {
- for ( i=0, iLen=oSettings.aaSortingFixed.length ; i<iLen ; i++ )
- {
- oSettings.aaSortingFixed[i][0] = aiInvertMapping[ oSettings.aaSortingFixed[i][0] ];
- }
- }
-
- for ( i=0, iLen=iCols ; i<iLen ; i++ )
- {
- oCol = oSettings.aoColumns[i];
- for ( j=0, jLen=oCol.aDataSort.length ; j<jLen ; j++ )
- {
- oCol.aDataSort[j] = aiInvertMapping[ oCol.aDataSort[j] ];
- }
-
- if ( v110 ) {
- oCol.idx = aiInvertMapping[ oCol.idx ];
- }
- }
- if ( v110 ) {
-
- $.each( oSettings.aLastSort, function (i, val) {
- oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
- } );
- }
-
- for ( i=0, iLen=iCols ; i<iLen ; i++ )
- {
- oCol = oSettings.aoColumns[i];
- if ( typeof oCol.mData == 'number' ) {
- oCol.mData = aiInvertMapping[ oCol.mData ];
-
- oSettings.oApi._fnColumnOptions( oSettings, i, {} );
- }
- else if ( $.isPlainObject( oCol.mData ) ) {
-
- attrMap( oCol.mData, '_', aiInvertMapping );
- attrMap( oCol.mData, 'filter', aiInvertMapping );
- attrMap( oCol.mData, 'sort', aiInvertMapping );
- attrMap( oCol.mData, 'type', aiInvertMapping );
-
- oSettings.oApi._fnColumnOptions( oSettings, i, {} );
- }
- }
-
- if ( oSettings.aoColumns[iFrom].bVisible )
- {
-
- var iVisibleIndex = this.oApi._fnColumnIndexToVisible( oSettings, iFrom );
- var iInsertBeforeIndex = null;
- i = iTo < iFrom ? iTo : iTo + 1;
- while ( iInsertBeforeIndex === null && i < iCols )
- {
- iInsertBeforeIndex = this.oApi._fnColumnIndexToVisible( oSettings, i );
- i++;
- }
-
- nTrs = oSettings.nTHead.getElementsByTagName('tr');
- for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
- {
- fnDomSwitch( nTrs[i], iVisibleIndex, iInsertBeforeIndex );
- }
-
- if ( oSettings.nTFoot !== null )
- {
- nTrs = oSettings.nTFoot.getElementsByTagName('tr');
- for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
- {
- fnDomSwitch( nTrs[i], iVisibleIndex, iInsertBeforeIndex );
- }
- }
-
- for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
- {
- if ( oSettings.aoData[i].nTr !== null )
- {
- fnDomSwitch( oSettings.aoData[i].nTr, iVisibleIndex, iInsertBeforeIndex );
- }
- }
- }
-
-
- fnArraySwitch( oSettings.aoColumns, iFrom, iTo );
-
- fnArraySwitch( oSettings.aoPreSearchCols, iFrom, iTo );
-
- for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
- {
- var data = oSettings.aoData[i];
- if ( v110 ) {
-
- if ( data.anCells ) {
- fnArraySwitch( data.anCells, iFrom, iTo );
- }
-
-
-
- if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
- fnArraySwitch( data._aData, iFrom, iTo );
- }
- }
- else {
-
- if ( $.isArray( data._aData ) ) {
- fnArraySwitch( data._aData, iFrom, iTo );
- }
- fnArraySwitch( data._anHidden, iFrom, iTo );
- }
- }
-
- for ( i=0, iLen=oSettings.aoHeader.length ; i<iLen ; i++ )
- {
- fnArraySwitch( oSettings.aoHeader[i], iFrom, iTo );
- }
- if ( oSettings.aoFooter !== null )
- {
- for ( i=0, iLen=oSettings.aoFooter.length ; i<iLen ; i++ )
- {
- fnArraySwitch( oSettings.aoFooter[i], iFrom, iTo );
- }
- }
-
- if ( v110 ) {
- var api = new $.fn.dataTable.Api( oSettings );
- api.rows().invalidate();
- }
-
-
- for ( i=0, iLen=iCols ; i<iLen ; i++ )
- {
- $(oSettings.aoColumns[i].nTh).off('click.DT');
- this.oApi._fnSortAttachListener( oSettings, oSettings.aoColumns[i].nTh, i );
- }
-
- $(oSettings.oInstance).trigger( 'column-reorder', [ oSettings, {
- "iFrom": iFrom,
- "iTo": iTo,
- "aiInvertMapping": aiInvertMapping
- } ] );
- };
- var ColReorder = function( dt, opts )
- {
- var oDTSettings;
- if ( $.fn.dataTable.Api ) {
- oDTSettings = new $.fn.dataTable.Api( dt ).settings()[0];
- }
-
- else if ( dt.fnSettings ) {
-
- oDTSettings = dt.fnSettings();
- }
- else if ( typeof dt === 'string' ) {
-
- if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
- oDTSettings = $(dt).eq(0).dataTable().fnSettings();
- }
- }
- else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
-
- if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
- oDTSettings = $(dt.nodeName).dataTable().fnSettings();
- }
- }
- else if ( dt instanceof jQuery ) {
-
- if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
- oDTSettings = dt.eq(0).dataTable().fnSettings();
- }
- }
- else {
-
- oDTSettings = dt;
- }
-
- if ( oDTSettings._colReorder ) {
- throw "ColReorder already initialised on table #"+oDTSettings.nTable.id;
- }
-
- var camelToHungarian = $.fn.dataTable.camelToHungarian;
- if ( camelToHungarian ) {
- camelToHungarian( ColReorder.defaults, ColReorder.defaults, true );
- camelToHungarian( ColReorder.defaults, opts || {} );
- }
-
-
- this.s = {
-
- "dt": null,
-
- "init": $.extend( true, {}, ColReorder.defaults, opts ),
-
- "fixed": 0,
-
- "fixedRight": 0,
-
- "reorderCallback": null,
-
- "mouse": {
- "startX": -1,
- "startY": -1,
- "offsetX": -1,
- "offsetY": -1,
- "target": -1,
- "targetIndex": -1,
- "fromIndex": -1
- },
-
- "aoTargets": []
- };
-
- this.dom = {
-
- "drag": null,
-
- "pointer": null
- };
-
- this.s.dt = oDTSettings;
- this.s.dt._colReorder = this;
- this._fnConstruct();
-
- oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
- return this;
- };
- ColReorder.prototype = {
-
-
- "fnReset": function ()
- {
- var a = [];
- for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
- {
- a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
- }
- this._fnOrderColumns( a );
- return this;
- },
-
- "fnGetCurrentOrder": function ()
- {
- return this.fnOrder();
- },
-
- "fnOrder": function ( set )
- {
- if ( set === undefined )
- {
- var a = [];
- for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
- {
- a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
- }
- return a;
- }
- this._fnOrderColumns( fnInvertKeyValues( set ) );
- return this;
- },
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Private methods (they are of course public in JS, but recommended as private)
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /**
- * Constructor logic
- * @method _fnConstruct
- * @returns void
- * @private
- */
- "_fnConstruct": function ()
- {
- var that = this;
- var iLen = this.s.dt.aoColumns.length;
- var i;
-
- if ( this.s.init.iFixedColumns )
- {
- this.s.fixed = this.s.init.iFixedColumns;
- }
-
- this.s.fixedRight = this.s.init.iFixedColumnsRight ?
- this.s.init.iFixedColumnsRight :
- 0;
-
- if ( this.s.init.fnReorderCallback )
- {
- this.s.reorderCallback = this.s.init.fnReorderCallback;
- }
-
- for ( i = 0; i < iLen; i++ )
- {
- if ( i > this.s.fixed-1 && i < iLen - this.s.fixedRight )
- {
- this._fnMouseListener( i, this.s.dt.aoColumns[i].nTh );
- }
-
- this.s.dt.aoColumns[i]._ColReorder_iOrigCol = i;
- }
-
- this.s.dt.oApi._fnCallbackReg( this.s.dt, 'aoStateSaveParams', function (oS, oData) {
- that._fnStateSave.call( that, oData );
- }, "ColReorder_State" );
-
- var aiOrder = null;
- if ( this.s.init.aiOrder )
- {
- aiOrder = this.s.init.aiOrder.slice();
- }
-
- if ( this.s.dt.oLoadedState && typeof this.s.dt.oLoadedState.ColReorder != 'undefined' &&
- this.s.dt.oLoadedState.ColReorder.length == this.s.dt.aoColumns.length )
- {
- aiOrder = this.s.dt.oLoadedState.ColReorder;
- }
-
- if ( aiOrder )
- {
-
- if ( !that.s.dt._bInitComplete )
- {
- var bDone = false;
- this.s.dt.aoDrawCallback.push( {
- "fn": function () {
- if ( !that.s.dt._bInitComplete && !bDone )
- {
- bDone = true;
- var resort = fnInvertKeyValues( aiOrder );
- that._fnOrderColumns.call( that, resort );
- }
- },
- "sName": "ColReorder_Pre"
- } );
- }
- else
- {
- var resort = fnInvertKeyValues( aiOrder );
- that._fnOrderColumns.call( that, resort );
- }
- }
- else {
- this._fnSetColumnIndexes();
- }
- },
-
- "_fnOrderColumns": function ( a )
- {
- if ( a.length != this.s.dt.aoColumns.length )
- {
- this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
- "match known number of columns. Skipping." );
- return;
- }
- for ( var i=0, iLen=a.length ; i<iLen ; i++ )
- {
- var currIndex = $.inArray( i, a );
- if ( i != currIndex )
- {
-
- fnArraySwitch( a, currIndex, i );
-
- this.s.dt.oInstance.fnColReorder( currIndex, i );
- }
- }
-
- if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
- {
- this.s.dt.oInstance.fnAdjustColumnSizing( false );
- }
-
- this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
- this._fnSetColumnIndexes();
-
- if ( this.s.reorderCallback !== null )
- {
- this.s.reorderCallback.call( this );
- }
- },
-
- "_fnStateSave": function ( oState )
- {
- var i, iLen, aCopy, iOrigColumn;
- var oSettings = this.s.dt;
- var columns = oSettings.aoColumns;
- oState.ColReorder = [];
-
- if ( oState.aaSorting ) {
-
- for ( i=0 ; i<oState.aaSorting.length ; i++ ) {
- oState.aaSorting[i][0] = columns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
- }
- var aSearchCopy = $.extend( true, [], oState.aoSearchCols );
- for ( i=0, iLen=columns.length ; i<iLen ; i++ )
- {
- iOrigColumn = columns[i]._ColReorder_iOrigCol;
-
- oState.aoSearchCols[ iOrigColumn ] = aSearchCopy[i];
-
- oState.abVisCols[ iOrigColumn ] = columns[i].bVisible;
-
- oState.ColReorder.push( iOrigColumn );
- }
- }
- else if ( oState.order ) {
-
- for ( i=0 ; i<oState.order.length ; i++ ) {
- oState.order[i][0] = columns[ oState.order[i][0] ]._ColReorder_iOrigCol;
- }
- var stateColumnsCopy = $.extend( true, [], oState.columns );
- for ( i=0, iLen=columns.length ; i<iLen ; i++ )
- {
- iOrigColumn = columns[i]._ColReorder_iOrigCol;
-
- oState.columns[ iOrigColumn ] = stateColumnsCopy[i];
-
- oState.ColReorder.push( iOrigColumn );
- }
- }
- },
-
-
- "_fnMouseListener": function ( i, nTh )
- {
- var that = this;
- $(nTh).on( 'mousedown.ColReorder', function (e) {
- e.preventDefault();
- that._fnMouseDown.call( that, e, nTh );
- } );
- },
-
- "_fnMouseDown": function ( e, nTh )
- {
- var that = this;
-
- var target = $(e.target).closest('th, td');
- var offset = target.offset();
- var idx = parseInt( $(nTh).attr('data-column-index'), 10 );
- if ( idx === undefined ) {
- return;
- }
- this.s.mouse.startX = e.pageX;
- this.s.mouse.startY = e.pageY;
- this.s.mouse.offsetX = e.pageX - offset.left;
- this.s.mouse.offsetY = e.pageY - offset.top;
- this.s.mouse.target = this.s.dt.aoColumns[ idx ].nTh;
- this.s.mouse.targetIndex = idx;
- this.s.mouse.fromIndex = idx;
- this._fnRegions();
-
- $(document)
- .on( 'mousemove.ColReorder', function (e) {
- that._fnMouseMove.call( that, e );
- } )
- .on( 'mouseup.ColReorder', function (e) {
- that._fnMouseUp.call( that, e );
- } );
- },
-
- "_fnMouseMove": function ( e )
- {
- var that = this;
- if ( this.dom.drag === null )
- {
-
- if ( Math.pow(
- Math.pow(e.pageX - this.s.mouse.startX, 2) +
- Math.pow(e.pageY - this.s.mouse.startY, 2), 0.5 ) < 5 )
- {
- return;
- }
- this._fnCreateDragNode();
- }
-
- this.dom.drag.css( {
- left: e.pageX - this.s.mouse.offsetX,
- top: e.pageY - this.s.mouse.offsetY
- } );
-
- var bSet = false;
- var lastToIndex = this.s.mouse.toIndex;
- for ( var i=1, iLen=this.s.aoTargets.length ; i<iLen ; i++ )
- {
- if ( e.pageX < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
- {
- this.dom.pointer.css( 'left', this.s.aoTargets[i-1].x );
- this.s.mouse.toIndex = this.s.aoTargets[i-1].to;
- bSet = true;
- break;
- }
- }
-
-
- if ( !bSet )
- {
- this.dom.pointer.css( 'left', this.s.aoTargets[this.s.aoTargets.length-1].x );
- this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
- }
-
- if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
- this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
- this.s.mouse.fromIndex = this.s.mouse.toIndex;
- this._fnRegions();
- }
- },
-
- "_fnMouseUp": function ( e )
- {
- var that = this;
- $(document).off( 'mousemove.ColReorder mouseup.ColReorder' );
- if ( this.dom.drag !== null )
- {
-
- this.dom.drag.remove();
- this.dom.pointer.remove();
- this.dom.drag = null;
- this.dom.pointer = null;
-
- this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
- this._fnSetColumnIndexes();
-
- if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
- {
- this.s.dt.oInstance.fnAdjustColumnSizing( false );
- }
-
- this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
- if ( this.s.reorderCallback !== null )
- {
- this.s.reorderCallback.call( this );
- }
- }
- },
-
- "_fnRegions": function ()
- {
- var aoColumns = this.s.dt.aoColumns;
- this.s.aoTargets.splice( 0, this.s.aoTargets.length );
- this.s.aoTargets.push( {
- "x": $(this.s.dt.nTable).offset().left,
- "to": 0
- } );
- var iToPoint = 0;
- for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
- {
-
- if ( i != this.s.mouse.fromIndex )
- {
- iToPoint++;
- }
- if ( aoColumns[i].bVisible )
- {
- this.s.aoTargets.push( {
- "x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
- "to": iToPoint
- } );
- }
- }
-
- if ( this.s.fixedRight !== 0 )
- {
- this.s.aoTargets.splice( this.s.aoTargets.length - this.s.fixedRight );
- }
-
- if ( this.s.fixed !== 0 )
- {
- this.s.aoTargets.splice( 0, this.s.fixed );
- }
- },
-
- "_fnCreateDragNode": function ()
- {
- var scrolling = this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "";
- var origCell = this.s.dt.aoColumns[ this.s.mouse.targetIndex ].nTh;
- var origTr = origCell.parentNode;
- var origThead = origTr.parentNode;
- var origTable = origThead.parentNode;
- var cloneCell = $(origCell).clone();
-
-
-
- this.dom.drag = $(origTable.cloneNode(false))
- .addClass( 'DTCR_clonedTable' )
- .append(
- $(origThead.cloneNode(false)).append(
- $(origTr.cloneNode(false)).append(
- cloneCell[0]
- )
- )
- )
- .css( {
- position: 'absolute',
- top: 0,
- left: 0,
- width: $(origCell).outerWidth(),
- height: $(origCell).outerHeight()
- } )
- .appendTo( 'body' );
- this.dom.pointer = $('<div></div>')
- .addClass( 'DTCR_pointer' )
- .css( {
- position: 'absolute',
- top: scrolling ?
- $('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top :
- $(this.s.dt.nTable).offset().top,
- height : scrolling ?
- $('div.dataTables_scroll', this.s.dt.nTableWrapper).height() :
- $(this.s.dt.nTable).height()
- } )
- .appendTo( 'body' );
- },
-
- "_fnDestroy": function ()
- {
- var i, iLen;
- for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; i<iLen ; i++ )
- {
- if ( this.s.dt.aoDrawCallback[i].sName === 'ColReorder_Pre' )
- {
- this.s.dt.aoDrawCallback.splice( i, 1 );
- break;
- }
- }
- $(this.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
- $.each( this.s.dt.aoColumns, function (i, column) {
- $(column.nTh).removeAttr('data-column-index');
- } );
- this.s.dt._colReorder = null;
- this.s = null;
- },
-
- "_fnSetColumnIndexes": function ()
- {
- $.each( this.s.dt.aoColumns, function (i, column) {
- $(column.nTh).attr('data-column-index', i);
- } );
- }
- };
- ColReorder.defaults = {
-
- aiOrder: null,
-
- bRealtime: false,
-
- iFixedColumns: 0,
-
- iFixedColumnsRight: 0,
-
- fnReorderCallback: null
- };
- ColReorder.version = "1.1.3";
- $.fn.dataTable.ColReorder = ColReorder;
- $.fn.DataTable.ColReorder = ColReorder;
- if ( typeof $.fn.dataTable == "function" &&
- typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
- $.fn.dataTableExt.fnVersionCheck('1.9.3') )
- {
- $.fn.dataTableExt.aoFeatures.push( {
- "fnInit": function( settings ) {
- var table = settings.oInstance;
- if ( ! settings._colReorder ) {
- var dtInit = settings.oInit;
- var opts = dtInit.colReorder || dtInit.oColReorder || {};
- new ColReorder( settings, opts );
- }
- else {
- table.oApi._fnLog( settings, 1, "ColReorder attempted to initialise twice. Ignoring second" );
- }
- return null;
- },
- "cFeature": "R",
- "sFeature": "ColReorder"
- } );
- }
- else {
- alert( "Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");
- }
- if ( $.fn.dataTable.Api ) {
- $.fn.dataTable.Api.register( 'colReorder.reset()', function () {
- return this.iterator( 'table', function ( ctx ) {
- ctx._colReorder.fnReset();
- } );
- } );
- $.fn.dataTable.Api.register( 'colReorder.order()', function ( set ) {
- if ( set ) {
- return this.iterator( 'table', function ( ctx ) {
- ctx._colReorder.fnOrder( set );
- } );
- }
- return this.context.length ?
- this.context[0]._colReorder.fnOrder() :
- null;
- } );
- }
- return ColReorder;
- }; // /factory
- // Define as an AMD module if possible
- if ( typeof define === 'function' && define.amd ) {
- define( ['jquery', 'datatables'], factory );
- }
- else if ( typeof exports === 'object' ) {
-
- factory( require('jquery'), require('datatables') );
- }
- else if ( jQuery && !jQuery.fn.dataTable.ColReorder ) {
-
- factory( jQuery, jQuery.fn.dataTable );
- }
- })(window, document);
|