Skip to content

Commit 7e13e58

Browse files
Merge pull request #121 from joelbarker2011/master
Update DT extensions to match DT v1.10.2
2 parents 55b7f9f + c2073e9 commit 7e13e58

14 files changed

+1272
-788
lines changed

app/assets/javascripts/dataTables/extras/dataTables.autoFill.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/*! AutoFill 1.2.0
1+
/*! AutoFill 1.2.1
22
* ©2008-2014 SpryMedia Ltd - datatables.net/license
33
*/
44

55
/**
66
* @summary AutoFill
77
* @description Add Excel like click and drag auto-fill options to DataTables
8-
* @version 1.2.0
8+
* @version 1.2.1
99
* @file dataTables.autoFill.js
1010
* @author SpryMedia Ltd (www.sprymedia.co.uk)
1111
* @contact www.sprymedia.co.uk/contact
@@ -720,7 +720,7 @@ DataTable.AutoFill = AutoFill;
720720
* @type String
721721
* @default See code
722722
*/
723-
AutoFill.version = "1.2.0";
723+
AutoFill.version = "1.2.1";
724724

725725

726726
/**
@@ -839,7 +839,11 @@ return AutoFill;
839839

840840
// Define as an AMD module if possible
841841
if ( typeof define === 'function' && define.amd ) {
842-
define( 'datatables-autofill', ['jquery', 'datatables'], factory );
842+
define( ['jquery', 'datatables'], factory );
843+
}
844+
else if ( typeof exports === 'object' ) {
845+
// Node/CommonJS
846+
factory( require('jquery'), require('datatables') );
843847
}
844848
else if ( jQuery && !jQuery.fn.dataTable.AutoFill ) {
845849
// Otherwise simply initialise as normal, stopping multiple evaluation

app/assets/javascripts/dataTables/extras/dataTables.colReorder.js

+75-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/*! ColReorder 1.1.1
1+
/*! ColReorder 1.1.2
22
* ©2010-2014 SpryMedia Ltd - datatables.net/license
33
*/
44

55
/**
66
* @summary ColReorder
77
* @description Provide the ability to reorder columns in a DataTable
8-
* @version 1.1.1
8+
* @version 1.1.2
99
* @file dataTables.colReorder.js
1010
* @author SpryMedia Ltd (www.sprymedia.co.uk)
1111
* @contact www.sprymedia.co.uk/contact
@@ -111,6 +111,20 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
111111
{
112112
var v110 = $.fn.dataTable.Api ? true : false;
113113
var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
114+
var attrMap = function ( obj, prop, mapping ) {
115+
if ( ! obj[ prop ] ) {
116+
return;
117+
}
118+
119+
var a = obj[ prop ].split('.');
120+
var num = a.shift();
121+
122+
if ( isNaN( num*1 ) ) {
123+
return;
124+
}
125+
126+
obj[ prop ] = mapping[ num*1 ]+'.'+a.join('.');
127+
};
114128

115129
/* Sanity check in the input */
116130
if ( iFrom == iTo )
@@ -187,9 +201,20 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
187201
for ( i=0, iLen=iCols ; i<iLen ; i++ )
188202
{
189203
oCol = oSettings.aoColumns[i];
204+
190205
if ( typeof oCol.mData == 'number' ) {
191206
oCol.mData = aiInvertMapping[ oCol.mData ];
192207

208+
// regenerate the get / set functions
209+
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
210+
}
211+
else if ( $.isPlainObject( oCol.mData ) ) {
212+
// HTML5 data sourced
213+
attrMap( oCol.mData, '_', aiInvertMapping );
214+
attrMap( oCol.mData, 'filter', aiInvertMapping );
215+
attrMap( oCol.mData, 'sort', aiInvertMapping );
216+
attrMap( oCol.mData, 'type', aiInvertMapping );
217+
193218
// regenerate the get / set functions
194219
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
195220
}
@@ -366,8 +391,10 @@ var ColReorder = function( dt, opts )
366391
}
367392

