jquery-datatables-rails 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/dataTables/bootstrap/2/jquery.dataTables.bootstrap.js +110 -96
  3. data/app/assets/javascripts/dataTables/bootstrap/3/jquery.dataTables.bootstrap.js +6 -6
  4. data/app/assets/javascripts/dataTables/extras/dataTables.colReorder.js +28 -27
  5. data/app/assets/javascripts/dataTables/extras/dataTables.colVis.js +27 -11
  6. data/app/assets/javascripts/dataTables/extras/dataTables.fixedColumns.js +53 -29
  7. data/app/assets/javascripts/dataTables/extras/dataTables.responsive.js +110 -47
  8. data/app/assets/javascripts/dataTables/extras/dataTables.tableTools.js +90 -25
  9. data/app/assets/javascripts/dataTables/jquery.dataTables.foundation.js +133 -139
  10. data/app/assets/javascripts/dataTables/jquery.dataTables.js +483 -375
  11. data/app/assets/javascripts/dataTables/jquery.dataTables.sorting.numbersHtml.js +37 -14
  12. data/app/assets/javascripts/dataTables/jquery.dataTables.typeDetection.numbersHtml.js +49 -33
  13. data/app/assets/media/dataTables/extras/swf/copy_csv_xls.swf +0 -0
  14. data/app/assets/media/dataTables/extras/swf/copy_csv_xls_pdf.swf +0 -0
  15. data/app/assets/stylesheets/dataTables/bootstrap/2/jquery.dataTables.bootstrap.scss +34 -9
  16. data/app/assets/stylesheets/dataTables/bootstrap/3/jquery.dataTables.bootstrap.scss +122 -31
  17. data/app/assets/stylesheets/dataTables/extras/dataTables.colvis.jqueryui.scss +18 -0
  18. data/app/assets/stylesheets/dataTables/extras/dataTables.fixedColumns.scss +1 -0
  19. data/app/assets/stylesheets/dataTables/extras/dataTables.responsive.scss +29 -12
  20. data/app/assets/stylesheets/dataTables/extras/dataTables.tableTools.scss +43 -19
  21. data/app/assets/stylesheets/dataTables/jquery.dataTables.foundation.scss +15 -4
  22. data/app/assets/stylesheets/dataTables/jquery.dataTables.scss +22 -11
  23. data/lib/jquery/datatables/rails/version.rb +1 -1
  24. metadata +18 -18
@@ -1,5 +1,5 @@
1
- /*! TableTools 2.2.2
2
- * 2009-2014 SpryMedia Ltd - datatables.net/license
1
+ /*! TableTools 2.2.4
2
+ * 2009-2015 SpryMedia Ltd - datatables.net/license
3
3
  *
4
4
  * ZeroClipboard 1.0.4
5
5
  * Author: Joseph Huckaby - MIT licensed
@@ -8,11 +8,11 @@
8
8
  /**
9
9
  * @summary TableTools
10
10
  * @description Tools and buttons for DataTables
11
- * @version 2.2.2
11
+ * @version 2.2.4
12
12
  * @file dataTables.tableTools.js
13
13
  * @author SpryMedia Ltd (www.sprymedia.co.uk)
14
14
  * @contact www.sprymedia.co.uk/contact
15
- * @copyright Copyright 2009-2014 SpryMedia Ltd.
15
+ * @copyright Copyright 2009-2015 SpryMedia Ltd.
16
16
  *
17
17
  * This source file is free software, available under the following license:
18
18
  * MIT license - http://datatables.net/license/mit
@@ -434,7 +434,7 @@ ZeroClipboard_TableTools.Client.prototype = {
434
434
  window.ZeroClipboard_TableTools = ZeroClipboard_TableTools;
435
435
  //include TableTools.js
436
436
  /* TableTools
437
- * 2009-2014 SpryMedia Ltd - datatables.net/license
437
+ * 2009-2015 SpryMedia Ltd - datatables.net/license
438
438
  */
439
439
 
