Last version of JQuery 1.12 and DataTables Componenent with working

export Excel,CVS,PDF, etc..
This commit is contained in:
Florian HENRY
2016-03-15 11:57:53 +01:00
parent ed9cd71eac
commit 28391a4e4d
31 changed files with 7292 additions and 6174 deletions

View File

@@ -1,11 +1,11 @@
/*! ColReorder 1.1.3
* ©2010-2014 SpryMedia Ltd - datatables.net/license
/*! ColReorder 1.3.1
* ©2010-2015 SpryMedia Ltd - datatables.net/license
*/
/**
* @summary ColReorder
* @description Provide the ability to reorder columns in a DataTable
* @version 1.1.3
* @version 1.3.1
* @file dataTables.colReorder.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
@@ -20,8 +20,34 @@
*
* 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;
}
(function(window, document, undefined) {
if ( ! $ || ! $.fn.dataTable ) {
$ = require('datatables.net')(root, $).$;
}
return factory( $, root, root.document );
};
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document, undefined ) {
'use strict';
var DataTable = $.fn.dataTable;
/**
@@ -89,10 +115,6 @@ function fnDomSwitch( nParent, iFrom, iTo )
}
var factory = function( $, DataTable ) {
"use strict";
/**
* Plug-in for DataTables which will reorder the internal column structure by taking the column
* from one position (iFrom) and insert it into a given point (iTo).
@@ -100,14 +122,15 @@ var factory = function( $, DataTable ) {
* @param object oSettings DataTables settings object - automatically added by DataTables!
* @param int iFrom Take the column to be repositioned from this point
* @param int iTo and insert it into this point
* @param bool drop Indicate if the reorder is the final one (i.e. a drop)
* not a live reorder
* @returns void
*/
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo, drop )
{
var v110 = $.fn.dataTable.Api ? true : false;
var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
var i, iLen, j, jLen, jen, iCols=oSettings.aoColumns.length, nTrs, oCol;
var attrMap = function ( obj, prop, mapping ) {
if ( ! obj[ prop ] ) {
if ( ! obj[ prop ] || typeof obj[ prop ] === 'function' ) {
return;
}
@@ -180,17 +203,13 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
}
// Update the column indexes
if ( v110 ) {
oCol.idx = aiInvertMapping[ oCol.idx ];
}
oCol.idx = aiInvertMapping[ oCol.idx ];
}
if ( v110 ) {
// Update 1.10 optimised sort class removal variable
$.each( oSettings.aLastSort, function (i, val) {
oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
} );
}
// Update 1.10 optimised sort class removal variable
$.each( oSettings.aLastSort, function (i, val) {
oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
} );
/* Update the Get and Set functions for each column */
for ( i=0, iLen=iCols ; i<iLen ; i++ )
@@ -199,9 +218,6 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
if ( typeof oCol.mData == 'number' ) {
oCol.mData = aiInvertMapping[ oCol.mData ];
// regenerate the get / set functions
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
}
else if ( $.isPlainObject( oCol.mData ) ) {
// HTML5 data sourced
@@ -209,13 +225,9 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
attrMap( oCol.mData, 'filter', aiInvertMapping );
attrMap( oCol.mData, 'sort', aiInvertMapping );
attrMap( oCol.mData, 'type', aiInvertMapping );
// regenerate the get / set functions
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
}
}
/*
* Move the DOM elements
*/
@@ -268,6 +280,11 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
/* Columns */
fnArraySwitch( oSettings.aoColumns, iFrom, iTo );
// regenerate the get / set functions
for ( i=0, iLen=iCols ; i<iLen ; i++ ) {
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
}
/* Search columns */
fnArraySwitch( oSettings.aoPreSearchCols, iFrom, iTo );
@@ -275,26 +292,25 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
{
var data = oSettings.aoData[i];
var cells = data.anCells;
if ( v110 ) {
// DataTables 1.10+
if ( data.anCells ) {
fnArraySwitch( data.anCells, iFrom, iTo );
}
if ( cells ) {
fnArraySwitch( cells, iFrom, iTo );
// For DOM sourced data, the invalidate will reread the cell into
// the data array, but for data sources as an array, they need to
// be flipped
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
fnArraySwitch( data._aData, iFrom, iTo );
// Longer term, should this be moved into the DataTables' invalidate
// methods?
for ( j=0, jen=cells.length ; j<jen ; j++ ) {
if ( cells[j] && cells[j]._DT_CellIndex ) {
cells[j]._DT_CellIndex.column = j;
}
}
}
else {
// DataTables 1.9-
if ( $.isArray( data._aData ) ) {
fnArraySwitch( data._aData, iFrom, iTo );
}
fnArraySwitch( data._anHidden, iFrom, iTo );
// For DOM sourced data, the invalidate will reread the cell into
// the data array, but for data sources as an array, they need to
// be flipped
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
fnArraySwitch( data._aData, iFrom, iTo );
}
}
@@ -312,11 +328,9 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
}
}
// In 1.10 we need to invalidate row cached data for sorting, filtering etc
if ( v110 ) {
var api = new $.fn.dataTable.Api( oSettings );
api.rows().invalidate();
}
// Invalidate row cached data for sorting, filtering etc
var api = new $.fn.dataTable.Api( oSettings );
api.rows().invalidate();
/*
* Update DataTables' event handlers
@@ -331,10 +345,16 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
/* Fire an event so other plug-ins can update */
$(oSettings.oInstance).trigger( 'column-reorder', [ oSettings, {
"iFrom": iFrom,
"iTo": iTo,
"aiInvertMapping": aiInvertMapping
$(oSettings.oInstance).trigger( 'column-reorder.dt', [ oSettings, {
from: iFrom,
to: iTo,
mapping: aiInvertMapping,
drop: drop,
// Old style parameters for compatibility
iFrom: iFrom,
iTo: iTo,
aiInvertMapping: aiInvertMapping
} ] );
};
@@ -348,42 +368,16 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
*/
var ColReorder = function( dt, opts )
{
var oDTSettings;
if ( $.fn.dataTable.Api ) {
oDTSettings = new $.fn.dataTable.Api( dt ).settings()[0];
}
// 1.9 compatibility
else if ( dt.fnSettings ) {
// DataTables object, convert to the settings object
oDTSettings = dt.fnSettings();
}
else if ( typeof dt === 'string' ) {
// jQuery selector
if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
oDTSettings = $(dt).eq(0).dataTable().fnSettings();
}
}
else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
// Table node
if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
oDTSettings = $(dt.nodeName).dataTable().fnSettings();
}
}
else if ( dt instanceof jQuery ) {
// jQuery object
if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
oDTSettings = dt.eq(0).dataTable().fnSettings();
}
}
else {
// DataTables settings object
oDTSettings = dt;
}
var settings = new $.fn.dataTable.Api( dt ).settings()[0];
// Ensure that we can't initialise on the same table twice
if ( oDTSettings._colReorder ) {
throw "ColReorder already initialised on table #"+oDTSettings.nTable.id;
if ( settings._colReorder ) {
return settings._colReorder;
}
// Allow the options to be a boolean for defaults
if ( opts === true ) {
opts = {};
}
// Convert from camelCase to Hungarian, just as DataTables does
@@ -491,19 +485,16 @@ var ColReorder = function( dt, opts )
/* Constructor logic */
this.s.dt = oDTSettings;
this.s.dt = settings;
this.s.dt._colReorder = this;
this._fnConstruct();
/* Add destroy callback */
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
return this;
};
ColReorder.prototype = {
$.extend( ColReorder.prototype, {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public methods
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -527,13 +518,7 @@ 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 );
this._fnOrderColumns( this.fnOrder() );
return this;
},
@@ -585,24 +570,74 @@ ColReorder.prototype = {
* $.fn.dataTable.ColReorder( '#example' ).fnOrder().reverse()
* );
*/
"fnOrder": function ( set )
"fnOrder": function ( set, original )
{
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 );
var a = [], i, ien, j, jen;
var columns = this.s.dt.aoColumns;
if ( set === undefined ){
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
a.push( columns[i]._ColReorder_iOrigCol );
}
return a;
}
// The order given is based on the original indexes, rather than the
// existing ones, so we need to translate from the original to current
// before then doing the order
if ( original ) {
var order = this.fnOrder();
for ( i=0, ien=set.length ; i<ien ; i++ ) {
a.push( $.inArray( set[i], order ) );
}
set = a;
}
this._fnOrderColumns( fnInvertKeyValues( set ) );
return this;
},
/**
* Convert from the original column index, to the original
*
* @param {int|array} idx Index(es) to convert
* @param {string} dir Transpose direction - `fromOriginal` / `toCurrent`
* or `'toOriginal` / `fromCurrent`
* @return {int|array} Converted values
*/
fnTranspose: function ( idx, dir )
{
if ( ! dir ) {
dir = 'toCurrent';
}
var order = this.fnOrder();
var columns = this.s.dt.aoColumns;
if ( dir === 'toCurrent' ) {
// Given an original index, want the current
return ! $.isArray( idx ) ?
$.inArray( idx, order ) :
$.map( idx, function ( index ) {
return $.inArray( index, order );
} );
}
else {
// Given a current index, want the original
return ! $.isArray( idx ) ?
columns[idx]._ColReorder_iOrigCol :
$.map( idx, function ( index ) {
return columns[index]._ColReorder_iOrigCol;
} );
}
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Private methods (they are of course public in JS, but recommended as private)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -617,6 +652,7 @@ ColReorder.prototype = {
{
var that = this;
var iLen = this.s.dt.aoColumns.length;
var table = this.s.dt.nTable;
var i;
/* Columns discounted from reordering - counting left to right */
@@ -625,6 +661,11 @@ ColReorder.prototype = {
this.s.fixed = this.s.init.iFixedColumns;
}
if ( this.s.init.iFixedColumnsLeft )
{
this.s.fixed = this.s.init.iFixedColumnsLeft;
}
/* Columns discounted from reordering - counting right to left */
this.s.fixedRight = this.s.init.iFixedColumnsRight ?
this.s.init.iFixedColumnsRight :
@@ -676,16 +717,13 @@ ColReorder.prototype = {
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"
$(table).on( 'draw.dt.colReorder', function () {
if ( !that.s.dt._bInitComplete && !bDone )
{
bDone = true;
var resort = fnInvertKeyValues( aiOrder );
that._fnOrderColumns.call( that, resort );
}
} );
}
else
@@ -697,6 +735,19 @@ ColReorder.prototype = {
else {
this._fnSetColumnIndexes();
}
// Destroy clean up
$(table).on( 'destroy.dt.colReorder', function () {
$(table).off( 'destroy.dt.colReorder draw.dt.colReorder' );
$(that.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
$.each( that.s.dt.aoColumns, function (i, column) {
$(column.nTh).removeAttr('data-column-index');
} );
that.s.dt._colReorder = null;
that.s = null;
} );
},
@@ -709,6 +760,8 @@ ColReorder.prototype = {
*/
"_fnOrderColumns": function ( a )
{
var changed = false;
if ( a.length != this.s.dt.aoColumns.length )
{
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
@@ -725,10 +778,19 @@ ColReorder.prototype = {
fnArraySwitch( a, currIndex, i );
/* Do the column reorder in the table */
this.s.dt.oInstance.fnColReorder( currIndex, i );
this.s.dt.oInstance.fnColReorder( currIndex, i, true );
changed = true;
}
}
this._fnSetColumnIndexes();
// Has anything actually changed? If not, then nothing else to do
if ( ! changed ) {
return;
}
/* When scrolling we need to recalculate the column sizes to allow for the shift */
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
{
@@ -737,8 +799,6 @@ ColReorder.prototype = {
/* Save the state */
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
this._fnSetColumnIndexes();
if ( this.s.reorderCallback !== null )
{
@@ -930,7 +990,7 @@ ColReorder.prototype = {
// Perform reordering if realtime updating is on and the column has moved
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.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, false );
this.s.mouse.fromIndex = this.s.mouse.toIndex;
this._fnRegions();
}
@@ -959,7 +1019,7 @@ ColReorder.prototype = {
this.dom.pointer = null;
/* Actually do the reorder */
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, true );
this._fnSetColumnIndexes();
/* When scrolling we need to recalculate the column sizes to allow for the shift */
@@ -998,10 +1058,12 @@ ColReorder.prototype = {
} );
var iToPoint = 0;
var total = $(aoColumns[0].nTh).offset().left; // Offset of the first column
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
{
/* For the column / header in question, we want it's position to remain the same if the
* position is just to it's immediate left or right, so we only incremement the counter for
* position is just to it's immediate left or right, so we only increment the counter for
* other columns
*/
if ( i != this.s.mouse.fromIndex )
@@ -1009,10 +1071,12 @@ ColReorder.prototype = {
iToPoint++;
}
if ( aoColumns[i].bVisible )
if ( aoColumns[i].bVisible && aoColumns[i].nTh.style.display !=='none' )
{
total += $(aoColumns[i].nTh).outerWidth();
this.s.aoTargets.push( {
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
"x": total,
"to": iToPoint
} );
}
@@ -1084,35 +1148,6 @@ ColReorder.prototype = {
.appendTo( 'body' );
},
/**
* Clean up ColReorder memory references and event handlers
* @method _fnDestroy
* @returns void
* @private
*/
"_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;
},
/**
* Add a data attribute to the column headers, so we know the index of
@@ -1126,7 +1161,7 @@ ColReorder.prototype = {
$(column.nTh).attr('data-column-index', i);
} );
}
};
} );
@@ -1150,22 +1185,6 @@ ColReorder.defaults = {
* @type array
* @default null
* @static
* @example
* // Using the `oColReorder` option in the DataTables options object
* $('#example').dataTable( {
* "sDom": 'Rlfrtip',
* "oColReorder": {
* "aiOrder": [ 4, 3, 2, 1, 0 ]
* }
* } );
*
* @example
* // Using `new` constructor
* $('#example').dataTable()
*
* new $.fn.dataTable.ColReorder( '#example', {
* "aiOrder": [ 4, 3, 2, 1, 0 ]
* } );
*/
aiOrder: null,
@@ -1178,24 +1197,8 @@ ColReorder.defaults = {
* @type boolean
* @default false
* @static
* @example
* // Using the `oColReorder` option in the DataTables options object
* $('#example').dataTable( {
* "sDom": 'Rlfrtip',
* "oColReorder": {
* "bRealtime": true
* }
* } );
*
* @example
* // Using `new` constructor
* $('#example').dataTable()
*
* new $.fn.dataTable.ColReorder( '#example', {
* "bRealtime": true
* } );
*/
bRealtime: false,
bRealtime: true,
/**
* Indicate how many columns should be fixed in position (counting from the
@@ -1203,74 +1206,23 @@ ColReorder.defaults = {
* @type int
* @default 0
* @static
* @example
* // Using the `oColReorder` option in the DataTables options object
* $('#example').dataTable( {
* "sDom": 'Rlfrtip',
* "oColReorder": {
* "iFixedColumns": 1
* }
* } );
*
* @example
* // Using `new` constructor
* $('#example').dataTable()
*
* new $.fn.dataTable.ColReorder( '#example', {
* "iFixedColumns": 1
* } );
*/
iFixedColumns: 0,
iFixedColumnsLeft: 0,
/**
* As `iFixedColumnsRight` but counting from the right.
* @type int
* @default 0
* @static
* @example
* // Using the `oColReorder` option in the DataTables options object
* $('#example').dataTable( {
* "sDom": 'Rlfrtip',
* "oColReorder": {
* "iFixedColumnsRight": 1
* }
* } );
*
* @example
* // Using `new` constructor
* $('#example').dataTable()
*
* new $.fn.dataTable.ColReorder( '#example', {
* "iFixedColumnsRight": 1
* } );
*/
iFixedColumnsRight: 0,
/**
* Callback function that is fired when columns are reordered
* Callback function that is fired when columns are reordered. The `column-
* reorder` event is preferred over this callback
* @type function():void
* @default null
* @static
* @example
* // Using the `oColReorder` option in the DataTables options object
* $('#example').dataTable( {
* "sDom": 'Rlfrtip',
* "oColReorder": {
* "fnReorderCallback": function () {
* alert( 'Columns reordered' );
* }
* }
* } );
*
* @example
* // Using `new` constructor
* $('#example').dataTable()
*
* new $.fn.dataTable.ColReorder( '#example', {
* "fnReorderCallback": function () {
* alert( 'Columns reordered' );
* }
* } );
*/
fnReorderCallback: null
};
@@ -1287,7 +1239,7 @@ ColReorder.defaults = {
* @type String
* @default As code
*/
ColReorder.version = "1.1.3";
ColReorder.version = "1.3.1";
@@ -1303,7 +1255,7 @@ $.fn.DataTable.ColReorder = ColReorder;
// Register a new feature with DataTables
if ( typeof $.fn.dataTable == "function" &&
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
$.fn.dataTableExt.fnVersionCheck('1.9.3') )
$.fn.dataTableExt.fnVersionCheck('1.10.8') )
{
$.fn.dataTableExt.aoFeatures.push( {
"fnInit": function( settings ) {
@@ -1326,47 +1278,55 @@ if ( typeof $.fn.dataTable == "function" &&
} );
}
else {
alert( "Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");
alert( "Warning: ColReorder requires DataTables 1.10.8 or greater - www.datatables.net/download");
}
// Attach a listener to the document which listens for DataTables initialisation
// events so we can automatically initialise
$(document).on( 'preInit.dt.colReorder', function (e, settings) {
if ( e.namespace !== 'dt' ) {
return;
}
var init = settings.oInit.colReorder;
var defaults = DataTable.defaults.colReorder;
if ( init || defaults ) {
var opts = $.extend( {}, init, defaults );
if ( init !== false ) {
new ColReorder( settings, opts );
}
}
} );
// API augmentation
if ( $.fn.dataTable.Api ) {
$.fn.dataTable.Api.register( 'colReorder.reset()', function () {
$.fn.dataTable.Api.register( 'colReorder.reset()', function () {
return this.iterator( 'table', function ( ctx ) {
ctx._colReorder.fnReset();
} );
} );
$.fn.dataTable.Api.register( 'colReorder.order()', function ( set, original ) {
if ( set ) {
return this.iterator( 'table', function ( ctx ) {
ctx._colReorder.fnReset();
ctx._colReorder.fnOrder( set, original );
} );
} );
}
$.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;
} );
$.fn.dataTable.Api.register( 'colReorder.transpose()', function ( idx, dir ) {
return this.context.length && this.context[0]._colReorder ?
this.context[0]._colReorder.fnTranspose( idx, dir ) :
idx;
} );
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' ) {
// Node/CommonJS
factory( require('jquery'), require('datatables') );
}
else if ( jQuery && !jQuery.fn.dataTable.ColReorder ) {
// Otherwise simply initialise as normal, stopping multiple evaluation
factory( jQuery, jQuery.fn.dataTable );
}
})(window, document);
}));

View File

@@ -1,26 +1,27 @@
/*!
ColReorder 1.1.3
©2010-2014 SpryMedia Ltd - datatables.net/license
ColReorder 1.3.1
©2010-2015 SpryMedia Ltd - datatables.net/license
*/
(function(o,r,s){function p(d){for(var f=[],a=0,b=d.length;a<b;a++)f[d[a]]=a;return f}function l(d,f,a){f=d.splice(f,1)[0];d.splice(a,0,f)}function q(d,f,a){for(var b=[],e=0,h=d.childNodes.length;e<h;e++)1==d.childNodes[e].nodeType&&b.push(d.childNodes[e]);f=b[f];null!==a?d.insertBefore(f,b[a]):d.appendChild(f)}o=function(d){d.fn.dataTableExt.oApi.fnColReorder=function(a,b,e){var h=d.fn.dataTable.Api?!0:!1,c,g,f,m,n=a.aoColumns.length,i,j;i=function(a,b,c){if(a[b]){var e=a[b].split("."),d=e.shift();
isNaN(1*d)||(a[b]=c[1*d]+"."+e.join("."))}};if(b!=e)if(0>b||b>=n)this.oApi._fnLog(a,1,"ColReorder 'from' index is out of bounds: "+b);else if(0>e||e>=n)this.oApi._fnLog(a,1,"ColReorder 'to' index is out of bounds: "+e);else{f=[];c=0;for(g=n;c<g;c++)f[c]=c;l(f,b,e);var k=p(f);c=0;for(g=a.aaSorting.length;c<g;c++)a.aaSorting[c][0]=k[a.aaSorting[c][0]];if(null!==a.aaSortingFixed){c=0;for(g=a.aaSortingFixed.length;c<g;c++)a.aaSortingFixed[c][0]=k[a.aaSortingFixed[c][0]]}c=0;for(g=n;c<g;c++){j=a.aoColumns[c];
f=0;for(m=j.aDataSort.length;f<m;f++)j.aDataSort[f]=k[j.aDataSort[f]];h&&(j.idx=k[j.idx])}h&&d.each(a.aLastSort,function(b,c){a.aLastSort[b].src=k[c.src]});c=0;for(g=n;c<g;c++)j=a.aoColumns[c],"number"==typeof j.mData?(j.mData=k[j.mData],a.oApi._fnColumnOptions(a,c,{})):d.isPlainObject(j.mData)&&(i(j.mData,"_",k),i(j.mData,"filter",k),i(j.mData,"sort",k),i(j.mData,"type",k),a.oApi._fnColumnOptions(a,c,{}));if(a.aoColumns[b].bVisible){f=this.oApi._fnColumnIndexToVisible(a,b);m=null;for(c=e<b?e:e+1;null===
m&&c<n;)m=this.oApi._fnColumnIndexToVisible(a,c),c++;i=a.nTHead.getElementsByTagName("tr");c=0;for(g=i.length;c<g;c++)q(i[c],f,m);if(null!==a.nTFoot){i=a.nTFoot.getElementsByTagName("tr");c=0;for(g=i.length;c<g;c++)q(i[c],f,m)}c=0;for(g=a.aoData.length;c<g;c++)null!==a.aoData[c].nTr&&q(a.aoData[c].nTr,f,m)}l(a.aoColumns,b,e);l(a.aoPreSearchCols,b,e);c=0;for(g=a.aoData.length;c<g;c++)i=a.aoData[c],h?(i.anCells&&l(i.anCells,b,e),"dom"!==i.src&&d.isArray(i._aData)&&l(i._aData,b,e)):(d.isArray(i._aData)&&
l(i._aData,b,e),l(i._anHidden,b,e));c=0;for(g=a.aoHeader.length;c<g;c++)l(a.aoHeader[c],b,e);if(null!==a.aoFooter){c=0;for(g=a.aoFooter.length;c<g;c++)l(a.aoFooter[c],b,e)}h&&(new d.fn.dataTable.Api(a)).rows().invalidate();c=0;for(g=n;c<g;c++)d(a.aoColumns[c].nTh).off("click.DT"),this.oApi._fnSortAttachListener(a,a.aoColumns[c].nTh,c);d(a.oInstance).trigger("column-reorder",[a,{iFrom:b,iTo:e,aiInvertMapping:k}])}};var f=function(a,b){var e;d.fn.dataTable.Api?e=(new d.fn.dataTable.Api(a)).settings()[0]:
a.fnSettings?e=a.fnSettings():"string"===typeof a?d.fn.dataTable.fnIsDataTable(d(a)[0])&&(e=d(a).eq(0).dataTable().fnSettings()):a.nodeName&&"table"===a.nodeName.toLowerCase()?d.fn.dataTable.fnIsDataTable(a.nodeName)&&(e=d(a.nodeName).dataTable().fnSettings()):a instanceof jQuery?d.fn.dataTable.fnIsDataTable(a[0])&&(e=a.eq(0).dataTable().fnSettings()):e=a;if(e._colReorder)throw"ColReorder already initialised on table #"+e.nTable.id;var h=d.fn.dataTable.camelToHungarian;h&&(h(f.defaults,f.defaults,
!0),h(f.defaults,b||{}));this.s={dt:null,init:d.extend(!0,{},f.defaults,b),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=e;this.s.dt._colReorder=this;this._fnConstruct();e.oApi._fnCallbackReg(e,"aoDestroyCallback",d.proxy(this._fnDestroy,this),"ColReorder");return this};f.prototype={fnReset:function(){for(var a=[],b=0,e=this.s.dt.aoColumns.length;b<e;b++)a.push(this.s.dt.aoColumns[b]._ColReorder_iOrigCol);
this._fnOrderColumns(a);return this},fnGetCurrentOrder:function(){return this.fnOrder()},fnOrder:function(a){if(a===s){for(var a=[],b=0,e=this.s.dt.aoColumns.length;b<e;b++)a.push(this.s.dt.aoColumns[b]._ColReorder_iOrigCol);return a}this._fnOrderColumns(p(a));return this},_fnConstruct:function(){var a=this,b=this.s.dt.aoColumns.length,e;this.s.init.iFixedColumns&&(this.s.fixed=this.s.init.iFixedColumns);this.s.fixedRight=this.s.init.iFixedColumnsRight?this.s.init.iFixedColumnsRight:0;this.s.init.fnReorderCallback&&
(this.s.reorderCallback=this.s.init.fnReorderCallback);for(e=0;e<b;e++)e>this.s.fixed-1&&e<b-this.s.fixedRight&&this._fnMouseListener(e,this.s.dt.aoColumns[e].nTh),this.s.dt.aoColumns[e]._ColReorder_iOrigCol=e;this.s.dt.oApi._fnCallbackReg(this.s.dt,"aoStateSaveParams",function(b,c){a._fnStateSave.call(a,c)},"ColReorder_State");var d=null;this.s.init.aiOrder&&(d=this.s.init.aiOrder.slice());this.s.dt.oLoadedState&&("undefined"!=typeof this.s.dt.oLoadedState.ColReorder&&this.s.dt.oLoadedState.ColReorder.length==
this.s.dt.aoColumns.length)&&(d=this.s.dt.oLoadedState.ColReorder);if(d)if(a.s.dt._bInitComplete)b=p(d),a._fnOrderColumns.call(a,b);else{var c=!1;this.s.dt.aoDrawCallback.push({fn:function(){if(!a.s.dt._bInitComplete&&!c){c=true;var b=p(d);a._fnOrderColumns.call(a,b)}},sName:"ColReorder_Pre"})}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.");
else{for(var b=0,e=a.length;b<e;b++){var h=d.inArray(b,a);b!=h&&(l(a,h,b),this.s.dt.oInstance.fnColReorder(h,b))}(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1);this.s.dt.oInstance.oApi._fnSaveState(this.s.dt);this._fnSetColumnIndexes();null!==this.s.reorderCallback&&this.s.reorderCallback.call(this)}},_fnStateSave:function(a){var b,e,h,c=this.s.dt.aoColumns;a.ColReorder=[];if(a.aaSorting){for(b=0;b<a.aaSorting.length;b++)a.aaSorting[b][0]=c[a.aaSorting[b][0]]._ColReorder_iOrigCol;
var f=d.extend(!0,[],a.aoSearchCols);b=0;for(e=c.length;b<e;b++)h=c[b]._ColReorder_iOrigCol,a.aoSearchCols[h]=f[b],a.abVisCols[h]=c[b].bVisible,a.ColReorder.push(h)}else if(a.order){for(b=0;b<a.order.length;b++)a.order[b][0]=c[a.order[b][0]]._ColReorder_iOrigCol;f=d.extend(!0,[],a.columns);b=0;for(e=c.length;b<e;b++)h=c[b]._ColReorder_iOrigCol,a.columns[h]=f[b],a.ColReorder.push(h)}},_fnMouseListener:function(a,b){var e=this;d(b).on("mousedown.ColReorder",function(a){a.preventDefault();e._fnMouseDown.call(e,
a,b)})},_fnMouseDown:function(a,b){var e=this,f=d(a.target).closest("th, td").offset(),c=parseInt(d(b).attr("data-column-index"),10);c!==s&&(this.s.mouse.startX=a.pageX,this.s.mouse.startY=a.pageY,this.s.mouse.offsetX=a.pageX-f.left,this.s.mouse.offsetY=a.pageY-f.top,this.s.mouse.target=this.s.dt.aoColumns[c].nTh,this.s.mouse.targetIndex=c,this.s.mouse.fromIndex=c,this._fnRegions(),d(r).on("mousemove.ColReorder",function(a){e._fnMouseMove.call(e,a)}).on("mouseup.ColReorder",function(a){e._fnMouseUp.call(e,
a)}))},_fnMouseMove:function(a){if(null===this.dom.drag){if(5>Math.pow(Math.pow(a.pageX-this.s.mouse.startX,2)+Math.pow(a.pageY-this.s.mouse.startY,2),0.5))return;this._fnCreateDragNode()}this.dom.drag.css({left:a.pageX-this.s.mouse.offsetX,top:a.pageY-this.s.mouse.offsetY});for(var b=!1,e=this.s.mouse.toIndex,d=1,c=this.s.aoTargets.length;d<c;d++)if(a.pageX<this.s.aoTargets[d-1].x+(this.s.aoTargets[d].x-this.s.aoTargets[d-1].x)/2){this.dom.pointer.css("left",this.s.aoTargets[d-1].x);this.s.mouse.toIndex=
this.s.aoTargets[d-1].to;b=!0;break}b||(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);this.s.init.bRealtime&&e!==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(){d(r).off("mousemove.ColReorder mouseup.ColReorder");null!==this.dom.drag&&(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(),(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))},_fnRegions:function(){var a=this.s.dt.aoColumns;this.s.aoTargets.splice(0,this.s.aoTargets.length);this.s.aoTargets.push({x:d(this.s.dt.nTable).offset().left,
to:0});for(var b=0,e=0,f=a.length;e<f;e++)e!=this.s.mouse.fromIndex&&b++,a[e].bVisible&&this.s.aoTargets.push({x:d(a[e].nTh).offset().left+d(a[e].nTh).outerWidth(),to:b});0!==this.s.fixedRight&&this.s.aoTargets.splice(this.s.aoTargets.length-this.s.fixedRight);0!==this.s.fixed&&this.s.aoTargets.splice(0,this.s.fixed)},_fnCreateDragNode:function(){var a=""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY,b=this.s.dt.aoColumns[this.s.mouse.targetIndex].nTh,e=b.parentNode,f=e.parentNode,c=f.parentNode,
g=d(b).clone();this.dom.drag=d(c.cloneNode(!1)).addClass("DTCR_clonedTable").append(d(f.cloneNode(!1)).append(d(e.cloneNode(!1)).append(g[0]))).css({position:"absolute",top:0,left:0,width:d(b).outerWidth(),height:d(b).outerHeight()}).appendTo("body");this.dom.pointer=d("<div></div>").addClass("DTCR_pointer").css({position:"absolute",top:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).offset().top:d(this.s.dt.nTable).offset().top,height:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).height():
d(this.s.dt.nTable).height()}).appendTo("body")},_fnDestroy:function(){var a,b;a=0;for(b=this.s.dt.aoDrawCallback.length;a<b;a++)if("ColReorder_Pre"===this.s.dt.aoDrawCallback[a].sName){this.s.dt.aoDrawCallback.splice(a,1);break}d(this.s.dt.nTHead).find("*").off(".ColReorder");d.each(this.s.dt.aoColumns,function(a,b){d(b.nTh).removeAttr("data-column-index")});this.s=this.s.dt._colReorder=null},_fnSetColumnIndexes:function(){d.each(this.s.dt.aoColumns,function(a,b){d(b.nTh).attr("data-column-index",
a)})}};f.defaults={aiOrder:null,bRealtime:!1,iFixedColumns:0,iFixedColumnsRight:0,fnReorderCallback:null};f.version="1.1.3";d.fn.dataTable.ColReorder=f;d.fn.DataTable.ColReorder=f;"function"==typeof d.fn.dataTable&&"function"==typeof d.fn.dataTableExt.fnVersionCheck&&d.fn.dataTableExt.fnVersionCheck("1.9.3")?d.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var b=a.oInstance;a._colReorder?b.oApi._fnLog(a,1,"ColReorder attempted to initialise twice. Ignoring second"):(b=a.oInit,new f(a,b.colReorder||
b.oColReorder||{}));return null},cFeature:"R",sFeature:"ColReorder"}):alert("Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");d.fn.dataTable.Api&&(d.fn.dataTable.Api.register("colReorder.reset()",function(){return this.iterator("table",function(a){a._colReorder.fnReset()})}),d.fn.dataTable.Api.register("colReorder.order()",function(a){return a?this.iterator("table",function(b){b._colReorder.fnOrder(a)}):this.context.length?this.context[0]._colReorder.fnOrder():
null}));return f};"function"===typeof define&&define.amd?define(["jquery","datatables"],o):"object"===typeof exports?o(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.ColReorder&&o(jQuery,jQuery.fn.dataTable)})(window,document);
(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(n){return f(n,window,document)}):"object"===typeof exports?module.exports=function(n,k){n||(n=window);if(!k||!k.fn.dataTable)k=require("datatables.net")(n,k).$;return f(k,n,n.document)}:f(jQuery,window,document)})(function(f,n,k,r){function p(a){for(var c=[],d=0,e=a.length;d<e;d++)c[a[d]]=d;return c}function o(a,c,d){c=a.splice(c,1)[0];a.splice(d,0,c)}function q(a,c,d){for(var e=[],b=0,f=a.childNodes.length;b<
f;b++)1==a.childNodes[b].nodeType&&e.push(a.childNodes[b]);c=e[c];null!==d?a.insertBefore(c,e[d]):a.appendChild(c)}var s=f.fn.dataTable;f.fn.dataTableExt.oApi.fnColReorder=function(a,c,d,e){var b,g,i,l,h,k=a.aoColumns.length,j;h=function(a,b,c){if(a[b]&&"function"!==typeof a[b]){var d=a[b].split("."),e=d.shift();isNaN(1*e)||(a[b]=c[1*e]+"."+d.join("."))}};if(c!=d)if(0>c||c>=k)this.oApi._fnLog(a,1,"ColReorder 'from' index is out of bounds: "+c);else if(0>d||d>=k)this.oApi._fnLog(a,1,"ColReorder 'to' index is out of bounds: "+
d);else{i=[];b=0;for(g=k;b<g;b++)i[b]=b;o(i,c,d);var m=p(i);b=0;for(g=a.aaSorting.length;b<g;b++)a.aaSorting[b][0]=m[a.aaSorting[b][0]];if(null!==a.aaSortingFixed){b=0;for(g=a.aaSortingFixed.length;b<g;b++)a.aaSortingFixed[b][0]=m[a.aaSortingFixed[b][0]]}b=0;for(g=k;b<g;b++){j=a.aoColumns[b];i=0;for(l=j.aDataSort.length;i<l;i++)j.aDataSort[i]=m[j.aDataSort[i]];j.idx=m[j.idx]}f.each(a.aLastSort,function(b,c){a.aLastSort[b].src=m[c.src]});b=0;for(g=k;b<g;b++)j=a.aoColumns[b],"number"==typeof j.mData?
j.mData=m[j.mData]:f.isPlainObject(j.mData)&&(h(j.mData,"_",m),h(j.mData,"filter",m),h(j.mData,"sort",m),h(j.mData,"type",m));if(a.aoColumns[c].bVisible){h=this.oApi._fnColumnIndexToVisible(a,c);l=null;for(b=d<c?d:d+1;null===l&&b<k;)l=this.oApi._fnColumnIndexToVisible(a,b),b++;i=a.nTHead.getElementsByTagName("tr");b=0;for(g=i.length;b<g;b++)q(i[b],h,l);if(null!==a.nTFoot){i=a.nTFoot.getElementsByTagName("tr");b=0;for(g=i.length;b<g;b++)q(i[b],h,l)}b=0;for(g=a.aoData.length;b<g;b++)null!==a.aoData[b].nTr&&
q(a.aoData[b].nTr,h,l)}o(a.aoColumns,c,d);b=0;for(g=k;b<g;b++)a.oApi._fnColumnOptions(a,b,{});o(a.aoPreSearchCols,c,d);b=0;for(g=a.aoData.length;b<g;b++){l=a.aoData[b];if(j=l.anCells){o(j,c,d);i=0;for(h=j.length;i<h;i++)j[i]&&j[i]._DT_CellIndex&&(j[i]._DT_CellIndex.column=i)}"dom"!==l.src&&f.isArray(l._aData)&&o(l._aData,c,d)}b=0;for(g=a.aoHeader.length;b<g;b++)o(a.aoHeader[b],c,d);if(null!==a.aoFooter){b=0;for(g=a.aoFooter.length;b<g;b++)o(a.aoFooter[b],c,d)}(new f.fn.dataTable.Api(a)).rows().invalidate();
b=0;for(g=k;b<g;b++)f(a.aoColumns[b].nTh).off("click.DT"),this.oApi._fnSortAttachListener(a,a.aoColumns[b].nTh,b);f(a.oInstance).trigger("column-reorder.dt",[a,{from:c,to:d,mapping:m,drop:e,iFrom:c,iTo:d,aiInvertMapping:m}])}};var h=function(a,c){var d=(new f.fn.dataTable.Api(a)).settings()[0];if(d._colReorder)return d._colReorder;!0===c&&(c={});var e=f.fn.dataTable.camelToHungarian;e&&(e(h.defaults,h.defaults,!0),e(h.defaults,c||{}));this.s={dt:null,init:f.extend(!0,{},h.defaults,c),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=d;this.s.dt._colReorder=this;this._fnConstruct();return this};f.extend(h.prototype,{fnReset:function(){this._fnOrderColumns(this.fnOrder());return this},fnGetCurrentOrder:function(){return this.fnOrder()},fnOrder:function(a,c){var d=[],e,b,g=this.s.dt.aoColumns;if(a===r){e=0;for(b=g.length;e<b;e++)d.push(g[e]._ColReorder_iOrigCol);return d}if(c){g=
this.fnOrder();e=0;for(b=a.length;e<b;e++)d.push(f.inArray(a[e],g));a=d}this._fnOrderColumns(p(a));return this},fnTranspose:function(a,c){c||(c="toCurrent");var d=this.fnOrder(),e=this.s.dt.aoColumns;return"toCurrent"===c?!f.isArray(a)?f.inArray(a,d):f.map(a,function(a){return f.inArray(a,d)}):!f.isArray(a)?e[a]._ColReorder_iOrigCol:f.map(a,function(a){return e[a]._ColReorder_iOrigCol})},_fnConstruct:function(){var a=this,c=this.s.dt.aoColumns.length,d=this.s.dt.nTable,e;this.s.init.iFixedColumns&&
(this.s.fixed=this.s.init.iFixedColumns);this.s.init.iFixedColumnsLeft&&(this.s.fixed=this.s.init.iFixedColumnsLeft);this.s.fixedRight=this.s.init.iFixedColumnsRight?this.s.init.iFixedColumnsRight:0;this.s.init.fnReorderCallback&&(this.s.reorderCallback=this.s.init.fnReorderCallback);for(e=0;e<c;e++)e>this.s.fixed-1&&e<c-this.s.fixedRight&&this._fnMouseListener(e,this.s.dt.aoColumns[e].nTh),this.s.dt.aoColumns[e]._ColReorder_iOrigCol=e;this.s.dt.oApi._fnCallbackReg(this.s.dt,"aoStateSaveParams",function(b,
c){a._fnStateSave.call(a,c)},"ColReorder_State");var b=null;this.s.init.aiOrder&&(b=this.s.init.aiOrder.slice());this.s.dt.oLoadedState&&("undefined"!=typeof this.s.dt.oLoadedState.ColReorder&&this.s.dt.oLoadedState.ColReorder.length==this.s.dt.aoColumns.length)&&(b=this.s.dt.oLoadedState.ColReorder);if(b)if(a.s.dt._bInitComplete)c=p(b),a._fnOrderColumns.call(a,c);else{var g=!1;f(d).on("draw.dt.colReorder",function(){if(!a.s.dt._bInitComplete&&!g){g=true;var c=p(b);a._fnOrderColumns.call(a,c)}})}else this._fnSetColumnIndexes();
f(d).on("destroy.dt.colReorder",function(){f(d).off("destroy.dt.colReorder draw.dt.colReorder");f(a.s.dt.nTHead).find("*").off(".ColReorder");f.each(a.s.dt.aoColumns,function(a,b){f(b.nTh).removeAttr("data-column-index")});a.s.dt._colReorder=null;a.s=null})},_fnOrderColumns:function(a){var c=!1;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.");else{for(var d=0,e=a.length;d<e;d++){var b=
f.inArray(d,a);d!=b&&(o(a,b,d),this.s.dt.oInstance.fnColReorder(b,d,!0),c=!0)}this._fnSetColumnIndexes();c&&((""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))}},_fnStateSave:function(a){var c,d,e,b=this.s.dt.aoColumns;a.ColReorder=[];if(a.aaSorting){for(c=0;c<a.aaSorting.length;c++)a.aaSorting[c][0]=b[a.aaSorting[c][0]]._ColReorder_iOrigCol;
var g=f.extend(!0,[],a.aoSearchCols);c=0;for(d=b.length;c<d;c++)e=b[c]._ColReorder_iOrigCol,a.aoSearchCols[e]=g[c],a.abVisCols[e]=b[c].bVisible,a.ColReorder.push(e)}else if(a.order){for(c=0;c<a.order.length;c++)a.order[c][0]=b[a.order[c][0]]._ColReorder_iOrigCol;g=f.extend(!0,[],a.columns);c=0;for(d=b.length;c<d;c++)e=b[c]._ColReorder_iOrigCol,a.columns[e]=g[c],a.ColReorder.push(e)}},_fnMouseListener:function(a,c){var d=this;f(c).on("mousedown.ColReorder",function(a){a.preventDefault();d._fnMouseDown.call(d,
a,c)})},_fnMouseDown:function(a,c){var d=this,e=f(a.target).closest("th, td").offset(),b=parseInt(f(c).attr("data-column-index"),10);b!==r&&(this.s.mouse.startX=a.pageX,this.s.mouse.startY=a.pageY,this.s.mouse.offsetX=a.pageX-e.left,this.s.mouse.offsetY=a.pageY-e.top,this.s.mouse.target=this.s.dt.aoColumns[b].nTh,this.s.mouse.targetIndex=b,this.s.mouse.fromIndex=b,this._fnRegions(),f(k).on("mousemove.ColReorder",function(a){d._fnMouseMove.call(d,a)}).on("mouseup.ColReorder",function(a){d._fnMouseUp.call(d,
a)}))},_fnMouseMove:function(a){if(null===this.dom.drag){if(5>Math.pow(Math.pow(a.pageX-this.s.mouse.startX,2)+Math.pow(a.pageY-this.s.mouse.startY,2),0.5))return;this._fnCreateDragNode()}this.dom.drag.css({left:a.pageX-this.s.mouse.offsetX,top:a.pageY-this.s.mouse.offsetY});for(var c=!1,d=this.s.mouse.toIndex,e=1,b=this.s.aoTargets.length;e<b;e++)if(a.pageX<this.s.aoTargets[e-1].x+(this.s.aoTargets[e].x-this.s.aoTargets[e-1].x)/2){this.dom.pointer.css("left",this.s.aoTargets[e-1].x);this.s.mouse.toIndex=
this.s.aoTargets[e-1].to;c=!0;break}c||(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);this.s.init.bRealtime&&d!==this.s.mouse.toIndex&&(this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex,!1),this.s.mouse.fromIndex=this.s.mouse.toIndex,this._fnRegions())},_fnMouseUp:function(){f(k).off("mousemove.ColReorder mouseup.ColReorder");null!==this.dom.drag&&(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,!0),this._fnSetColumnIndexes(),(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))},_fnRegions:function(){var a=this.s.dt.aoColumns;this.s.aoTargets.splice(0,this.s.aoTargets.length);this.s.aoTargets.push({x:f(this.s.dt.nTable).offset().left,
to:0});for(var c=0,d=f(a[0].nTh).offset().left,e=0,b=a.length;e<b;e++)e!=this.s.mouse.fromIndex&&c++,a[e].bVisible&&"none"!==a[e].nTh.style.display&&(d+=f(a[e].nTh).outerWidth(),this.s.aoTargets.push({x:d,to:c}));0!==this.s.fixedRight&&this.s.aoTargets.splice(this.s.aoTargets.length-this.s.fixedRight);0!==this.s.fixed&&this.s.aoTargets.splice(0,this.s.fixed)},_fnCreateDragNode:function(){var a=""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY,c=this.s.dt.aoColumns[this.s.mouse.targetIndex].nTh,
d=c.parentNode,e=d.parentNode,b=e.parentNode,g=f(c).clone();this.dom.drag=f(b.cloneNode(!1)).addClass("DTCR_clonedTable").append(f(e.cloneNode(!1)).append(f(d.cloneNode(!1)).append(g[0]))).css({position:"absolute",top:0,left:0,width:f(c).outerWidth(),height:f(c).outerHeight()}).appendTo("body");this.dom.pointer=f("<div></div>").addClass("DTCR_pointer").css({position:"absolute",top:a?f("div.dataTables_scroll",this.s.dt.nTableWrapper).offset().top:f(this.s.dt.nTable).offset().top,height:a?f("div.dataTables_scroll",
this.s.dt.nTableWrapper).height():f(this.s.dt.nTable).height()}).appendTo("body")},_fnSetColumnIndexes:function(){f.each(this.s.dt.aoColumns,function(a,c){f(c.nTh).attr("data-column-index",a)})}});h.defaults={aiOrder:null,bRealtime:!0,iFixedColumnsLeft:0,iFixedColumnsRight:0,fnReorderCallback:null};h.version="1.3.1";f.fn.dataTable.ColReorder=h;f.fn.DataTable.ColReorder=h;"function"==typeof f.fn.dataTable&&"function"==typeof f.fn.dataTableExt.fnVersionCheck&&f.fn.dataTableExt.fnVersionCheck("1.10.8")?
f.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var c=a.oInstance;a._colReorder?c.oApi._fnLog(a,1,"ColReorder attempted to initialise twice. Ignoring second"):(c=a.oInit,new h(a,c.colReorder||c.oColReorder||{}));return null},cFeature:"R",sFeature:"ColReorder"}):alert("Warning: ColReorder requires DataTables 1.10.8 or greater - www.datatables.net/download");f(k).on("preInit.dt.colReorder",function(a,c){if("dt"===a.namespace){var d=c.oInit.colReorder,e=s.defaults.colReorder;if(d||e)e=f.extend({},
d,e),!1!==d&&new h(c,e)}});f.fn.dataTable.Api.register("colReorder.reset()",function(){return this.iterator("table",function(a){a._colReorder.fnReset()})});f.fn.dataTable.Api.register("colReorder.order()",function(a,c){return a?this.iterator("table",function(d){d._colReorder.fnOrder(a,c)}):this.context.length?this.context[0]._colReorder.fnOrder():null});f.fn.dataTable.Api.register("colReorder.transpose()",function(a,c){return this.context.length&&this.context[0]._colReorder?this.context[0]._colReorder.fnTranspose(a,
c):a});return h});