368393
// Convert from camelCase to Hungarian, just as DataTables does
369-
if ( $.fn.dataTable.camelToHungarian ) {
370-
$.fn.dataTable.camelToHungarian( ColReorder.defaults, opts || {} );
394+
var camelToHungarian = $.fn.dataTable.camelToHungarian;
395+
if ( camelToHungarian ) {
396+
camelToHungarian( ColReorder.defaults, ColReorder.defaults, true );
397+
camelToHungarian( ColReorder.defaults, opts || {} );
371398
}
372399

373400

@@ -732,28 +759,51 @@ ColReorder.prototype = {
732759
{
733760
var i, iLen, aCopy, iOrigColumn;
734761
var oSettings = this.s.dt;
762+
var columns = oSettings.aoColumns;
763+
764+
oState.ColReorder = [];
735765

736766
/* Sorting */
737-
for ( i=0 ; i<oState.aaSorting.length ; i++ )
738-
{
739-
oState.aaSorting[i][0] = oSettings.aoColumns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
740-
}
767+
if ( oState.aaSorting ) {
768+
// 1.10.0-
769+
for ( i=0 ; i<oState.aaSorting.length ; i++ ) {
770+
oState.aaSorting[i][0] = columns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
771+
}
741772

742-
var aSearchCopy = $.extend( true, [], oState.aoSearchCols );
743-
oState.ColReorder = [];
773+
var aSearchCopy = $.extend( true, [], oState.aoSearchCols );
744774

745-
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
746-
{
747-
iOrigColumn = oSettings.aoColumns[i]._ColReorder_iOrigCol;
775+
for ( i=0, iLen=columns.length ; i<iLen ; i++ )
776+
{
777+
iOrigColumn = columns[i]._ColReorder_iOrigCol;
748778

749-
/* Column filter */
750-
oState.aoSearchCols[ iOrigColumn ] = aSearchCopy[i];
779+
/* Column filter */
780+
oState.aoSearchCols[ iOrigColumn ] = aSearchCopy[i];
751781

752-
/* Visibility */
753-
oState.abVisCols[ iOrigColumn ] = oSettings.aoColumns[i].bVisible;
782+
/* Visibility */
783+
oState.abVisCols[ iOrigColumn ] = columns[i].bVisible;
754784

755-
/* Column reordering */
756-
oState.ColReorder.push( iOrigColumn );
785+
/* Column reordering */
786+
oState.ColReorder.push( iOrigColumn );
787+
}
788+
}
789+
else if ( oState.order ) {
790+
// 1.10.1+
791+
for ( i=0 ; i<oState.order.length ; i++ ) {
792+
oState.order[i][0] = columns[ oState.order[i][0] ]._ColReorder_iOrigCol;
793+
}
794+
795+
var stateColumnsCopy = $.extend( true, [], oState.columns );
796+
797+
for ( i=0, iLen=columns.length ; i<iLen ; i++ )
798+
{
799+
iOrigColumn = columns[i]._ColReorder_iOrigCol;
800+
801+
/* Columns */
802+
oState.columns[ iOrigColumn ] = stateColumnsCopy[i];
803+
804+
/* Column reordering */
805+
oState.ColReorder.push( iOrigColumn );
806+
}
757807
}
758808
},
759809

@@ -1236,7 +1286,7 @@ ColReorder.defaults = {
12361286
* @type String
12371287
* @default As code
12381288
*/
1239-
ColReorder.version = "1.1.1";
1289+
ColReorder.version = "1.1.2";
12401290

12411291

12421292

@@ -1306,7 +1356,11 @@ return ColReorder;
13061356

13071357
// Define as an AMD module if possible
13081358
if ( typeof define === 'function' && define.amd ) {
1309-
define( 'datatables-colreorder', ['jquery', 'datatables'], factory );
1359+
define( ['jquery', 'datatables'], factory );
1360+
}
1361+
else if ( typeof exports === 'object' ) {
1362+
// Node/CommonJS
1363+
factory( require('jquery'), require('datatables') );
13101364
}
13111365
else if ( jQuery && !jQuery.fn.dataTable.ColReorder ) {
13121366
// Otherwise simply initialise as normal, stopping multiple evaluation

app/assets/javascripts/dataTables/extras/dataTables.colVis.js

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/*! ColVis 1.1.0
1+
/*! ColVis 1.1.1
22
* ©2010-2014 SpryMedia Ltd - datatables.net/license
33
*/
44

55
/**
66
* @summary ColVis
77
* @description Controls for column visibility in DataTables
8-
* @version 1.1.0
8+
* @version 1.1.1
99
* @file dataTables.colReorder.js
1010
* @author SpryMedia Ltd (www.sprymedia.co.uk)
1111
* @contact www.sprymedia.co.uk/contact
@@ -463,11 +463,18 @@ ColVis.prototype = {
463463

464464
if ( this.s.showAll )
465465
{
466-
nButton = this._fnDomShowAllButton();
466+
nButton = this._fnDomShowXButton( this.s.showAll, true );
467467
nButton.className += " ColVis_ShowAll";
468468
this.dom.buttons.push( nButton );
469469
}
470470

471+
if ( this.s.showNone )
472+
{
473+
nButton = this._fnDomShowXButton( this.s.showNone, false );
474+
nButton.className += " ColVis_ShowNone";
475+
this.dom.buttons.push( nButton );
476+
}
477+
471478
$(this.dom.collection).append( this.dom.buttons );
472479
},
473480

@@ -502,28 +509,28 @@ ColVis.prototype = {
502509

503510

504511
/**
505-
* Create a button which allows a "show all" action
506-
* @method _fnDomShowAllButton
512+
* Create a button which allows show all and show node actions
513+
* @method _fnDomShowXButton
507514
* @returns {Node} Created button
508515
* @private
509516
*/
510-
"_fnDomShowAllButton": function ()
517+
"_fnDomShowXButton": function ( str, action )
511518
{
512519
var
513520
that = this,
514521
dt = this.s.dt;
515522

516523
return $(
517524
'<li class="ColVis_Special '+(dt.bJUI ? 'ui-button ui-state-default' : '')+'">'+
518-
this.s.showAll+
525+
str+
519526
'</li>'
520527
)
521528
.click( function (e) {
522529
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
523530
{
524531
if (that.s.aiExclude.indexOf(i) === -1)
525532
{
526-
that.s.dt.oInstance.fnSetColumnVis( i, true, false );
533+
that.s.dt.oInstance.fnSetColumnVis( i, action, false );
527534
}
528535
}
529536
that._fnAdjustOpenRows();
@@ -627,7 +634,7 @@ ColVis.prototype = {
627634

628635
$.fn.dataTableExt.iApiIndex = oldIndex; /* Restore */
629636

630-
if ( that.s.fnStateChange !== null )
637+
if ( e.target.nodeName.toLowerCase() === 'input' && that.s.fnStateChange !== null )
631638
{
632639
that.s.fnStateChange.call( that, i, showHide );
633640
}
@@ -1039,7 +1046,7 @@ ColVis.prototype.CLASS = "ColVis";
10391046
* @type String
10401047
* @default See code
10411048
*/
1042-
ColVis.VERSION = "1.1.0";
1049+
ColVis.VERSION = "1.1.1";
10431050
ColVis.prototype.VERSION = ColVis.VERSION;
10441051

10451052

@@ -1084,7 +1091,11 @@ return ColVis;
10841091

10851092
// Define as an AMD module if possible
10861093
if ( typeof define === 'function' && define.amd ) {
1087-
define( 'datatables-colvis', ['jquery', 'datatables'], factory );
1094+
define( ['jquery', 'datatables'], factory );
1095+
}
1096+
else if ( typeof exports === 'object' ) {
1097+
// Node/CommonJS
1098+
factory( require('jquery'), require('datatables') );
10881099
}
10891100
else if ( jQuery && !jQuery.fn.dataTable.ColVis ) {
10901101
// Otherwise simply initialise as normal, stopping multiple evaluation

0 commit comments

Comments
 (0)