jquery-datatables-rails 1.12.2 → 2.1.10.0.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/images/dataTables/extras/filler.png +0 -0
- data/app/assets/images/dataTables/extras/loading-background.png +0 -0
- data/app/assets/images/dataTables/sort_asc_disabled.png +0 -0
- data/app/assets/javascripts/dataTables/extras/dataTables.autoFill.js +851 -0
- data/app/assets/javascripts/dataTables/extras/{ColReorder.js → dataTables.colReorder.js} +558 -223
- data/app/assets/javascripts/dataTables/extras/dataTables.colVis.js +1096 -0
- data/app/assets/javascripts/dataTables/extras/{FixedColumns.js → dataTables.fixedColumns.js} +163 -113
- data/app/assets/javascripts/dataTables/extras/{FixedHeader.js → dataTables.fixedHeader.js} +306 -219
- data/app/assets/javascripts/dataTables/extras/{KeyTable.js → dataTables.keyTable.js} +155 -95
- data/app/assets/javascripts/dataTables/extras/{Scroller.js → dataTables.scroller.js} +469 -188
- data/app/assets/javascripts/dataTables/extras/{TableTools.js → dataTables.tableTools.js} +949 -341
- data/app/assets/javascripts/dataTables/jquery.dataTables.foundation.js +4 -4
- data/app/assets/javascripts/dataTables/jquery.dataTables.js +10711 -8427
- data/app/assets/media/dataTables/extras/swf/copy_csv_xls.swf +0 -0
- data/app/assets/media/dataTables/extras/swf/copy_csv_xls_pdf.swf +0 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.autoFill.css.scss +24 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.colReorder.css.scss +14 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.colVis.css.scss +184 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.colvis.jqueryui.css.scss +23 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.fixedColumns.css.scss +24 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.fixedHeader.css.scss +7 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.keyTable.css.scss +7 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.scroller.css.scss +44 -0
- data/app/assets/stylesheets/dataTables/extras/{TableTools.css.erb → dataTables.tableTools.css.scss} +30 -15
- data/app/assets/stylesheets/dataTables/jquery.dataTables.bootstrap.css.scss +6 -0
- data/app/assets/stylesheets/dataTables/jquery.dataTables.css.scss +363 -184
- data/app/assets/stylesheets/dataTables/src/jquery.dataTables_themeroller.css +307 -220
- data/lib/jquery/datatables/rails/version.rb +1 -1
- metadata +42 -22
- data/app/assets/javascripts/dataTables/extras/AutoFill.js +0 -820
- data/app/assets/javascripts/dataTables/extras/ColVis.js +0 -1005
- data/app/assets/javascripts/dataTables/extras/TableTools.min.js +0 -77
- data/app/assets/stylesheets/dataTables/extras/ColReorder.css.erb +0 -21
- data/app/assets/stylesheets/dataTables/extras/ColVis.css +0 -76
- data/app/assets/stylesheets/dataTables/extras/ColVisAlt.css.erb +0 -104
@@ -1,27 +1,27 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
1
|
+
/*! ColReorder 1.1.1
|
2
|
+
* ©2010-2014 SpryMedia Ltd - datatables.net/license
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @summary ColReorder
|
7
|
+
* @description Provide the ability to reorder columns in a DataTable
|
8
|
+
* @version 1.1.1
|
9
|
+
* @file dataTables.colReorder.js
|
10
|
+
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
11
|
+
* @contact www.sprymedia.co.uk/contact
|
12
|
+
* @copyright Copyright 2010-2014 SpryMedia Ltd.
|
13
13
|
*
|
14
|
-
*
|
14
|
+
* This source file is free software, available under the following license:
|
15
|
+
* MIT license - http://datatables.net/license/mit
|
15
16
|
*
|
16
|
-
* This source file is
|
17
|
-
*
|
18
|
-
*
|
19
|
-
* http://datatables.net/license_bsd
|
17
|
+
* This source file is distributed in the hope that it will be useful, but
|
18
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
19
|
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
20
20
|
*
|
21
|
+
* For details please refer to: http://www.datatables.net
|
21
22
|
*/
|
22
23
|
|
23
|
-
|
24
|
-
(function($, window, document) {
|
24
|
+
(function(window, document, undefined) {
|
25
25
|
|
26
26
|
|
27
27
|
/**
|
@@ -109,6 +109,7 @@ function fnDomSwitch( nParent, iFrom, iTo )
|
|
109
109
|
*/
|
110
110
|
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
111
111
|
{
|
112
|
+
var v110 = $.fn.dataTable.Api ? true : false;
|
112
113
|
var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
|
113
114
|
|
114
115
|
/* Sanity check in the input */
|
@@ -168,6 +169,18 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
168
169
|
{
|
169
170
|
oCol.aDataSort[j] = aiInvertMapping[ oCol.aDataSort[j] ];
|
170
171
|
}
|
172
|
+
|
173
|
+
// Update the column indexes
|
174
|
+
if ( v110 ) {
|
175
|
+
oCol.idx = aiInvertMapping[ oCol.idx ];
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
if ( v110 ) {
|
180
|
+
// Update 1.10 optimised sort class removal variable
|
181
|
+
$.each( oSettings.aLastSort, function (i, val) {
|
182
|
+
oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
|
183
|
+
} );
|
171
184
|
}
|
172
185
|
|
173
186
|
/* Update the Get and Set functions for each column */
|
@@ -176,8 +189,9 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
176
189
|
oCol = oSettings.aoColumns[i];
|
177
190
|
if ( typeof oCol.mData == 'number' ) {
|
178
191
|
oCol.mData = aiInvertMapping[ oCol.mData ];
|
179
|
-
|
180
|
-
|
192
|
+
|
193
|
+
// regenerate the get / set functions
|
194
|
+
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
|
181
195
|
}
|
182
196
|
}
|
183
197
|
|
@@ -228,7 +242,6 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
228
242
|
}
|
229
243
|
}
|
230
244
|
|
231
|
-
|
232
245
|
/*
|
233
246
|
* Move the internal array elements
|
234
247
|
*/
|
@@ -241,10 +254,28 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
241
254
|
/* Array array - internal data anodes cache */
|
242
255
|
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
243
256
|
{
|
244
|
-
|
245
|
-
|
257
|
+
var data = oSettings.aoData[i];
|
258
|
+
|
259
|
+
if ( v110 ) {
|
260
|
+
// DataTables 1.10+
|
261
|
+
if ( data.anCells ) {
|
262
|
+
fnArraySwitch( data.anCells, iFrom, iTo );
|
263
|
+
}
|
264
|
+
|
265
|
+
// For DOM sourced data, the invalidate will reread the cell into
|
266
|
+
// the data array, but for data sources as an array, they need to
|
267
|
+
// be flipped
|
268
|
+
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
|
269
|
+
fnArraySwitch( data._aData, iFrom, iTo );
|
270
|
+
}
|
271
|
+
}
|
272
|
+
else {
|
273
|
+
// DataTables 1.9-
|
274
|
+
if ( $.isArray( data._aData ) ) {
|
275
|
+
fnArraySwitch( data._aData, iFrom, iTo );
|
276
|
+
}
|
277
|
+
fnArraySwitch( data._anHidden, iFrom, iTo );
|
246
278
|
}
|
247
|
-
fnArraySwitch( oSettings.aoData[i]._anHidden, iFrom, iTo );
|
248
279
|
}
|
249
280
|
|
250
281
|
/* Reposition the header elements in the header layout array */
|
@@ -261,6 +292,11 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
261
292
|
}
|
262
293
|
}
|
263
294
|
|
295
|
+
// In 1.10 we need to invalidate row cached data for sorting, filtering etc
|
296
|
+
if ( v110 ) {
|
297
|
+
var api = new $.fn.dataTable.Api( oSettings );
|
298
|
+
api.rows().invalidate();
|
299
|
+
}
|
264
300
|
|
265
301
|
/*
|
266
302
|
* Update DataTables' event handlers
|
@@ -269,7 +305,7 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
269
305
|
/* Sort listener */
|
270
306
|
for ( i=0, iLen=iCols ; i<iLen ; i++ )
|
271
307
|
{
|
272
|
-
$(oSettings.aoColumns[i].nTh).
|
308
|
+
$(oSettings.aoColumns[i].nTh).off('click.DT');
|
273
309
|
this.oApi._fnSortAttachListener( oSettings, oSettings.aoColumns[i].nTh, i );
|
274
310
|
}
|
275
311
|
|
@@ -280,34 +316,58 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
|
280
316
|
"iTo": iTo,
|
281
317
|
"aiInvertMapping": aiInvertMapping
|
282
318
|
} ] );
|
283
|
-
|
284
|
-
if ( typeof oSettings.oInstance._oPluginFixedHeader != 'undefined' )
|
285
|
-
{
|
286
|
-
oSettings.oInstance._oPluginFixedHeader.fnUpdate();
|
287
|
-
}
|
288
319
|
};
|
289
320
|
|
290
321
|
|
291
322
|
|
323
|
+
var factory = function( $, DataTable ) {
|
324
|
+
"use strict";
|
292
325
|
|
293
326
|
/**
|
294
|
-
* ColReorder provides column
|
327
|
+
* ColReorder provides column visibility control for DataTables
|
295
328
|
* @class ColReorder
|
296
329
|
* @constructor
|
297
|
-
* @param {object} DataTables settings object
|
298
|
-
* @param {object} ColReorder options
|
330
|
+
* @param {object} dt DataTables settings object
|
331
|
+
* @param {object} opts ColReorder options
|
299
332
|
*/
|
300
|
-
ColReorder = function(
|
333
|
+
var ColReorder = function( dt, opts )
|
301
334
|
{
|
302
|
-
|
303
|
-
|
304
|
-
{
|
305
|
-
|
335
|
+
var oDTSettings;
|
336
|
+
|
337
|
+
if ( $.fn.dataTable.Api ) {
|
338
|
+
oDTSettings = new $.fn.dataTable.Api( dt ).settings()[0];
|
339
|
+
}
|
340
|
+
// 1.9 compatibility
|
341
|
+
else if ( dt.fnSettings ) {
|
342
|
+
// DataTables object, convert to the settings object
|
343
|
+
oDTSettings = dt.fnSettings();
|
344
|
+
}
|
345
|
+
else if ( typeof dt === 'string' ) {
|
346
|
+
// jQuery selector
|
347
|
+
if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
|
348
|
+
oDTSettings = $(dt).eq(0).dataTable().fnSettings();
|
349
|
+
}
|
350
|
+
}
|
351
|
+
else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
|
352
|
+
// Table node
|
353
|
+
if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
|
354
|
+
oDTSettings = $(dt.nodeName).dataTable().fnSettings();
|
355
|
+
}
|
356
|
+
}
|
357
|
+
else if ( dt instanceof jQuery ) {
|
358
|
+
// jQuery object
|
359
|
+
if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
|
360
|
+
oDTSettings = dt.eq(0).dataTable().fnSettings();
|
361
|
+
}
|
362
|
+
}
|
363
|
+
else {
|
364
|
+
// DataTables settings object
|
365
|
+
oDTSettings = dt;
|
306
366
|
}
|
307
367
|
|
308
|
-
|
309
|
-
{
|
310
|
-
|
368
|
+
// Convert from camelCase to Hungarian, just as DataTables does
|
369
|
+
if ( $.fn.dataTable.camelToHungarian ) {
|
370
|
+
$.fn.dataTable.camelToHungarian( ColReorder.defaults, opts || {} );
|
311
371
|
}
|
312
372
|
|
313
373
|
|
@@ -333,7 +393,7 @@ ColReorder = function( oDTSettings, oOpts )
|
|
333
393
|
* @type object
|
334
394
|
* @default {}
|
335
395
|
*/
|
336
|
-
"init":
|
396
|
+
"init": $.extend( true, {}, ColReorder.defaults, opts ),
|
337
397
|
|
338
398
|
/**
|
339
399
|
* Number of columns to fix (not allow to be reordered)
|
@@ -343,6 +403,14 @@ ColReorder = function( oDTSettings, oOpts )
|
|
343
403
|
*/
|
344
404
|
"fixed": 0,
|
345
405
|
|
406
|
+
/**
|
407
|
+
* Number of columns to fix counting from right (not allow to be reordered)
|
408
|
+
* @property fixedRight
|
409
|
+
* @type int
|
410
|
+
* @default 0
|
411
|
+
*/
|
412
|
+
"fixedRight": 0,
|
413
|
+
|
346
414
|
/**
|
347
415
|
* Callback function for once the reorder has been done
|
348
416
|
* @property dropcallback
|
@@ -401,13 +469,12 @@ ColReorder = function( oDTSettings, oOpts )
|
|
401
469
|
|
402
470
|
/* Constructor logic */
|
403
471
|
this.s.dt = oDTSettings.oInstance.fnSettings();
|
472
|
+
this.s.dt._colReorder = this;
|
404
473
|
this._fnConstruct();
|
405
474
|
|
406
475
|
/* Add destroy callback */
|
407
|
-
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback',
|
476
|
+
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
|
408
477
|
|
409
|
-
/* Store the instance for later use */
|
410
|
-
ColReorder.aoInstances.push( this );
|
411
478
|
return this;
|
412
479
|
};
|
413
480
|
|
@@ -418,6 +485,23 @@ ColReorder.prototype = {
|
|
418
485
|
* Public methods
|
419
486
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
420
487
|
|
488
|
+
/**
|
489
|
+
* Reset the column ordering to the original ordering that was detected on
|
490
|
+
* start up.
|
491
|
+
* @return {this} Returns `this` for chaining.
|
492
|
+
*
|
493
|
+
* @example
|
494
|
+
* // DataTables initialisation with ColReorder
|
495
|
+
* var table = $('#example').dataTable( {
|
496
|
+
* "sDom": 'Rlfrtip'
|
497
|
+
* } );
|
498
|
+
*
|
499
|
+
* // Add click event to a button to reset the ordering
|
500
|
+
* $('#resetOrdering').click( function (e) {
|
501
|
+
* e.preventDefault();
|
502
|
+
* $.fn.dataTable.ColReorder( table ).fnReset();
|
503
|
+
* } );
|
504
|
+
*/
|
421
505
|
"fnReset": function ()
|
422
506
|
{
|
423
507
|
var a = [];
|
@@ -427,6 +511,72 @@ ColReorder.prototype = {
|
|
427
511
|
}
|
428
512
|
|
429
513
|
this._fnOrderColumns( a );
|
514
|
+
|
515
|
+
return this;
|
516
|
+
},
|
517
|
+
|
518
|
+
/**
|
519
|
+
* `Deprecated` - Get the current order of the columns, as an array.
|
520
|
+
* @return {array} Array of column identifiers
|
521
|
+
* @deprecated `fnOrder` should be used in preference to this method.
|
522
|
+
* `fnOrder` acts as a getter/setter.
|
523
|
+
*/
|
524
|
+
"fnGetCurrentOrder": function ()
|
525
|
+
{
|
526
|
+
return this.fnOrder();
|
527
|
+
},
|
528
|
+
|
529
|
+
/**
|
530
|
+
* Get the current order of the columns, as an array. Note that the values
|
531
|
+
* given in the array are unique identifiers for each column. Currently
|
532
|
+
* these are the original ordering of the columns that was detected on
|
533
|
+
* start up, but this could potentially change in future.
|
534
|
+
* @return {array} Array of column identifiers
|
535
|
+
*
|
536
|
+
* @example
|
537
|
+
* // Get column ordering for the table
|
538
|
+
* var order = $.fn.dataTable.ColReorder( dataTable ).fnOrder();
|
539
|
+
*//**
|
540
|
+
* Set the order of the columns, from the positions identified in the
|
541
|
+
* ordering array given. Note that ColReorder takes a brute force approach
|
542
|
+
* to reordering, so it is possible multiple reordering events will occur
|
543
|
+
* before the final order is settled upon.
|
544
|
+
* @param {array} [set] Array of column identifiers in the new order. Note
|
545
|
+
* that every column must be included, uniquely, in this array.
|
546
|
+
* @return {this} Returns `this` for chaining.
|
547
|
+
*
|
548
|
+
* @example
|
549
|
+
* // Swap the first and second columns
|
550
|
+
* $.fn.dataTable.ColReorder( dataTable ).fnOrder( [1, 0, 2, 3, 4] );
|
551
|
+
*
|
552
|
+
* @example
|
553
|
+
* // Move the first column to the end for the table `#example`
|
554
|
+
* var curr = $.fn.dataTable.ColReorder( '#example' ).fnOrder();
|
555
|
+
* var first = curr.shift();
|
556
|
+
* curr.push( first );
|
557
|
+
* $.fn.dataTable.ColReorder( '#example' ).fnOrder( curr );
|
558
|
+
*
|
559
|
+
* @example
|
560
|
+
* // Reverse the table's order
|
561
|
+
* $.fn.dataTable.ColReorder( '#example' ).fnOrder(
|
562
|
+
* $.fn.dataTable.ColReorder( '#example' ).fnOrder().reverse()
|
563
|
+
* );
|
564
|
+
*/
|
565
|
+
"fnOrder": function ( set )
|
566
|
+
{
|
567
|
+
if ( set === undefined )
|
568
|
+
{
|
569
|
+
var a = [];
|
570
|
+
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
571
|
+
{
|
572
|
+
a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
|
573
|
+
}
|
574
|
+
return a;
|
575
|
+
}
|
576
|
+
|
577
|
+
this._fnOrderColumns( fnInvertKeyValues( set ) );
|
578
|
+
|
579
|
+
return this;
|
430
580
|
},
|
431
581
|
|
432
582
|
|
@@ -443,24 +593,30 @@ ColReorder.prototype = {
|
|
443
593
|
"_fnConstruct": function ()
|
444
594
|
{
|
445
595
|
var that = this;
|
446
|
-
var
|
596
|
+
var iLen = this.s.dt.aoColumns.length;
|
597
|
+
var i;
|
447
598
|
|
448
599
|
/* Columns discounted from reordering - counting left to right */
|
449
|
-
if (
|
600
|
+
if ( this.s.init.iFixedColumns )
|
450
601
|
{
|
451
602
|
this.s.fixed = this.s.init.iFixedColumns;
|
452
603
|
}
|
453
604
|
|
605
|
+
/* Columns discounted from reordering - counting right to left */
|
606
|
+
this.s.fixedRight = this.s.init.iFixedColumnsRight ?
|
607
|
+
this.s.init.iFixedColumnsRight :
|
608
|
+
0;
|
609
|
+
|
454
610
|
/* Drop callback initialisation option */
|
455
|
-
if (
|
611
|
+
if ( this.s.init.fnReorderCallback )
|
456
612
|
{
|
457
613
|
this.s.dropCallback = this.s.init.fnReorderCallback;
|
458
614
|
}
|
459
615
|
|
460
616
|
/* Add event handlers for the drag and drop, and also mark the original column order */
|
461
|
-
for ( i
|
617
|
+
for ( i = 0; i < iLen; i++ )
|
462
618
|
{
|
463
|
-
if ( i > this.s.fixed-1 )
|
619
|
+
if ( i > this.s.fixed-1 && i < iLen - this.s.fixedRight )
|
464
620
|
{
|
465
621
|
this._fnMouseListener( i, this.s.dt.aoColumns[i].nTh );
|
466
622
|
}
|
@@ -476,7 +632,7 @@ ColReorder.prototype = {
|
|
476
632
|
|
477
633
|
/* An initial column order has been specified */
|
478
634
|
var aiOrder = null;
|
479
|
-
if (
|
635
|
+
if ( this.s.init.aiOrder )
|
480
636
|
{
|
481
637
|
aiOrder = this.s.init.aiOrder.slice();
|
482
638
|
}
|
@@ -515,6 +671,9 @@ ColReorder.prototype = {
|
|
515
671
|
that._fnOrderColumns.call( that, resort );
|
516
672
|
}
|
517
673
|
}
|
674
|
+
else {
|
675
|
+
this._fnSetColumnIndexes();
|
676
|
+
}
|
518
677
|
},
|
519
678
|
|
520
679
|
|
@@ -530,7 +689,7 @@ ColReorder.prototype = {
|
|
530
689
|
if ( a.length != this.s.dt.aoColumns.length )
|
531
690
|
{
|
532
691
|
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
|
533
|
-
|
692
|
+
"match known number of columns. Skipping." );
|
534
693
|
return;
|
535
694
|
}
|
536
695
|
|
@@ -555,6 +714,8 @@ ColReorder.prototype = {
|
|
555
714
|
|
556
715
|
/* Save the state */
|
557
716
|
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
|
717
|
+
|
718
|
+
this._fnSetColumnIndexes();
|
558
719
|
},
|
559
720
|
|
560
721
|
|
@@ -578,7 +739,7 @@ ColReorder.prototype = {
|
|
578
739
|
oState.aaSorting[i][0] = oSettings.aoColumns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
|
579
740
|
}
|
580
741
|
|
581
|
-
aSearchCopy = $.extend( true, [], oState.aoSearchCols );
|
742
|
+
var aSearchCopy = $.extend( true, [], oState.aoSearchCols );
|
582
743
|
oState.ColReorder = [];
|
583
744
|
|
584
745
|
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
@@ -612,7 +773,7 @@ ColReorder.prototype = {
|
|
612
773
|
"_fnMouseListener": function ( i, nTh )
|
613
774
|
{
|
614
775
|
var that = this;
|
615
|
-
$(nTh).
|
776
|
+
$(nTh).on( 'mousedown.ColReorder', function (e) {
|
616
777
|
e.preventDefault();
|
617
778
|
that._fnMouseDown.call( that, e, nTh );
|
618
779
|
} );
|
@@ -629,65 +790,35 @@ ColReorder.prototype = {
|
|
629
790
|
*/
|
630
791
|
"_fnMouseDown": function ( e, nTh )
|
631
792
|
{
|
632
|
-
var
|
633
|
-
that = this,
|
634
|
-
aoColumns = this.s.dt.aoColumns;
|
793
|
+
var that = this;
|
635
794
|
|
636
795
|
/* Store information about the mouse position */
|
637
|
-
var
|
638
|
-
var offset =
|
796
|
+
var target = $(e.target).closest('th, td');
|
797
|
+
var offset = target.offset();
|
798
|
+
var idx = parseInt( $(nTh).attr('data-column-index'), 10 );
|
799
|
+
|
800
|
+
if ( idx === undefined ) {
|
801
|
+
return;
|
802
|
+
}
|
803
|
+
|
639
804
|
this.s.mouse.startX = e.pageX;
|
640
805
|
this.s.mouse.startY = e.pageY;
|
641
806
|
this.s.mouse.offsetX = e.pageX - offset.left;
|
642
807
|
this.s.mouse.offsetY = e.pageY - offset.top;
|
643
|
-
this.s.mouse.target = nTh;
|
644
|
-
this.s.mouse.targetIndex =
|
645
|
-
this.s.mouse.fromIndex =
|
646
|
-
this.s.mouse.targetIndex );
|
647
|
-
|
648
|
-
/* Calculate a cached array with the points of the column inserts, and the 'to' points */
|
649
|
-
this.s.aoTargets.splice( 0, this.s.aoTargets.length );
|
650
|
-
|
651
|
-
this.s.aoTargets.push( {
|
652
|
-
"x": $(this.s.dt.nTable).offset().left,
|
653
|
-
"to": 0
|
654
|
-
} );
|
655
|
-
|
656
|
-
var iToPoint = 0;
|
657
|
-
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
|
658
|
-
{
|
659
|
-
/* For the column / header in question, we want it's position to remain the same if the
|
660
|
-
* position is just to it's immediate left or right, so we only incremement the counter for
|
661
|
-
* other columns
|
662
|
-
*/
|
663
|
-
if ( i != this.s.mouse.fromIndex )
|
664
|
-
{
|
665
|
-
iToPoint++;
|
666
|
-
}
|
667
|
-
|
668
|
-
if ( aoColumns[i].bVisible )
|
669
|
-
{
|
670
|
-
this.s.aoTargets.push( {
|
671
|
-
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
|
672
|
-
"to": iToPoint
|
673
|
-
} );
|
674
|
-
}
|
675
|
-
}
|
808
|
+
this.s.mouse.target = this.s.dt.aoColumns[ idx ].nTh;//target[0];
|
809
|
+
this.s.mouse.targetIndex = idx;
|
810
|
+
this.s.mouse.fromIndex = idx;
|
676
811
|
|
677
|
-
|
678
|
-
if ( this.s.fixed !== 0 )
|
679
|
-
{
|
680
|
-
this.s.aoTargets.splice( 0, this.s.fixed );
|
681
|
-
}
|
812
|
+
this._fnRegions();
|
682
813
|
|
683
814
|
/* Add event handlers to the document */
|
684
|
-
$(document)
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
815
|
+
$(document)
|
816
|
+
.on( 'mousemove.ColReorder', function (e) {
|
817
|
+
that._fnMouseMove.call( that, e );
|
818
|
+
} )
|
819
|
+
.on( 'mouseup.ColReorder', function (e) {
|
820
|
+
that._fnMouseUp.call( that, e );
|
821
|
+
} );
|
691
822
|
},
|
692
823
|
|
693
824
|
|
@@ -718,30 +849,40 @@ ColReorder.prototype = {
|
|
718
849
|
}
|
719
850
|
|
720
851
|
/* Position the element - we respect where in the element the click occured */
|
721
|
-
this.dom.drag.
|
722
|
-
|
852
|
+
this.dom.drag.css( {
|
853
|
+
left: e.pageX - this.s.mouse.offsetX,
|
854
|
+
top: e.pageY - this.s.mouse.offsetY
|
855
|
+
} );
|
723
856
|
|
724
857
|
/* Based on the current mouse position, calculate where the insert should go */
|
725
858
|
var bSet = false;
|
859
|
+
var lastToIndex = this.s.mouse.toIndex;
|
860
|
+
|
726
861
|
for ( var i=1, iLen=this.s.aoTargets.length ; i<iLen ; i++ )
|
727
862
|
{
|
728
863
|
if ( e.pageX < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
|
729
864
|
{
|
730
|
-
this.dom.pointer.
|
865
|
+
this.dom.pointer.css( 'left', this.s.aoTargets[i-1].x );
|
731
866
|
this.s.mouse.toIndex = this.s.aoTargets[i-1].to;
|
732
867
|
bSet = true;
|
733
868
|
break;
|
734
869
|
}
|
735
870
|
}
|
736
871
|
|
737
|
-
|
738
|
-
|
739
|
-
*/
|
872
|
+
// The insert element wasn't positioned in the array (less than
|
873
|
+
// operator), so we put it at the end
|
740
874
|
if ( !bSet )
|
741
875
|
{
|
742
|
-
this.dom.pointer.
|
876
|
+
this.dom.pointer.css( 'left', this.s.aoTargets[this.s.aoTargets.length-1].x );
|
743
877
|
this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
|
744
878
|
}
|
879
|
+
|
880
|
+
// Perform reordering if realtime updating is on and the column has moved
|
881
|
+
if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
|
882
|
+
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
|
883
|
+
this.s.mouse.fromIndex = this.s.mouse.toIndex;
|
884
|
+
this._fnRegions();
|
885
|
+
}
|
745
886
|
},
|
746
887
|
|
747
888
|
|
@@ -756,19 +897,19 @@ ColReorder.prototype = {
|
|
756
897
|
{
|
757
898
|
var that = this;
|
758
899
|
|
759
|
-
$(document).
|
760
|
-
$(document).unbind( 'mouseup.ColReorder' );
|
900
|
+
$(document).off( 'mousemove.ColReorder mouseup.ColReorder' );
|
761
901
|
|
762
902
|
if ( this.dom.drag !== null )
|
763
903
|
{
|
764
904
|
/* Remove the guide elements */
|
765
|
-
|
766
|
-
|
905
|
+
this.dom.drag.remove();
|
906
|
+
this.dom.pointer.remove();
|
767
907
|
this.dom.drag = null;
|
768
908
|
this.dom.pointer = null;
|
769
909
|
|
770
910
|
/* Actually do the reorder */
|
771
911
|
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
|
912
|
+
this._fnSetColumnIndexes();
|
772
913
|
|
773
914
|
/* When scrolling we need to recalculate the column sizes to allow for the shift */
|
774
915
|
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
|
@@ -788,65 +929,108 @@ ColReorder.prototype = {
|
|
788
929
|
|
789
930
|
|
790
931
|
/**
|
791
|
-
*
|
792
|
-
*
|
793
|
-
* @method
|
932
|
+
* Calculate a cached array with the points of the column inserts, and the
|
933
|
+
* 'to' points
|
934
|
+
* @method _fnRegions
|
794
935
|
* @returns void
|
795
936
|
* @private
|
796
937
|
*/
|
797
|
-
"
|
938
|
+
"_fnRegions": function ()
|
798
939
|
{
|
799
|
-
var
|
800
|
-
|
801
|
-
this.dom.drag = $(this.s.dt.nTHead.parentNode).clone(true)[0];
|
802
|
-
this.dom.drag.className += " DTCR_clonedTable";
|
803
|
-
while ( this.dom.drag.getElementsByTagName('caption').length > 0 )
|
804
|
-
{
|
805
|
-
this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('caption')[0] );
|
806
|
-
}
|
807
|
-
while ( this.dom.drag.getElementsByTagName('tbody').length > 0 )
|
808
|
-
{
|
809
|
-
this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('tbody')[0] );
|
810
|
-
}
|
811
|
-
while ( this.dom.drag.getElementsByTagName('tfoot').length > 0 )
|
812
|
-
{
|
813
|
-
this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('tfoot')[0] );
|
814
|
-
}
|
815
|
-
|
816
|
-
$('thead tr:eq(0)', this.dom.drag).each( function () {
|
817
|
-
$('th', this).eq(that.s.mouse.targetIndex).siblings().remove();
|
818
|
-
} );
|
819
|
-
$('tr', this.dom.drag).height( $('tr:eq(0)', that.s.dt.nTHead).height() );
|
940
|
+
var aoColumns = this.s.dt.aoColumns;
|
820
941
|
|
821
|
-
|
942
|
+
this.s.aoTargets.splice( 0, this.s.aoTargets.length );
|
822
943
|
|
823
|
-
|
824
|
-
|
944
|
+
this.s.aoTargets.push( {
|
945
|
+
"x": $(this.s.dt.nTable).offset().left,
|
946
|
+
"to": 0
|
825
947
|
} );
|
826
948
|
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
949
|
+
var iToPoint = 0;
|
950
|
+
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
|
951
|
+
{
|
952
|
+
/* For the column / header in question, we want it's position to remain the same if the
|
953
|
+
* position is just to it's immediate left or right, so we only incremement the counter for
|
954
|
+
* other columns
|
955
|
+
*/
|
956
|
+
if ( i != this.s.mouse.fromIndex )
|
957
|
+
{
|
958
|
+
iToPoint++;
|
959
|
+
}
|
832
960
|
|
833
|
-
|
834
|
-
|
835
|
-
|
961
|
+
if ( aoColumns[i].bVisible )
|
962
|
+
{
|
963
|
+
this.s.aoTargets.push( {
|
964
|
+
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
|
965
|
+
"to": iToPoint
|
966
|
+
} );
|
967
|
+
}
|
968
|
+
}
|
836
969
|
|
837
|
-
|
970
|
+
/* Disallow columns for being reordered by drag and drop, counting right to left */
|
971
|
+
if ( this.s.fixedRight !== 0 )
|
838
972
|
{
|
839
|
-
this.
|
840
|
-
this.dom.pointer.style.height = $(this.s.dt.nTable).height()+"px";
|
973
|
+
this.s.aoTargets.splice( this.s.aoTargets.length - this.s.fixedRight );
|
841
974
|
}
|
842
|
-
|
975
|
+
|
976
|
+
/* Disallow columns for being reordered by drag and drop, counting left to right */
|
977
|
+
if ( this.s.fixed !== 0 )
|
843
978
|
{
|
844
|
-
this.
|
845
|
-
this.dom.pointer.style.height = $('div.dataTables_scroll', this.s.dt.nTableWrapper).height()+"px";
|
979
|
+
this.s.aoTargets.splice( 0, this.s.fixed );
|
846
980
|
}
|
981
|
+
},
|
982
|
+
|
847
983
|
|
848
|
-
|
849
|
-
|
984
|
+
/**
|
985
|
+
* Copy the TH element that is being drags so the user has the idea that they are actually
|
986
|
+
* moving it around the page.
|
987
|
+
* @method _fnCreateDragNode
|
988
|
+
* @returns void
|
989
|
+
* @private
|
990
|
+
*/
|
991
|
+
"_fnCreateDragNode": function ()
|
992
|
+
{
|
993
|
+
var scrolling = this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "";
|
994
|
+
|
995
|
+
var origCell = this.s.dt.aoColumns[ this.s.mouse.targetIndex ].nTh;
|
996
|
+
var origTr = origCell.parentNode;
|
997
|
+
var origThead = origTr.parentNode;
|
998
|
+
var origTable = origThead.parentNode;
|
999
|
+
var cloneCell = $(origCell).clone();
|
1000
|
+
|
1001
|
+
// This is a slightly odd combination of jQuery and DOM, but it is the
|
1002
|
+
// fastest and least resource intensive way I could think of cloning
|
1003
|
+
// the table with just a single header cell in it.
|
1004
|
+
this.dom.drag = $(origTable.cloneNode(false))
|
1005
|
+
.addClass( 'DTCR_clonedTable' )
|
1006
|
+
.append(
|
1007
|
+
origThead.cloneNode(false).appendChild(
|
1008
|
+
origTr.cloneNode(false).appendChild(
|
1009
|
+
cloneCell[0]
|
1010
|
+
)
|
1011
|
+
)
|
1012
|
+
)
|
1013
|
+
.css( {
|
1014
|
+
position: 'absolute',
|
1015
|
+
top: 0,
|
1016
|
+
left: 0,
|
1017
|
+
width: $(origCell).outerWidth(),
|
1018
|
+
height: $(origCell).outerHeight()
|
1019
|
+
} )
|
1020
|
+
.appendTo( 'body' );
|
1021
|
+
|
1022
|
+
this.dom.pointer = $('<div></div>')
|
1023
|
+
.addClass( 'DTCR_pointer' )
|
1024
|
+
.css( {
|
1025
|
+
position: 'absolute',
|
1026
|
+
top: scrolling ?
|
1027
|
+
$('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top :
|
1028
|
+
$(this.s.dt.nTable).offset().top,
|
1029
|
+
height : scrolling ?
|
1030
|
+
$('div.dataTables_scroll', this.s.dt.nTableWrapper).height() :
|
1031
|
+
$(this.s.dt.nTable).height()
|
1032
|
+
} )
|
1033
|
+
.appendTo( 'body' );
|
850
1034
|
},
|
851
1035
|
|
852
1036
|
/**
|
@@ -857,19 +1041,39 @@ ColReorder.prototype = {
|
|
857
1041
|
*/
|
858
1042
|
"_fnDestroy": function ()
|
859
1043
|
{
|
860
|
-
|
1044
|
+
var i, iLen;
|
1045
|
+
|
1046
|
+
for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; i<iLen ; i++ )
|
861
1047
|
{
|
862
|
-
if (
|
1048
|
+
if ( this.s.dt.aoDrawCallback[i].sName === 'ColReorder_Pre' )
|
863
1049
|
{
|
864
|
-
|
1050
|
+
this.s.dt.aoDrawCallback.splice( i, 1 );
|
865
1051
|
break;
|
866
1052
|
}
|
867
1053
|
}
|
868
1054
|
|
869
|
-
$(this.s.dt.nTHead).find( '*' ).
|
1055
|
+
$(this.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
|
1056
|
+
|
1057
|
+
$.each( this.s.dt.aoColumns, function (i, column) {
|
1058
|
+
$(column.nTh).removeAttr('data-column-index');
|
1059
|
+
} );
|
870
1060
|
|
871
|
-
this.s.dt.
|
1061
|
+
this.s.dt._colReorder = null;
|
872
1062
|
this.s = null;
|
1063
|
+
},
|
1064
|
+
|
1065
|
+
|
1066
|
+
/**
|
1067
|
+
* Add a data attribute to the column headers, so we know the index of
|
1068
|
+
* the row to be reordered. This allows fast detection of the index, and
|
1069
|
+
* for this plug-in to work with FixedHeader which clones the nodes.
|
1070
|
+
* @private
|
1071
|
+
*/
|
1072
|
+
"_fnSetColumnIndexes": function ()
|
1073
|
+
{
|
1074
|
+
$.each( this.s.dt.aoColumns, function (i, column) {
|
1075
|
+
$(column.nTh).attr('data-column-index', i);
|
1076
|
+
} );
|
873
1077
|
}
|
874
1078
|
};
|
875
1079
|
|
@@ -881,102 +1085,233 @@ ColReorder.prototype = {
|
|
881
1085
|
* Static parameters
|
882
1086
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
883
1087
|
|
1088
|
+
|
884
1089
|
/**
|
885
|
-
*
|
886
|
-
* @
|
887
|
-
* @type array
|
888
|
-
* @default []
|
1090
|
+
* ColReorder default settings for initialisation
|
1091
|
+
* @namespace
|
889
1092
|
* @static
|
890
1093
|
*/
|
891
|
-
ColReorder.
|
892
|
-
|
893
|
-
|
1094
|
+
ColReorder.defaults = {
|
1095
|
+
/**
|
1096
|
+
* Predefined ordering for the columns that will be applied automatically
|
1097
|
+
* on initialisation. If not specified then the order that the columns are
|
1098
|
+
* found to be in the HTML is the order used.
|
1099
|
+
* @type array
|
1100
|
+
* @default null
|
1101
|
+
* @static
|
1102
|
+
* @example
|
1103
|
+
* // Using the `oColReorder` option in the DataTables options object
|
1104
|
+
* $('#example').dataTable( {
|
1105
|
+
* "sDom": 'Rlfrtip',
|
1106
|
+
* "oColReorder": {
|
1107
|
+
* "aiOrder": [ 4, 3, 2, 1, 0 ]
|
1108
|
+
* }
|
1109
|
+
* } );
|
1110
|
+
*
|
1111
|
+
* @example
|
1112
|
+
* // Using `new` constructor
|
1113
|
+
* $('#example').dataTable()
|
1114
|
+
*
|
1115
|
+
* new $.fn.dataTable.ColReorder( '#example', {
|
1116
|
+
* "aiOrder": [ 4, 3, 2, 1, 0 ]
|
1117
|
+
* } );
|
1118
|
+
*/
|
1119
|
+
aiOrder: null,
|
894
1120
|
|
1121
|
+
/**
|
1122
|
+
* Redraw the table's column ordering as the end user draws the column
|
1123
|
+
* (`true`) or wait until the mouse is released (`false` - default). Note
|
1124
|
+
* that this will perform a redraw on each reordering, which involves an
|
1125
|
+
* Ajax request each time if you are using server-side processing in
|
1126
|
+
* DataTables.
|
1127
|
+
* @type boolean
|
1128
|
+
* @default false
|
1129
|
+
* @static
|
1130
|
+
* @example
|
1131
|
+
* // Using the `oColReorder` option in the DataTables options object
|
1132
|
+
* $('#example').dataTable( {
|
1133
|
+
* "sDom": 'Rlfrtip',
|
1134
|
+
* "oColReorder": {
|
1135
|
+
* "bRealtime": true
|
1136
|
+
* }
|
1137
|
+
* } );
|
1138
|
+
*
|
1139
|
+
* @example
|
1140
|
+
* // Using `new` constructor
|
1141
|
+
* $('#example').dataTable()
|
1142
|
+
*
|
1143
|
+
* new $.fn.dataTable.ColReorder( '#example', {
|
1144
|
+
* "bRealtime": true
|
1145
|
+
* } );
|
1146
|
+
*/
|
1147
|
+
bRealtime: false,
|
895
1148
|
|
1149
|
+
/**
|
1150
|
+
* Indicate how many columns should be fixed in position (counting from the
|
1151
|
+
* left). This will typically be 1 if used, but can be as high as you like.
|
1152
|
+
* @type int
|
1153
|
+
* @default 0
|
1154
|
+
* @static
|
1155
|
+
* @example
|
1156
|
+
* // Using the `oColReorder` option in the DataTables options object
|
1157
|
+
* $('#example').dataTable( {
|
1158
|
+
* "sDom": 'Rlfrtip',
|
1159
|
+
* "oColReorder": {
|
1160
|
+
* "iFixedColumns": 1
|
1161
|
+
* }
|
1162
|
+
* } );
|
1163
|
+
*
|
1164
|
+
* @example
|
1165
|
+
* // Using `new` constructor
|
1166
|
+
* $('#example').dataTable()
|
1167
|
+
*
|
1168
|
+
* new $.fn.dataTable.ColReorder( '#example', {
|
1169
|
+
* "iFixedColumns": 1
|
1170
|
+
* } );
|
1171
|
+
*/
|
1172
|
+
iFixedColumns: 0,
|
896
1173
|
|
897
|
-
|
898
|
-
|
899
|
-
|
1174
|
+
/**
|
1175
|
+
* As `iFixedColumnsRight` but counting from the right.
|
1176
|
+
* @type int
|
1177
|
+
* @default 0
|
1178
|
+
* @static
|
1179
|
+
* @example
|
1180
|
+
* // Using the `oColReorder` option in the DataTables options object
|
1181
|
+
* $('#example').dataTable( {
|
1182
|
+
* "sDom": 'Rlfrtip',
|
1183
|
+
* "oColReorder": {
|
1184
|
+
* "iFixedColumnsRight": 1
|
1185
|
+
* }
|
1186
|
+
* } );
|
1187
|
+
*
|
1188
|
+
* @example
|
1189
|
+
* // Using `new` constructor
|
1190
|
+
* $('#example').dataTable()
|
1191
|
+
*
|
1192
|
+
* new $.fn.dataTable.ColReorder( '#example', {
|
1193
|
+
* "iFixedColumnsRight": 1
|
1194
|
+
* } );
|
1195
|
+
*/
|
1196
|
+
iFixedColumnsRight: 0,
|
900
1197
|
|
901
|
-
/**
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
1198
|
+
/**
|
1199
|
+
* Callback function that is fired when columns are reordered
|
1200
|
+
* @type function():void
|
1201
|
+
* @default null
|
1202
|
+
* @static
|
1203
|
+
* @example
|
1204
|
+
* // Using the `oColReorder` option in the DataTables options object
|
1205
|
+
* $('#example').dataTable( {
|
1206
|
+
* "sDom": 'Rlfrtip',
|
1207
|
+
* "oColReorder": {
|
1208
|
+
* "fnReorderCallback": function () {
|
1209
|
+
* alert( 'Columns reordered' );
|
1210
|
+
* }
|
1211
|
+
* }
|
1212
|
+
* } );
|
1213
|
+
*
|
1214
|
+
* @example
|
1215
|
+
* // Using `new` constructor
|
1216
|
+
* $('#example').dataTable()
|
1217
|
+
*
|
1218
|
+
* new $.fn.dataTable.ColReorder( '#example', {
|
1219
|
+
* "fnReorderCallback": function () {
|
1220
|
+
* alert( 'Columns reordered' );
|
1221
|
+
* }
|
1222
|
+
* } );
|
1223
|
+
*/
|
1224
|
+
fnReorderCallback: null
|
917
1225
|
};
|
918
1226
|
|
919
1227
|
|
920
1228
|
|
921
|
-
|
922
|
-
|
923
1229
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
924
1230
|
* Constants
|
925
1231
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
926
1232
|
|
927
|
-
/**
|
928
|
-
* Name of this class
|
929
|
-
* @constant CLASS
|
930
|
-
* @type String
|
931
|
-
* @default ColReorder
|
932
|
-
*/
|
933
|
-
ColReorder.prototype.CLASS = "ColReorder";
|
934
|
-
|
935
|
-
|
936
1233
|
/**
|
937
1234
|
* ColReorder version
|
938
|
-
* @constant
|
1235
|
+
* @constant version
|
939
1236
|
* @type String
|
940
1237
|
* @default As code
|
941
1238
|
*/
|
942
|
-
ColReorder.
|
943
|
-
ColReorder.prototype.VERSION = ColReorder.VERSION;
|
944
|
-
|
945
|
-
|
1239
|
+
ColReorder.version = "1.1.1";
|
946
1240
|
|
947
1241
|
|
948
1242
|
|
949
1243
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
950
|
-
*
|
1244
|
+
* DataTables interfaces
|
951
1245
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
952
1246
|
|
953
|
-
|
954
|
-
|
955
|
-
|
1247
|
+
// Expose
|
1248
|
+
$.fn.dataTable.ColReorder = ColReorder;
|
1249
|
+
$.fn.DataTable.ColReorder = ColReorder;
|
1250
|
+
|
1251
|
+
|
1252
|
+
// Register a new feature with DataTables
|
956
1253
|
if ( typeof $.fn.dataTable == "function" &&
|
957
1254
|
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
|
958
1255
|
$.fn.dataTableExt.fnVersionCheck('1.9.3') )
|
959
1256
|
{
|
960
1257
|
$.fn.dataTableExt.aoFeatures.push( {
|
961
|
-
"fnInit": function(
|
962
|
-
var
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
1258
|
+
"fnInit": function( settings ) {
|
1259
|
+
var table = settings.oInstance;
|
1260
|
+
|
1261
|
+
if ( ! settings._colReorder ) {
|
1262
|
+
var dtInit = settings.oInit;
|
1263
|
+
var opts = dtInit.colReorder || dtInit.oColReorder || {};
|
1264
|
+
|
1265
|
+
new ColReorder( settings, opts );
|
1266
|
+
}
|
1267
|
+
else {
|
1268
|
+
table.oApi._fnLog( settings, 1, "ColReorder attempted to initialise twice. Ignoring second" );
|
969
1269
|
}
|
970
1270
|
|
971
|
-
return null; /* No node to insert */
|
1271
|
+
return null; /* No node for DataTables to insert */
|
972
1272
|
},
|
973
1273
|
"cFeature": "R",
|
974
1274
|
"sFeature": "ColReorder"
|
975
1275
|
} );
|
976
1276
|
}
|
977
|
-
else
|
978
|
-
{
|
1277
|
+
else {
|
979
1278
|
alert( "Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");
|
980
1279
|
}
|
981
1280
|
|
982
|
-
|
1281
|
+
|
1282
|
+
// API augmentation
|
1283
|
+
if ( $.fn.dataTable.Api ) {
|
1284
|
+
$.fn.dataTable.Api.register( 'colReorder.reset()', function () {
|
1285
|
+
return this.iterator( 'table', function ( ctx ) {
|
1286
|
+
ctx._colReorder.fnReset();
|
1287
|
+
} );
|
1288
|
+
} );
|
1289
|
+
|
1290
|
+
$.fn.dataTable.Api.register( 'colReorder.order()', function ( set ) {
|
1291
|
+
if ( set ) {
|
1292
|
+
return this.iterator( 'table', function ( ctx ) {
|
1293
|
+
ctx._colReorder.fnOrder( set );
|
1294
|
+
} );
|
1295
|
+
}
|
1296
|
+
|
1297
|
+
return this.context.length ?
|
1298
|
+
this.context[0]._colReorder.fnOrder() :
|
1299
|
+
null;
|
1300
|
+
} );
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
return ColReorder;
|
1304
|
+
}; // /factory
|
1305
|
+
|
1306
|
+
|
1307
|
+
// Define as an AMD module if possible
|
1308
|
+
if ( typeof define === 'function' && define.amd ) {
|
1309
|
+
define( 'datatables-colreorder', ['jquery', 'datatables'], factory );
|
1310
|
+
}
|
1311
|
+
else if ( jQuery && !jQuery.fn.dataTable.ColReorder ) {
|
1312
|
+
// Otherwise simply initialise as normal, stopping multiple evaluation
|
1313
|
+
factory( jQuery, jQuery.fn.dataTable );
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
|
1317
|
+
})(window, document);
|