440
440
  /*globals TableTools,ZeroClipboard_TableTools*/
@@ -1157,7 +1157,11 @@ TableTools.prototype = {
1157
1157
  this.s.dt.aoDestroyCallback.push( {
1158
1158
  "sName": "TableTools",
1159
1159
  "fn": function () {
1160
- $(that.s.dt.nTBody).off( 'click.DTTT_Select', 'tr' );
1160
+ $(that.s.dt.nTBody)
1161
+ .off( 'click.DTTT_Select', that.s.custom.sRowSelector )
1162
+ .off( 'mousedown.DTTT_Select', 'tr' )
1163
+ .off( 'mouseup.DTTT_Select', 'tr' );
1164
+
1161
1165
  $(that.dom.container).empty();
1162
1166
 
1163
1167
  // Remove the instance
@@ -1298,6 +1302,33 @@ TableTools.prototype = {
1298
1302
  this._fnCollectionConfig( nButton, oConfig );
1299
1303
  }
1300
1304
 
1305
+ if ( this.s.dt.iTabIndex !== -1 ) {
1306
+ $(nButton)
1307
+ .attr( 'tabindex', this.s.dt.iTabIndex )
1308
+ .attr( 'aria-controls', this.s.dt.sTableId )
1309
+ .on( 'keyup.DTTT', function (e) {
1310
+ // Trigger the click event on return key when focused.
1311
+ // Note that for Flash buttons this has no effect since we
1312
+ // can't programmatically trigger the Flash export
1313
+ if ( e.keyCode === 13 ) {
1314
+ e.stopPropagation();
1315
+
1316
+ $(this).trigger( 'click' );
1317
+ }
1318
+ } )
1319
+ .on( 'mousedown.DTTT', function (e) {
1320
+ // On mousedown we want to stop the focus occurring on the
1321
+ // button, focus is used only for the keyboard navigation.
1322
+ // But using preventDefault for the flash buttons stops the
1323
+ // flash action. However, it is not the button that gets
1324
+ // focused but the flash element for flash buttons, so this
1325
+ // works
1326
+ if ( ! oConfig.sAction.match(/flash/) ) {
1327
+ e.preventDefault();
1328
+ }
1329
+ } );
1330
+ }
1331
+
1301
1332
  return nButton;
1302
1333
  },
1303
1334
 
@@ -1778,6 +1809,10 @@ TableTools.prototype = {
1778
1809
 
1779
1810
  return out;
1780
1811
  }
1812
+ else if ( typeof src === 'number' )
1813
+ {
1814
+ out.push(this.s.dt.aoData[src]);
1815
+ }
1781
1816
  else
1782
1817
  {
1783
1818
  // A single aoData point
@@ -1951,6 +1986,13 @@ TableTools.prototype = {
1951
1986
  that._fnCollectionHide( nButton, oConfig );
1952
1987
  } );
1953
1988
 
1989
+ if ( oConfig.fnSelect !== null )
1990
+ {
1991
+ TableTools._fnEventListen( this, 'select', function (n) {
1992
+ oConfig.fnSelect.call( that, nButton, oConfig, n );
1993
+ } );
1994
+ }
1995
+
1954
1996
  this._fnFlashGlue( flash, nButton, oConfig.sToolTip );
1955
1997
  },
1956
1998
 
@@ -2030,10 +2072,21 @@ TableTools.prototype = {
2030
2072
  var aColumns = [];
2031
2073
  var dt = this.s.dt;
2032
2074
  var i, iLen;
2075
+ var columns = dt.aoColumns;
2076
+ var columnCount = columns.length;
2033
2077
 
2034
- if ( typeof mColumns == "object" )
2078
+ if ( typeof mColumns == "function" )
2035
2079
  {
2036
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
2080
+ var a = mColumns.call( this, dt );
2081
+
2082
+ for ( i=0, iLen=columnCount ; i<iLen ; i++ )
2083
+ {
2084
+ aColumns.push( $.inArray( i, a ) !== -1 ? true : false );
2085
+ }
2086
+ }
2087
+ else if ( typeof mColumns == "object" )
2088
+ {
2089
+ for ( i=0, iLen=columnCount ; i<iLen ; i++ )
2037
2090
  {
2038
2091
  aColumns.push( false );
2039
2092
  }
@@ -2045,28 +2098,28 @@ TableTools.prototype = {
2045
2098
  }
2046
2099
  else if ( mColumns == "visible" )
2047
2100
  {
2048
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
2101
+ for ( i=0, iLen=columnCount ; i<iLen ; i++ )
2049
2102
  {
2050
- aColumns.push( dt.aoColumns[i].bVisible ? true : false );
2103
+ aColumns.push( columns[i].bVisible ? true : false );
2051
2104
  }
2052
2105
  }
2053
2106
  else if ( mColumns == "hidden" )
2054
2107
  {
2055
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
2108
+ for ( i=0, iLen=columnCount ; i<iLen ; i++ )
2056
2109
  {
2057
- aColumns.push( dt.aoColumns[i].bVisible ? false : true );
2110
+ aColumns.push( columns[i].bVisible ? false : true );
2058
2111
  }
2059
2112
  }
2060
2113
  else if ( mColumns == "sortable" )
2061
2114
  {
2062
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
2115
+ for ( i=0, iLen=columnCount ; i<iLen ; i++ )
2063
2116
  {
2064
- aColumns.push( dt.aoColumns[i].bSortable ? true : false );
2117
+ aColumns.push( columns[i].bSortable ? true : false );
2065
2118
  }
2066
2119
  }
2067
2120
  else /* all */
2068
2121
  {
2069
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
2122
+ for ( i=0, iLen=columnCount ; i<iLen ; i++ )
2070
2123
  {
2071
2124
  aColumns.push( true );
2072
2125
  }
@@ -2139,24 +2192,36 @@ TableTools.prototype = {
2139
2192
  aData.push( aRow.join(oConfig.sFieldSeperator) );
2140
2193
  }
2141
2194
 
2195
+ bSelectedOnly = true;
2196
+
2142
2197
  /*
2143
2198
  * Body
2144
2199
  */
2145
- var aSelected = this.fnGetSelected();
2200
+ var aDataIndex;
2201
+ var aSelected = this.fnGetSelectedIndexes();
2146
2202
  bSelectedOnly = this.s.select.type !== "none" && bSelectedOnly && aSelected.length !== 0;
2147
2203
 
2148
- var api = $.fn.dataTable.Api;
2149
- var aDataIndex = api ?
2150
- new api( dt ).rows( oConfig.oSelectorOpts ).indexes().flatten().toArray() :
2151
- dt.oInstance
2204
+ if ( bSelectedOnly ) {
2205
+ // Use the selected indexes
2206
+ aDataIndex = aSelected;
2207
+ }
2208
+ else if ( DataTable.Api ) {
2209
+ // 1.10+ style
2210
+ aDataIndex = new DataTable.Api( dt )
2211
+ .rows( oConfig.oSelectorOpts )
2212
+ .indexes()
2213
+ .flatten()
2214
+ .toArray();
2215
+ }
2216
+ else {
2217
+ // 1.9- style
2218
+ aDataIndex = dt.oInstance
2152
2219
  .$('tr', oConfig.oSelectorOpts)
2153
2220
  .map( function (id, row) {
2154
- // If "selected only", then ensure that the row is in the selected list
2155
- return bSelectedOnly && $.inArray( row, aSelected ) === -1 ?
2156
- null :
2157
- dt.oInstance.fnGetPosition( row );
2221
+ return dt.oInstance.fnGetPosition( row );
2158
2222
  } )
2159
2223
  .get();
2224
+ }
2160
2225
 
2161
2226
  for ( j=0, jLen=aDataIndex.length ; j<jLen ; j++ )
2162
2227
  {
@@ -3054,7 +3119,7 @@ TableTools.prototype.CLASS = "TableTools";
3054
3119
  * @type String
3055
3120
  * @default See code
3056
3121
  */
3057
- TableTools.version = "2.2.2";
3122
+ TableTools.version = "2.2.4";
3058
3123
 
3059
3124
 
3060
3125
 
@@ -1,165 +1,140 @@
1
- /* Set the defaults for DataTables initialisation */
2
- $.extend( true, $.fn.dataTable.defaults, {
3
- "sDom":
4
- "<'row'<'large-6 columns'l><'large-6 columns'f>r>"+
5
- "t"+
6
- "<'row'<'large-6 columns'i><'large-6 columns'p>>",
7
- "sPaginationType": "foundation",
8
- "oLanguage": {
9
- "sLengthMenu": "_MENU_ records per page"
10
- }
11
- } );
12
-
1
+ /*! DataTables Foundation integration
2
+ * ©2011-2014 SpryMedia Ltd - datatables.net/license
3
+ */
13
4
 
14
- /* API method to get paging information */
15
- $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
16
- {
17
- return {
18
- "iStart": oSettings._iDisplayStart,
19
- "iEnd": oSettings.fnDisplayEnd(),
20
- "iLength": oSettings._iDisplayLength,
21
- "iTotal": oSettings.fnRecordsTotal(),
22
- "iFilteredTotal": oSettings.fnRecordsDisplay(),
23
- "iPage": oSettings._iDisplayLength === -1 ?
24
- 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
25
- "iTotalPages": oSettings._iDisplayLength === -1 ?
26
- 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
27
- };
28
- };
5
+ /**
6
+ * DataTables integration for Foundation. This requires Foundation 5 and
7
+ * DataTables 1.10 or newer.
8
+ *
9
+ * This file sets the defaults and adds options to DataTables to style its
10
+ * controls using Foundation. See http://datatables.net/manual/styling/foundation
11
+ * for further information.
12
+ */
13
+ (function(window, document, undefined){
29
14
 
15
+ var factory = function( $, DataTable ) {
16
+ "use strict";
30
17
 
31
- /* Foundation style pagination control */
32
- $.extend( $.fn.dataTableExt.oPagination, {
33
- "foundation": {
34
- "fnInit": function( oSettings, nPaging, fnDraw ) {
35
- var oLang = oSettings.oLanguage.oPaginate;
36
- var fnClickHandler = function ( e ) {
37
- e.preventDefault();
38
- if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
39
- fnDraw( oSettings );
40
- }
41
- };
42
-
43
- $(nPaging).append(
44
- '<ul class="pagination">'+
45
- '<li class="prev arrow unavailable"><a href="">&laquo;</a></li>'+
46
- '<li class="next arrow unavailable"><a href="">&raquo;</a></li>'+
47
- '</ul>'
48
- );
49
- var els = $('a', nPaging);
50
- $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
51
- $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
52
- },
53
18
 
54
- "fnUpdate": function ( oSettings, fnDraw ) {
55
- var iListLength = 5;
56
- var oPaging = oSettings.oInstance.fnPagingInfo();
57
- var an = oSettings.aanFeatures.p;
58
- var pages = [];
59
- var i, ien, klass, host;
60
-
61
- // This could use some improving - however, see
62
- // https://github.com/DataTables/DataTables/issues/163 - this will
63
- // be changing in the near future, so not much point in doing too
64
- // much just now
65
- if ( oPaging.iTotalPages <= 6 ) {
66
- for ( i=0 ; i<oPaging.iTotalPages ; i++ ) {
67
- pages.push( i );
68
- }
69
- }
70
- else {
71
- // Current page
72
- pages.push( oPaging.iPage );
73
-
74
- // After current page
75
- var pagesAfter = oPaging.iPage + 2 >= oPaging.iTotalPages ?
76
- oPaging.iTotalPages :
77
- oPaging.iPage + 2;
78
- for ( i=oPaging.iPage+1 ; i<pagesAfter ; i++ ) {
79
- pages.push( i );
80
- }
19
+ $.extend( DataTable.ext.classes, {
20
+ sWrapper: "dataTables_wrapper dt-foundation"
21
+ } );
81
22
 
82
- // After gap
83
- if ( pagesAfter < oPaging.iTotalPages-2 ) {
84
- pages.push( null );
85
- }
86
23
 
87
- // End
88
- if ( $.inArray( oPaging.iTotalPages-2, pages ) === -1 && oPaging.iPage < oPaging.iTotalPages-2 ) {
89
- pages.push( oPaging.iTotalPages-2 );
90
- }
91
- if ( $.inArray( oPaging.iTotalPages-1, pages ) === -1 ) {
92
- pages.push( oPaging.iTotalPages-1 );
93
- }
24
+ /* Set the defaults for DataTables initialisation */
25
+ $.extend( true, DataTable.defaults, {
26
+ dom:
27
+ "<'row'<'small-6 columns'l><'small-6 columns'f>r>"+
28
+ "t"+
29
+ "<'row'<'small-6 columns'i><'small-6 columns'p>>",
30
+ renderer: 'foundation'
31
+ } );
94
32
 
95
- // Pages before
96
- var pagesBefore = oPaging.iPage - 2 > 0 ?
97
- oPaging.iPage - 2 :
98
- 0;
99
- for ( i=oPaging.iPage-1 ; i>pagesBefore ; i-- ) {
100
- pages.unshift( i );
101
- }
102
33
 
103
- // Before gap
104
- if ( pagesBefore > 1 ) {
105
- pages.unshift( null );
106
- }
34
+ /* Page button renderer */
35
+ DataTable.ext.renderer.pageButton.foundation = function ( settings, host, idx, buttons, page, pages ) {
36
+ var api = new DataTable.Api( settings );
37
+ var classes = settings.oClasses;
38
+ var lang = settings.oLanguage.oPaginate;
39
+ var btnDisplay, btnClass;
107
40
 
108
- // Start
109
- if ( $.inArray( 1, pages ) === -1 && oPaging.iTotalPages > 1 ) {
110
- pages.unshift( 1 );
111
- }
112
- if ( $.inArray( 0, pages ) === -1 ) {
113
- pages.unshift( 0 );
114
- }
41
+ var attach = function( container, buttons ) {
42
+ var i, ien, node, button;
43
+ var clickHandler = function ( e ) {
44
+ e.preventDefault();
45
+ if ( e.data.action !== 'ellipsis' ) {
46
+ api.page( e.data.action ).draw( false );
115
47
  }
48
+ };
116
49
 
117
- for ( i=0, ien=an.length ; i<ien ; i++ ) {
118
- // Remove the middle elements
119
- host = an[i];
120
- $('li:gt(0)', host).filter(':not(:last)').remove();
121
-
122
- // Add the new list items and their event handlers
123
- $.each( pages, function( ii, page ) {
124
- klass = page === null ? 'unavailable' :
125
- page === oPaging.iPage ? 'current' : '';
126
- $('<li class="'+klass+'"><a href="">'+(page===null? '&hellip;' : page+1)+'</a></li>')
127
- .insertBefore( $('li:last', host) )
128
- .bind('click', function (e) {
129
- e.preventDefault();
130
- oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
131
- fnDraw( oSettings );
132
- } );
133
- } );
134
-
135
- // Add / remove disabled classes from the static elements
136
- if ( oPaging.iPage === 0 ) {
137
- $('li:first', host).addClass('unavailable');
138
- } else {
139
- $('li:first', host).removeClass('unavailable');
50
+ for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
51
+ button = buttons[i];
52
+
53
+ if ( $.isArray( button ) ) {
54
+ attach( container, button );
55
+ }
56
+ else {
57
+ btnDisplay = '';
58
+ btnClass = '';
59
+
60
+ switch ( button ) {
61
+ case 'ellipsis':
62
+ btnDisplay = '&hellip;';
63
+ btnClass = 'unavailable';
64
+ break;
65
+
66
+ case 'first':
67
+ btnDisplay = lang.sFirst;
68
+ btnClass = button + (page > 0 ?
69
+ '' : ' unavailable');
70
+ break;
71
+
72
+ case 'previous':
73
+ btnDisplay = lang.sPrevious;
74
+ btnClass = button + (page > 0 ?
75
+ '' : ' unavailable');
76
+ break;
77
+
78
+ case 'next':
79
+ btnDisplay = lang.sNext;
80
+ btnClass = button + (page < pages-1 ?
81
+ '' : ' unavailable');
82
+ break;
83
+
84
+ case 'last':
85
+ btnDisplay = lang.sLast;
86
+ btnClass = button + (page < pages-1 ?
87
+ '' : ' unavailable');
88
+ break;
89
+
90
+ default:
91
+ btnDisplay = button + 1;
92
+ btnClass = page === button ?
93
+ 'current' : '';
94
+ break;
140
95
  }
141
96
 
142
- if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
143
- $('li:last', host).addClass('unavailable');
144
- } else {
145
- $('li:last', host).removeClass('unavailable');
97
+ if ( btnDisplay ) {
98
+ node = $('<li>', {
99
+ 'class': classes.sPageButton+' '+btnClass,
100
+ 'aria-controls': settings.sTableId,
101
+ 'tabindex': settings.iTabIndex,
102
+ 'id': idx === 0 && typeof button === 'string' ?
103
+ settings.sTableId +'_'+ button :
104
+ null
105
+ } )
106
+ .append( $('<a>', {
107
+ 'href': '#'
108
+ } )
109
+ .html( btnDisplay )
110
+ )
111
+ .appendTo( container );
112
+
113
+ settings.oApi._fnBindAction(
114
+ node, {action: button}, clickHandler
115
+ );
146
116
  }
147
117
  }
148
118
  }
149
- }
150
- } );
119
+ };
120
+
121
+ attach(
122
+ $(host).empty().html('<ul class="pagination"/>').children('ul'),
123
+ buttons
124
+ );
125
+ };
151
126
 
152
127
 
153
128
  /*
154
129
  * TableTools Foundation compatibility
155
130
  * Required TableTools 2.1+
156
131
  */
157
- if ( $.fn.DataTable.TableTools ) {
132
+ if ( DataTable.TableTools ) {
158
133
  // Set the classes that TableTools uses to something suitable for Foundation
159
- $.extend( true, $.fn.DataTable.TableTools.classes, {
134
+ $.extend( true, DataTable.TableTools.classes, {
160
135
  "container": "DTTT button-group",
161
136
  "buttons": {
162
- "normal": "button",
137
+ "normal": "button small",
163
138
  "disabled": "disabled"
164
139
  },
165
140
  "collection": {
@@ -174,8 +149,8 @@ if ( $.fn.DataTable.TableTools ) {
174
149
  }
175
150
  } );
176
151
 
177
- // Have the collection use a Foundation compatible dropdown
178
- $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, {
152
+ // Have the collection use a bootstrap compatible dropdown
153
+ $.extend( true, DataTable.TableTools.DEFAULTS.oTags, {
179
154
  "collection": {
180
155
  "container": "ul",
181
156
  "button": "li",
@@ -184,3 +159,22 @@ if ( $.fn.DataTable.TableTools ) {
184
159
  } );
185
160
  }
186
161
 
162
+ }; // /factory
163
+
164
+
165
+ // Define as an AMD module if possible
166
+ if ( typeof define === 'function' && define.amd ) {
167
+ define( ['jquery', 'datatables'], factory );
168
+ }
169
+ else if ( typeof exports === 'object' ) {
170
+ // Node/CommonJS
171
+ factory( require('jquery'), require('datatables') );
172
+ }
173
+ else if ( jQuery ) {
174
+ // Otherwise simply initialise as normal, stopping multiple evaluation
175
+ factory( jQuery, jQuery.fn.dataTable );
176
+ }
177
+
178
+
179
+ })(window, document);
180
+