jquery-datatables-rails 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/dataTables/bootstrap/3/jquery.dataTables.bootstrap.js +64 -29
- data/app/assets/javascripts/dataTables/extras/dataTables.autoFill.js +806 -648
- data/app/assets/javascripts/dataTables/extras/dataTables.buttons.js +1607 -0
- data/app/assets/javascripts/dataTables/extras/dataTables.colReorder.js +220 -267
- data/app/assets/javascripts/dataTables/extras/dataTables.fixedColumns.js +164 -69
- data/app/assets/javascripts/dataTables/extras/dataTables.fixedHeader.js +469 -870
- data/app/assets/javascripts/dataTables/extras/dataTables.keyTable.js +636 -972
- data/app/assets/javascripts/dataTables/extras/dataTables.responsive.js +472 -187
- data/app/assets/javascripts/dataTables/extras/dataTables.rowReorder.js +619 -0
- data/app/assets/javascripts/dataTables/extras/dataTables.scroller.js +146 -111
- data/app/assets/javascripts/dataTables/extras/dataTables.select.js +1038 -0
- data/app/assets/javascripts/dataTables/jquery.dataTables.api.fnGetColumnData.js +0 -0
- data/app/assets/javascripts/dataTables/jquery.dataTables.api.fnReloadAjax.js +0 -0
- data/app/assets/javascripts/dataTables/jquery.dataTables.foundation.js +37 -61
- data/app/assets/javascripts/dataTables/jquery.dataTables.js +720 -387
- data/app/assets/javascripts/dataTables/jquery.dataTables.sorting.ipAddress.js +44 -0
- data/app/assets/javascripts/dataTables/jquery.dataTables.sorting.numbersHtml.js +0 -0
- data/app/assets/javascripts/dataTables/jquery.dataTables.typeDetection.numbersHtml.js +0 -0
- data/app/assets/stylesheets/dataTables/jquery.dataTables.scss +34 -66
- data/app/assets/stylesheets/dataTables/src/demo_table.css +1 -1
- data/app/assets/stylesheets/dataTables/src/demo_table_jui.css.scss +4 -4
- data/lib/jquery/datatables/rails/version.rb +1 -1
- metadata +24 -19
@@ -1,11 +1,11 @@
|
|
1
|
-
/*! ColReorder 1.
|
2
|
-
* ©2010-
|
1
|
+
/*! ColReorder 1.3.0
|
2
|
+
* ©2010-2015 SpryMedia Ltd - datatables.net/license
|
3
3
|
*/
|
4
4
|
|
5
5
|
/**
|
6
6
|
* @summary ColReorder
|
7
7
|
* @description Provide the ability to reorder columns in a DataTable
|
8
|
-
* @version 1.
|
8
|
+
* @version 1.3.0
|
9
9
|
* @file dataTables.colReorder.js
|
10
10
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
11
11
|
* @contact www.sprymedia.co.uk/contact
|
@@ -20,8 +20,34 @@
|
|
20
20
|
*
|
21
21
|
* For details please refer to: http://www.datatables.net
|
22
22
|
*/
|
23
|
+
(function( factory ){
|
24
|
+
if ( typeof define === 'function' && define.amd ) {
|
25
|
+
// AMD
|
26
|
+
define( ['jquery', 'datatables.net'], function ( $ ) {
|
27
|
+
return factory( $, window, document );
|
28
|
+
} );
|
29
|
+
}
|
30
|
+
else if ( typeof exports === 'object' ) {
|
31
|
+
// CommonJS
|
32
|
+
module.exports = function (root, $) {
|
33
|
+
if ( ! root ) {
|
34
|
+
root = window;
|
35
|
+
}
|
23
36
|
|
24
|
-
(
|
37
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
38
|
+
$ = require('datatables.net')(root, $).$;
|
39
|
+
}
|
40
|
+
|
41
|
+
return factory( $, root, root.document );
|
42
|
+
};
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
// Browser
|
46
|
+
factory( jQuery, window, document );
|
47
|
+
}
|
48
|
+
}(function( $, window, document, undefined ) {
|
49
|
+
'use strict';
|
50
|
+
var DataTable = $.fn.dataTable;
|
25
51
|
|
26
52
|
|
27
53
|
/**
|
@@ -89,10 +115,6 @@ function fnDomSwitch( nParent, iFrom, iTo )
|
|
89
115
|
}
|
90
116
|
|
91
117
|
|
92
|
-
|
93
|
-
var factory = function( $, DataTable ) {
|
94
|
-
"use strict";
|
95
|
-
|
96
118
|
/**
|
97
119
|
* Plug-in for DataTables which will reorder the internal column structure by taking the column
|
98
120
|
* from one position (iFrom) and insert it into a given point (iTo).
|
@@ -100,14 +122,15 @@ var factory = function( $, DataTable ) {
|
|
100
122
|
* @param object oSettings DataTables settings object - automatically added by DataTables!
|
101
123
|
* @param int iFrom Take the column to be repositioned from this point
|
102
124
|
* @param int iTo and insert it into this point
|
125
|
+
* @param bool drop Indicate if the reorder is the final one (i.e. a drop)
|
126
|
+
* not a live reorder
|
103
127
|
* @returns void
|
104
128
|
*/
|
105
|
-
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
129
|
+
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo, drop )
|
106
130
|
{
|
107
|
-
var v110 = $.fn.dataTable.Api ? true : false;
|
108
131
|
var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
|
109
132
|
var attrMap = function ( obj, prop, mapping ) {
|
110
|
-
if ( ! obj[ prop ] ) {
|
133
|
+
if ( ! obj[ prop ] || typeof obj[ prop ] === 'function' ) {
|
111
134
|
return;
|
112
135
|
}
|
113
136
|
|
@@ -180,17 +203,13 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
180
203
|
}
|
181
204
|
|
182
205
|
// Update the column indexes
|
183
|
-
|
184
|
-
oCol.idx = aiInvertMapping[ oCol.idx ];
|
185
|
-
}
|
206
|
+
oCol.idx = aiInvertMapping[ oCol.idx ];
|
186
207
|
}
|
187
208
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
} );
|
193
|
-
}
|
209
|
+
// Update 1.10 optimised sort class removal variable
|
210
|
+
$.each( oSettings.aLastSort, function (i, val) {
|
211
|
+
oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
|
212
|
+
} );
|
194
213
|
|
195
214
|
/* Update the Get and Set functions for each column */
|
196
215
|
for ( i=0, iLen=iCols ; i<iLen ; i++ )
|
@@ -276,25 +295,15 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
276
295
|
{
|
277
296
|
var data = oSettings.aoData[i];
|
278
297
|
|
279
|
-
if (
|
280
|
-
|
281
|
-
if ( data.anCells ) {
|
282
|
-
fnArraySwitch( data.anCells, iFrom, iTo );
|
283
|
-
}
|
284
|
-
|
285
|
-
// For DOM sourced data, the invalidate will reread the cell into
|
286
|
-
// the data array, but for data sources as an array, they need to
|
287
|
-
// be flipped
|
288
|
-
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
|
289
|
-
fnArraySwitch( data._aData, iFrom, iTo );
|
290
|
-
}
|
298
|
+
if ( data.anCells ) {
|
299
|
+
fnArraySwitch( data.anCells, iFrom, iTo );
|
291
300
|
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
fnArraySwitch( data.
|
301
|
+
|
302
|
+
// For DOM sourced data, the invalidate will reread the cell into
|
303
|
+
// the data array, but for data sources as an array, they need to
|
304
|
+
// be flipped
|
305
|
+
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
|
306
|
+
fnArraySwitch( data._aData, iFrom, iTo );
|
298
307
|
}
|
299
308
|
}
|
300
309
|
|
@@ -312,11 +321,9 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
312
321
|
}
|
313
322
|
}
|
314
323
|
|
315
|
-
//
|
316
|
-
|
317
|
-
|
318
|
-
api.rows().invalidate();
|
319
|
-
}
|
324
|
+
// Invalidate row cached data for sorting, filtering etc
|
325
|
+
var api = new $.fn.dataTable.Api( oSettings );
|
326
|
+
api.rows().invalidate();
|
320
327
|
|
321
328
|
/*
|
322
329
|
* Update DataTables' event handlers
|
@@ -331,10 +338,16 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
331
338
|
|
332
339
|
|
333
340
|
/* Fire an event so other plug-ins can update */
|
334
|
-
$(oSettings.oInstance).trigger( 'column-reorder', [ oSettings, {
|
335
|
-
|
336
|
-
|
337
|
-
|
341
|
+
$(oSettings.oInstance).trigger( 'column-reorder.dt', [ oSettings, {
|
342
|
+
from: iFrom,
|
343
|
+
to: iTo,
|
344
|
+
mapping: aiInvertMapping,
|
345
|
+
drop: drop,
|
346
|
+
|
347
|
+
// Old style parameters for compatibility
|
348
|
+
iFrom: iFrom,
|
349
|
+
iTo: iTo,
|
350
|
+
aiInvertMapping: aiInvertMapping
|
338
351
|
} ] );
|
339
352
|
};
|
340
353
|
|
@@ -348,42 +361,16 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
348
361
|
*/
|
349
362
|
var ColReorder = function( dt, opts )
|
350
363
|
{
|
351
|
-
var
|
364
|
+
var settings = new $.fn.dataTable.Api( dt ).settings()[0];
|
352
365
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
// 1.9 compatibility
|
357
|
-
else if ( dt.fnSettings ) {
|
358
|
-
// DataTables object, convert to the settings object
|
359
|
-
oDTSettings = dt.fnSettings();
|
360
|
-
}
|
361
|
-
else if ( typeof dt === 'string' ) {
|
362
|
-
// jQuery selector
|
363
|
-
if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
|
364
|
-
oDTSettings = $(dt).eq(0).dataTable().fnSettings();
|
365
|
-
}
|
366
|
-
}
|
367
|
-
else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
|
368
|
-
// Table node
|
369
|
-
if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
|
370
|
-
oDTSettings = $(dt.nodeName).dataTable().fnSettings();
|
371
|
-
}
|
372
|
-
}
|
373
|
-
else if ( dt instanceof jQuery ) {
|
374
|
-
// jQuery object
|
375
|
-
if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
|
376
|
-
oDTSettings = dt.eq(0).dataTable().fnSettings();
|
377
|
-
}
|
378
|
-
}
|
379
|
-
else {
|
380
|
-
// DataTables settings object
|
381
|
-
oDTSettings = dt;
|
366
|
+
// Ensure that we can't initialise on the same table twice
|
367
|
+
if ( settings._colReorder ) {
|
368
|
+
return settings._colReorder;
|
382
369
|
}
|
383
370
|
|
384
|
-
//
|
385
|
-
if (
|
386
|
-
|
371
|
+
// Allow the options to be a boolean for defaults
|
372
|
+
if ( opts === true ) {
|
373
|
+
opts = {};
|
387
374
|
}
|
388
375
|
|
389
376
|
// Convert from camelCase to Hungarian, just as DataTables does
|
@@ -491,19 +478,16 @@ var ColReorder = function( dt, opts )
|
|
491
478
|
|
492
479
|
|
493
480
|
/* Constructor logic */
|
494
|
-
this.s.dt =
|
481
|
+
this.s.dt = settings;
|
495
482
|
this.s.dt._colReorder = this;
|
496
483
|
this._fnConstruct();
|
497
484
|
|
498
|
-
/* Add destroy callback */
|
499
|
-
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
|
500
|
-
|
501
485
|
return this;
|
502
486
|
};
|
503
487
|
|
504
488
|
|
505
489
|
|
506
|
-
ColReorder.prototype
|
490
|
+
$.extend( ColReorder.prototype, {
|
507
491
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
508
492
|
* Public methods
|
509
493
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
@@ -527,13 +511,7 @@ ColReorder.prototype = {
|
|
527
511
|
*/
|
528
512
|
"fnReset": function ()
|
529
513
|
{
|
530
|
-
|
531
|
-
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
532
|
-
{
|
533
|
-
a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
|
534
|
-
}
|
535
|
-
|
536
|
-
this._fnOrderColumns( a );
|
514
|
+
this._fnOrderColumns( this.fnOrder() );
|
537
515
|
|
538
516
|
return this;
|
539
517
|
},
|
@@ -585,24 +563,74 @@ ColReorder.prototype = {
|
|
585
563
|
* $.fn.dataTable.ColReorder( '#example' ).fnOrder().reverse()
|
586
564
|
* );
|
587
565
|
*/
|
588
|
-
"fnOrder": function ( set )
|
566
|
+
"fnOrder": function ( set, original )
|
589
567
|
{
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
{
|
595
|
-
a.push(
|
568
|
+
var a = [], i, ien, j, jen;
|
569
|
+
var columns = this.s.dt.aoColumns;
|
570
|
+
|
571
|
+
if ( set === undefined ){
|
572
|
+
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
|
573
|
+
a.push( columns[i]._ColReorder_iOrigCol );
|
596
574
|
}
|
575
|
+
|
597
576
|
return a;
|
598
577
|
}
|
599
578
|
|
579
|
+
// The order given is based on the original indexes, rather than the
|
580
|
+
// existing ones, so we need to translate from the original to current
|
581
|
+
// before then doing the order
|
582
|
+
if ( original ) {
|
583
|
+
var order = this.fnOrder();
|
584
|
+
|
585
|
+
for ( i=0, ien=set.length ; i<ien ; i++ ) {
|
586
|
+
a.push( $.inArray( set[i], order ) );
|
587
|
+
}
|
588
|
+
|
589
|
+
set = a;
|
590
|
+
}
|
591
|
+
|
600
592
|
this._fnOrderColumns( fnInvertKeyValues( set ) );
|
601
593
|
|
602
594
|
return this;
|
603
595
|
},
|
604
596
|
|
605
597
|
|
598
|
+
/**
|
599
|
+
* Convert from the original column index, to the original
|
600
|
+
*
|
601
|
+
* @param {int|array} idx Index(es) to convert
|
602
|
+
* @param {string} dir Transpose direction - `fromOriginal` / `toCurrent`
|
603
|
+
* or `'toOriginal` / `fromCurrent`
|
604
|
+
* @return {int|array} Converted values
|
605
|
+
*/
|
606
|
+
fnTranspose: function ( idx, dir )
|
607
|
+
{
|
608
|
+
if ( ! dir ) {
|
609
|
+
dir = 'toCurrent';
|
610
|
+
}
|
611
|
+
|
612
|
+
var order = this.fnOrder();
|
613
|
+
var columns = this.s.dt.aoColumns;
|
614
|
+
|
615
|
+
if ( dir === 'toCurrent' ) {
|
616
|
+
// Given an original index, want the current
|
617
|
+
return ! $.isArray( idx ) ?
|
618
|
+
$.inArray( idx, order ) :
|
619
|
+
$.map( idx, function ( index ) {
|
620
|
+
return $.inArray( index, order );
|
621
|
+
} );
|
622
|
+
}
|
623
|
+
else {
|
624
|
+
// Given a current index, want the original
|
625
|
+
return ! $.isArray( idx ) ?
|
626
|
+
columns[idx]._ColReorder_iOrigCol :
|
627
|
+
$.map( idx, function ( index ) {
|
628
|
+
return columns[index]._ColReorder_iOrigCol;
|
629
|
+
} );
|
630
|
+
}
|
631
|
+
},
|
632
|
+
|
633
|
+
|
606
634
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
607
635
|
* Private methods (they are of course public in JS, but recommended as private)
|
608
636
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
@@ -617,6 +645,7 @@ ColReorder.prototype = {
|
|
617
645
|
{
|
618
646
|
var that = this;
|
619
647
|
var iLen = this.s.dt.aoColumns.length;
|
648
|
+
var table = this.s.dt.nTable;
|
620
649
|
var i;
|
621
650
|
|
622
651
|
/* Columns discounted from reordering - counting left to right */
|
@@ -625,6 +654,11 @@ ColReorder.prototype = {
|
|
625
654
|
this.s.fixed = this.s.init.iFixedColumns;
|
626
655
|
}
|
627
656
|
|
657
|
+
if ( this.s.init.iFixedColumnsLeft )
|
658
|
+
{
|
659
|
+
this.s.fixed = this.s.init.iFixedColumnsLeft;
|
660
|
+
}
|
661
|
+
|
628
662
|
/* Columns discounted from reordering - counting right to left */
|
629
663
|
this.s.fixedRight = this.s.init.iFixedColumnsRight ?
|
630
664
|
this.s.init.iFixedColumnsRight :
|
@@ -676,16 +710,13 @@ ColReorder.prototype = {
|
|
676
710
|
if ( !that.s.dt._bInitComplete )
|
677
711
|
{
|
678
712
|
var bDone = false;
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
}
|
687
|
-
},
|
688
|
-
"sName": "ColReorder_Pre"
|
713
|
+
$(table).on( 'draw.dt.colReorder', function () {
|
714
|
+
if ( !that.s.dt._bInitComplete && !bDone )
|
715
|
+
{
|
716
|
+
bDone = true;
|
717
|
+
var resort = fnInvertKeyValues( aiOrder );
|
718
|
+
that._fnOrderColumns.call( that, resort );
|
719
|
+
}
|
689
720
|
} );
|
690
721
|
}
|
691
722
|
else
|
@@ -697,6 +728,19 @@ ColReorder.prototype = {
|
|
697
728
|
else {
|
698
729
|
this._fnSetColumnIndexes();
|
699
730
|
}
|
731
|
+
|
732
|
+
// Destroy clean up
|
733
|
+
$(table).on( 'destroy.dt.colReorder', function () {
|
734
|
+
$(table).off( 'destroy.dt.colReorder draw.dt.colReorder' );
|
735
|
+
$(that.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
|
736
|
+
|
737
|
+
$.each( that.s.dt.aoColumns, function (i, column) {
|
738
|
+
$(column.nTh).removeAttr('data-column-index');
|
739
|
+
} );
|
740
|
+
|
741
|
+
that.s.dt._colReorder = null;
|
742
|
+
that.s = null;
|
743
|
+
} );
|
700
744
|
},
|
701
745
|
|
702
746
|
|
@@ -709,6 +753,8 @@ ColReorder.prototype = {
|
|
709
753
|
*/
|
710
754
|
"_fnOrderColumns": function ( a )
|
711
755
|
{
|
756
|
+
var changed = false;
|
757
|
+
|
712
758
|
if ( a.length != this.s.dt.aoColumns.length )
|
713
759
|
{
|
714
760
|
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
|
@@ -725,10 +771,19 @@ ColReorder.prototype = {
|
|
725
771
|
fnArraySwitch( a, currIndex, i );
|
726
772
|
|
727
773
|
/* Do the column reorder in the table */
|
728
|
-
this.s.dt.oInstance.fnColReorder( currIndex, i );
|
774
|
+
this.s.dt.oInstance.fnColReorder( currIndex, i, true );
|
775
|
+
|
776
|
+
changed = true;
|
729
777
|
}
|
730
778
|
}
|
731
779
|
|
780
|
+
this._fnSetColumnIndexes();
|
781
|
+
|
782
|
+
// Has anything actually changed? If not, then nothing else to do
|
783
|
+
if ( ! changed ) {
|
784
|
+
return;
|
785
|
+
}
|
786
|
+
|
732
787
|
/* When scrolling we need to recalculate the column sizes to allow for the shift */
|
733
788
|
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
|
734
789
|
{
|
@@ -737,8 +792,6 @@ ColReorder.prototype = {
|
|
737
792
|
|
738
793
|
/* Save the state */
|
739
794
|
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
|
740
|
-
|
741
|
-
this._fnSetColumnIndexes();
|
742
795
|
|
743
796
|
if ( this.s.reorderCallback !== null )
|
744
797
|
{
|
@@ -930,7 +983,7 @@ ColReorder.prototype = {
|
|
930
983
|
|
931
984
|
// Perform reordering if realtime updating is on and the column has moved
|
932
985
|
if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
|
933
|
-
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
|
986
|
+
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, false );
|
934
987
|
this.s.mouse.fromIndex = this.s.mouse.toIndex;
|
935
988
|
this._fnRegions();
|
936
989
|
}
|
@@ -959,7 +1012,7 @@ ColReorder.prototype = {
|
|
959
1012
|
this.dom.pointer = null;
|
960
1013
|
|
961
1014
|
/* Actually do the reorder */
|
962
|
-
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
|
1015
|
+
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, true );
|
963
1016
|
this._fnSetColumnIndexes();
|
964
1017
|
|
965
1018
|
/* When scrolling we need to recalculate the column sizes to allow for the shift */
|
@@ -998,10 +1051,12 @@ ColReorder.prototype = {
|
|
998
1051
|
} );
|
999
1052
|
|
1000
1053
|
var iToPoint = 0;
|
1054
|
+
var total = $(aoColumns[0].nTh).offset().left; // Offset of the first column
|
1055
|
+
|
1001
1056
|
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
|
1002
1057
|
{
|
1003
1058
|
/* For the column / header in question, we want it's position to remain the same if the
|
1004
|
-
* position is just to it's immediate left or right, so we only
|
1059
|
+
* position is just to it's immediate left or right, so we only increment the counter for
|
1005
1060
|
* other columns
|
1006
1061
|
*/
|
1007
1062
|
if ( i != this.s.mouse.fromIndex )
|
@@ -1011,8 +1066,10 @@ ColReorder.prototype = {
|
|
1011
1066
|
|
1012
1067
|
if ( aoColumns[i].bVisible )
|
1013
1068
|
{
|
1069
|
+
total += $(aoColumns[i].nTh).outerWidth();
|
1070
|
+
|
1014
1071
|
this.s.aoTargets.push( {
|
1015
|
-
"x":
|
1072
|
+
"x": total,
|
1016
1073
|
"to": iToPoint
|
1017
1074
|
} );
|
1018
1075
|
}
|
@@ -1084,35 +1141,6 @@ ColReorder.prototype = {
|
|
1084
1141
|
.appendTo( 'body' );
|
1085
1142
|
},
|
1086
1143
|
|
1087
|
-
/**
|
1088
|
-
* Clean up ColReorder memory references and event handlers
|
1089
|
-
* @method _fnDestroy
|
1090
|
-
* @returns void
|
1091
|
-
* @private
|
1092
|
-
*/
|
1093
|
-
"_fnDestroy": function ()
|
1094
|
-
{
|
1095
|
-
var i, iLen;
|
1096
|
-
|
1097
|
-
for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; i<iLen ; i++ )
|
1098
|
-
{
|
1099
|
-
if ( this.s.dt.aoDrawCallback[i].sName === 'ColReorder_Pre' )
|
1100
|
-
{
|
1101
|
-
this.s.dt.aoDrawCallback.splice( i, 1 );
|
1102
|
-
break;
|
1103
|
-
}
|
1104
|
-
}
|
1105
|
-
|
1106
|
-
$(this.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
|
1107
|
-
|
1108
|
-
$.each( this.s.dt.aoColumns, function (i, column) {
|
1109
|
-
$(column.nTh).removeAttr('data-column-index');
|
1110
|
-
} );
|
1111
|
-
|
1112
|
-
this.s.dt._colReorder = null;
|
1113
|
-
this.s = null;
|
1114
|
-
},
|
1115
|
-
|
1116
1144
|
|
1117
1145
|
/**
|
1118
1146
|
* Add a data attribute to the column headers, so we know the index of
|
@@ -1126,7 +1154,7 @@ ColReorder.prototype = {
|
|
1126
1154
|
$(column.nTh).attr('data-column-index', i);
|
1127
1155
|
} );
|
1128
1156
|
}
|
1129
|
-
};
|
1157
|
+
} );
|
1130
1158
|
|
1131
1159
|
|
1132
1160
|
|
@@ -1150,22 +1178,6 @@ ColReorder.defaults = {
|
|
1150
1178
|
* @type array
|
1151
1179
|
* @default null
|
1152
1180
|
* @static
|
1153
|
-
* @example
|
1154
|
-
* // Using the `oColReorder` option in the DataTables options object
|
1155
|
-
* $('#example').dataTable( {
|
1156
|
-
* "sDom": 'Rlfrtip',
|
1157
|
-
* "oColReorder": {
|
1158
|
-
* "aiOrder": [ 4, 3, 2, 1, 0 ]
|
1159
|
-
* }
|
1160
|
-
* } );
|
1161
|
-
*
|
1162
|
-
* @example
|
1163
|
-
* // Using `new` constructor
|
1164
|
-
* $('#example').dataTable()
|
1165
|
-
*
|
1166
|
-
* new $.fn.dataTable.ColReorder( '#example', {
|
1167
|
-
* "aiOrder": [ 4, 3, 2, 1, 0 ]
|
1168
|
-
* } );
|
1169
1181
|
*/
|
1170
1182
|
aiOrder: null,
|
1171
1183
|
|
@@ -1178,24 +1190,8 @@ ColReorder.defaults = {
|
|
1178
1190
|
* @type boolean
|
1179
1191
|
* @default false
|
1180
1192
|
* @static
|
1181
|
-
* @example
|
1182
|
-
* // Using the `oColReorder` option in the DataTables options object
|
1183
|
-
* $('#example').dataTable( {
|
1184
|
-
* "sDom": 'Rlfrtip',
|
1185
|
-
* "oColReorder": {
|
1186
|
-
* "bRealtime": true
|
1187
|
-
* }
|
1188
|
-
* } );
|
1189
|
-
*
|
1190
|
-
* @example
|
1191
|
-
* // Using `new` constructor
|
1192
|
-
* $('#example').dataTable()
|
1193
|
-
*
|
1194
|
-
* new $.fn.dataTable.ColReorder( '#example', {
|
1195
|
-
* "bRealtime": true
|
1196
|
-
* } );
|
1197
1193
|
*/
|
1198
|
-
bRealtime:
|
1194
|
+
bRealtime: true,
|
1199
1195
|
|
1200
1196
|
/**
|
1201
1197
|
* Indicate how many columns should be fixed in position (counting from the
|
@@ -1203,74 +1199,23 @@ ColReorder.defaults = {
|
|
1203
1199
|
* @type int
|
1204
1200
|
* @default 0
|
1205
1201
|
* @static
|
1206
|
-
* @example
|
1207
|
-
* // Using the `oColReorder` option in the DataTables options object
|
1208
|
-
* $('#example').dataTable( {
|
1209
|
-
* "sDom": 'Rlfrtip',
|
1210
|
-
* "oColReorder": {
|
1211
|
-
* "iFixedColumns": 1
|
1212
|
-
* }
|
1213
|
-
* } );
|
1214
|
-
*
|
1215
|
-
* @example
|
1216
|
-
* // Using `new` constructor
|
1217
|
-
* $('#example').dataTable()
|
1218
|
-
*
|
1219
|
-
* new $.fn.dataTable.ColReorder( '#example', {
|
1220
|
-
* "iFixedColumns": 1
|
1221
|
-
* } );
|
1222
1202
|
*/
|
1223
|
-
|
1203
|
+
iFixedColumnsLeft: 0,
|
1224
1204
|
|
1225
1205
|
/**
|
1226
1206
|
* As `iFixedColumnsRight` but counting from the right.
|
1227
1207
|
* @type int
|
1228
1208
|
* @default 0
|
1229
1209
|
* @static
|
1230
|
-
* @example
|
1231
|
-
* // Using the `oColReorder` option in the DataTables options object
|
1232
|
-
* $('#example').dataTable( {
|
1233
|
-
* "sDom": 'Rlfrtip',
|
1234
|
-
* "oColReorder": {
|
1235
|
-
* "iFixedColumnsRight": 1
|
1236
|
-
* }
|
1237
|
-
* } );
|
1238
|
-
*
|
1239
|
-
* @example
|
1240
|
-
* // Using `new` constructor
|
1241
|
-
* $('#example').dataTable()
|
1242
|
-
*
|
1243
|
-
* new $.fn.dataTable.ColReorder( '#example', {
|
1244
|
-
* "iFixedColumnsRight": 1
|
1245
|
-
* } );
|
1246
1210
|
*/
|
1247
1211
|
iFixedColumnsRight: 0,
|
1248
1212
|
|
1249
1213
|
/**
|
1250
|
-
* Callback function that is fired when columns are reordered
|
1214
|
+
* Callback function that is fired when columns are reordered. The `column-
|
1215
|
+
* reorder` event is preferred over this callback
|
1251
1216
|
* @type function():void
|
1252
1217
|
* @default null
|
1253
1218
|
* @static
|
1254
|
-
* @example
|
1255
|
-
* // Using the `oColReorder` option in the DataTables options object
|
1256
|
-
* $('#example').dataTable( {
|
1257
|
-
* "sDom": 'Rlfrtip',
|
1258
|
-
* "oColReorder": {
|
1259
|
-
* "fnReorderCallback": function () {
|
1260
|
-
* alert( 'Columns reordered' );
|
1261
|
-
* }
|
1262
|
-
* }
|
1263
|
-
* } );
|
1264
|
-
*
|
1265
|
-
* @example
|
1266
|
-
* // Using `new` constructor
|
1267
|
-
* $('#example').dataTable()
|
1268
|
-
*
|
1269
|
-
* new $.fn.dataTable.ColReorder( '#example', {
|
1270
|
-
* "fnReorderCallback": function () {
|
1271
|
-
* alert( 'Columns reordered' );
|
1272
|
-
* }
|
1273
|
-
* } );
|
1274
1219
|
*/
|
1275
1220
|
fnReorderCallback: null
|
1276
1221
|
};
|
@@ -1287,7 +1232,7 @@ ColReorder.defaults = {
|
|
1287
1232
|
* @type String
|
1288
1233
|
* @default As code
|
1289
1234
|
*/
|
1290
|
-
ColReorder.version = "1.
|
1235
|
+
ColReorder.version = "1.3.0";
|
1291
1236
|
|
1292
1237
|
|
1293
1238
|
|
@@ -1303,7 +1248,7 @@ $.fn.DataTable.ColReorder = ColReorder;
|
|
1303
1248
|
// Register a new feature with DataTables
|
1304
1249
|
if ( typeof $.fn.dataTable == "function" &&
|
1305
1250
|
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
|
1306
|
-
$.fn.dataTableExt.fnVersionCheck('1.
|
1251
|
+
$.fn.dataTableExt.fnVersionCheck('1.10.8') )
|
1307
1252
|
{
|
1308
1253
|
$.fn.dataTableExt.aoFeatures.push( {
|
1309
1254
|
"fnInit": function( settings ) {
|
@@ -1326,47 +1271,55 @@ if ( typeof $.fn.dataTable == "function" &&
|
|
1326
1271
|
} );
|
1327
1272
|
}
|
1328
1273
|
else {
|
1329
|
-
alert( "Warning: ColReorder requires DataTables 1.
|
1274
|
+
alert( "Warning: ColReorder requires DataTables 1.10.8 or greater - www.datatables.net/download");
|
1330
1275
|
}
|
1331
1276
|
|
1332
1277
|
|
1333
|
-
//
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
} );
|
1278
|
+
// Attach a listener to the document which listens for DataTables initialisation
|
1279
|
+
// events so we can automatically initialise
|
1280
|
+
$(document).on( 'preInit.dt.colReorder', function (e, settings) {
|
1281
|
+
if ( e.namespace !== 'dt' ) {
|
1282
|
+
return;
|
1283
|
+
}
|
1340
1284
|
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1285
|
+
var init = settings.oInit.colReorder;
|
1286
|
+
var defaults = DataTable.defaults.colReorder;
|
1287
|
+
|
1288
|
+
if ( init || defaults ) {
|
1289
|
+
var opts = $.extend( {}, init, defaults );
|
1290
|
+
|
1291
|
+
if ( init !== false ) {
|
1292
|
+
new ColReorder( settings, opts );
|
1346
1293
|
}
|
1294
|
+
}
|
1295
|
+
} );
|
1296
|
+
|
1347
1297
|
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1298
|
+
// API augmentation
|
1299
|
+
$.fn.dataTable.Api.register( 'colReorder.reset()', function () {
|
1300
|
+
return this.iterator( 'table', function ( ctx ) {
|
1301
|
+
ctx._colReorder.fnReset();
|
1351
1302
|
} );
|
1352
|
-
}
|
1303
|
+
} );
|
1353
1304
|
|
1354
|
-
|
1355
|
-
|
1305
|
+
$.fn.dataTable.Api.register( 'colReorder.order()', function ( set, original ) {
|
1306
|
+
if ( set ) {
|
1307
|
+
return this.iterator( 'table', function ( ctx ) {
|
1308
|
+
ctx._colReorder.fnOrder( set, original );
|
1309
|
+
} );
|
1310
|
+
}
|
1356
1311
|
|
1312
|
+
return this.context.length ?
|
1313
|
+
this.context[0]._colReorder.fnOrder() :
|
1314
|
+
null;
|
1315
|
+
} );
|
1357
1316
|
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
// Node/CommonJS
|
1364
|
-
factory( require('jquery'), require('datatables') );
|
1365
|
-
}
|
1366
|
-
else if ( jQuery && !jQuery.fn.dataTable.ColReorder ) {
|
1367
|
-
// Otherwise simply initialise as normal, stopping multiple evaluation
|
1368
|
-
factory( jQuery, jQuery.fn.dataTable );
|
1369
|
-
}
|
1317
|
+
$.fn.dataTable.Api.register( 'colReorder.transpose()', function ( idx, dir ) {
|
1318
|
+
return this.context.length && this.context[0]._colReorder ?
|
1319
|
+
this.context[0]._colReorder.fnTranspose( idx, dir ) :
|
1320
|
+
idx;
|
1321
|
+
} );
|
1370
1322
|
|
1371
1323
|
|
1372
|
-
|
1324
|
+
return ColReorder;
|
1325
|
+
}));
|