jquery-datatables 1.10.17 → 1.10.18

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +26 -9
  4. data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +2 -2
  5. data/app/assets/javascripts/datatables/dataTables.dataTables.js +37 -0
  6. data/app/assets/javascripts/datatables/dataTables.semanticui.js +7 -3
  7. data/app/assets/javascripts/datatables/jquery.dataTables.js +3 -3
  8. data/app/assets/javascripts/datatables/plugins/api/average.js +0 -1
  9. data/app/assets/javascripts/datatables/plugins/api/sum.js +9 -10
  10. data/app/assets/javascripts/datatables/plugins/pagination/input.js +203 -203
  11. data/app/assets/javascripts/datatables/plugins/search/{alphabetSearch.js → dataTables.alphabetSearch.js} +81 -50
  12. data/app/assets/javascripts/datatables/plugins/sorting/currency.js +36 -0
  13. data/app/assets/javascripts/datatables/plugins/sorting/date-uk.js +42 -0
  14. data/app/assets/javascripts/datatables/plugins/sorting/file-size.js +2 -1
  15. data/app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js +40 -0
  16. data/app/assets/javascripts/datatables/plugins/sorting/ip-address.js +74 -73
  17. data/app/assets/javascripts/datatables/plugins/sorting/num-html.js +38 -0
  18. data/app/assets/javascripts/datatables/plugins/sorting/numeric-comma.js +37 -0
  19. data/app/assets/javascripts/datatables/plugins/type-detection/currency.js +40 -0
  20. data/app/assets/javascripts/datatables/plugins/type-detection/date-uk.js +19 -0
  21. data/app/assets/javascripts/datatables/plugins/type-detection/file-size.js +20 -0
  22. data/app/assets/javascripts/datatables/plugins/type-detection/formatted-num.js +28 -0
  23. data/app/assets/javascripts/datatables/plugins/type-detection/ip-address.js +18 -0
  24. data/app/assets/javascripts/datatables/plugins/type-detection/num-html.js +56 -0
  25. data/app/assets/javascripts/datatables/plugins/type-detection/numeric-comma.js +40 -0
  26. data/app/assets/stylesheets/datatables/dataTables.bootstrap4.scss +1 -1
  27. data/app/assets/stylesheets/datatables/dataTables.semanticui.scss +1 -1
  28. data/app/assets/stylesheets/datatables/plugins/search/dataTables.alphabetSearch.bootstrap.css +53 -0
  29. data/app/assets/stylesheets/datatables/plugins/search/dataTables.alphabetSearch.css +83 -0
  30. data/jquery-datatables.gemspec +3 -5
  31. data/lib/generators/jquery/datatables/templates/javascripts/initializer.js.tt +11 -0
  32. data/lib/generators/jquery/datatables/templates/views/index.html.erb +1 -1
  33. data/lib/generators/jquery/datatables/templates/views/index.html.haml +12 -0
  34. data/lib/jquery-datatables/version.rb +1 -1
  35. metadata +19 -18
  36. data/app/assets/stylesheets/datatables/plugins/search/alphabetSearch.css +0 -43
@@ -1,4 +1,4 @@
1
- /*! AlphabetSearch for DataTables v1.1.2
1
+ /*! AlphabetSearch for DataTables v1.2.4
2
2
  * 2014 SpryMedia Ltd - datatables.net/license
3
3
  * Gyrocode - MIT License
4
4
  */
@@ -7,7 +7,7 @@
7
7
  * @summary AlphabetSearch
8
8
  * @description Show an set of alphabet buttons alongside a table providing
9
9
  * search input options
10
- * @version 1.1.1
10
+ * @version 1.2.4
11
11
  * @file dataTables.alphabetSearch.js
12
12
  * @author SpryMedia Ltd (www.sprymedia.co.uk)
13
13
  * @contact www.sprymedia.co.uk/contact
@@ -19,7 +19,7 @@
19
19
  * License MIT - http://datatables.net/license/mit
20
20
  *
21
21
  * For more detailed information please see:
22
- * http://www.gyrocode.com/articles/jquery-datatables-alphabetical-search
22
+ * https://www.gyrocode.com/projects/jquery-datatables-alphabetsearch/
23
23
  */
24
24
  (function(){
25
25
 
@@ -34,7 +34,7 @@ $.fn.dataTable.Api.register( 'alphabetSearch()', function ( searchTerm ) {
34
34
  } );
35
35
 
36
36
  // Recalculate the alphabet display for updated data
37
- $.fn.dataTable.Api.register( 'alphabetSearch.recalc()', function ( searchTerm ) {
37
+ $.fn.dataTable.Api.register( 'alphabetSearch.recalc()', function () {
38
38
  this.iterator( 'table', function ( context ) {
39
39
  draw(
40
40
  new $.fn.dataTable.Api( context ),
@@ -49,6 +49,11 @@ $.fn.dataTable.Api.register( 'alphabetSearch.recalc()', function ( searchTerm )
49
49
 
50
50
  // Search plug-in
51
51
  $.fn.dataTable.ext.search.push( function ( context, searchData ) {
52
+ // Ensure that table has alphabet search feature enabled
53
+ if ( ! context.hasOwnProperty('alphabetSearch') ) {
54
+ return true;
55
+ }
56
+
52
57
  // Ensure that there is a search applied to this table before running it
53
58
  if ( ! context.alphabetSearch.letterSearch ) {
54
59
  return true;
@@ -80,7 +85,7 @@ $.fn.dataTable.ext.search.push( function ( context, searchData ) {
80
85
  // there would be two calls to this method
81
86
  $.fn.dataTable.ext.order['alphabetSearch'] = function ( context, col )
82
87
  {
83
- var order_col = this.api().order()[0][0];
88
+ var order_col = this.api().order()[0][0];
84
89
  var order_method = this.api().order()[0][1];
85
90
 
86
91
  // If sorting by column other than the one being alphabetized
@@ -89,28 +94,29 @@ $.fn.dataTable.ext.order['alphabetSearch'] = function ( context, col )
89
94
  }
90
95
 
91
96
  var data = this.api().column( col, { order: 'index' } ).data().map( function (value, index) {
97
+ var letter = value.replace(/<.*?>/g, '').charAt(0).toUpperCase();
98
+
92
99
  // If sorting by alphabetized column
93
100
  return (order_col === context.alphabetSearch.column)
94
- ? (
95
- // If first pass
96
- ( !context.alphabetSearch.pass )
97
- // Ignore
98
- ?
99
- ''
100
- // Otherwise, if it's a second pass
101
- :
102
- (
103
- // If method is ascending sort
104
- ( order_method === 'asc' )
105
- // Return first letter
106
- ? value.charAt(0)
107
- : String.fromCharCode(65535 - value.charCodeAt(0))
108
- )
109
- )
110
- // Otherwise, if sorting by column other than the one being alphabetized,
111
- // return first letter
112
- : value.charAt(0);
113
-
101
+ ? (
102
+ // If first pass
103
+ ( !context.alphabetSearch.pass )
104
+ // Ignore
105
+ ?
106
+ ''
107
+ // Otherwise, if it's a second pass
108
+ :
109
+ (
110
+ // If method is ascending sort
111
+ ( order_method === 'asc' )
112
+ // Return first letter
113
+ ? letter
114
+ : String.fromCharCode(65535 - letter.charCodeAt(0))
115
+ )
116
+ )
117
+ // Otherwise, if sorting by column other than the one being alphabetized,
118
+ // return first letter
119
+ : letter;
114
120
  } );
115
121
 
116
122
  // If sorting by alphabetized column
@@ -151,34 +157,50 @@ function bin ( data ) {
151
157
  function draw ( table, alphabet, context )
152
158
  {
153
159
  alphabet.empty();
154
- alphabet.append( context.oLanguage.alphabetSearch.infoDisplay + ': ' );
160
+
161
+ if(context.oLanguage.alphabetSearch.infoDisplay !== ''){
162
+ $('<span class="alphabet-info-display"></span>')
163
+ .html(context.oLanguage.alphabetSearch.infoDisplay)
164
+ .appendTo( alphabet );
165
+ }
155
166
 
156
167
  var columnData = table.column(context.alphabetSearch.column, { search: 'applied' } ).data();
157
168
  var bins = bin( columnData );
158
169
 
159
- $('<span class="alphabet-clear' + ((!context.alphabetSearch.letter) ? ' active' : '') + '"/>')
170
+ var alphabetList = $('<ul/>');
171
+
172
+ $('<a/>')
173
+ .attr( 'href', 'javascript:;' )
160
174
  .data( 'letter', '' )
161
175
  .data( 'match-count', columnData.length )
162
- .html( context.oLanguage.alphabetSearch.infoAll )
163
- .appendTo( alphabet );
176
+ .addClass(
177
+ ((!context.alphabetSearch.letter) ? 'active' : '')
178
+ )
179
+ .html( '<span>' + context.oLanguage.alphabetSearch.infoAll + '</span>' )
180
+ .wrap( '<li/>' )
181
+ .parent()
182
+ .appendTo( alphabetList );
164
183
 
165
184
  for ( var i=0 ; i<context.oLanguage.alphabetSearch.alphabet.length ; i++ ) {
166
185
  var letter = context.oLanguage.alphabetSearch.alphabet[i];
167
186
 
168
- $('<span/>')
187
+ $('<a/>')
188
+ .attr( 'href', 'javascript:;' )
169
189
  .data( 'letter', letter )
170
190
  .data( 'match-count', bins[letter] || 0 )
171
191
  .addClass(
172
192
  (! bins[letter] ? 'empty' : '')
173
193
  + ((context.alphabetSearch.letter === letter) ? ' active' : '')
174
194
  )
175
- .html(
176
- (letter === '#') ? '0-9' : letter
177
- )
178
- .appendTo( alphabet );
195
+ .html( '<span>' + letter + '</span>' )
196
+ .wrap( '<li/>' )
197
+ .parent()
198
+ .appendTo( alphabetList );
179
199
  }
180
200
 
181
- $('<div class="alphabet_info"></div>')
201
+ alphabetList.appendTo( alphabet );
202
+
203
+ $('<div class="alphabet-info"></div>')
182
204
  .appendTo( alphabet );
183
205
 
184
206
 
@@ -221,7 +243,7 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
221
243
  $.extend(
222
244
  {
223
245
  'alphabet': '#ABCDEFGHIJKLMNOPQRSTUVWXYZ',
224
- 'infoDisplay': 'Display',
246
+ 'infoDisplay': 'Display:',
225
247
  'infoAll': 'All'
226
248
  },
227
249
  ((context.oLanguage.alphabetSearch)
@@ -288,7 +310,10 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
288
310
 
289
311
 
290
312
  // Trigger a search
291
- alphabet.on( 'click', 'span', function () {
313
+ alphabet.on( 'click', 'a', function (e) {
314
+ // Prevent default behavior
315
+ e.preventDefault();
316
+
292
317
  alphabet.find( '.active' ).removeClass( 'active' );
293
318
  $(this).addClass( 'active' );
294
319
 
@@ -299,19 +324,25 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
299
324
 
300
325
  // Mouse events to show helper information
301
326
  alphabet
302
- .on( 'mouseenter', 'span', function () {
303
- alphabet
304
- .find('div.alphabet_info')
327
+ .on( 'mouseenter', 'a', function () {
328
+ var $el = $(this);
329
+ var el_pos = $el.position();
330
+
331
+ var $alphabet_info = $('.alphabet-info', alphabet);
332
+
333
+ $alphabet_info.html( $el.data('match-count') );
334
+
335
+ // Display helper centered horizontally under the letter
336
+ $alphabet_info
305
337
  .css( {
306
338
  opacity: 1,
307
- left: $(this).position().left,
308
- width: $(this).width()
309
- } )
310
- .html( $(this).data('match-count') );
339
+ left: el_pos.left + Math.round(($el.outerWidth() - $alphabet_info.outerWidth())/2),
340
+ top: $(this).position().top + $el.outerHeight()
341
+ } );
311
342
  } )
312
- .on( 'mouseleave', 'span', function () {
343
+ .on( 'mouseleave', 'a', function () {
313
344
  alphabet
314
- .find('div.alphabet_info')
345
+ .find('div.alphabet-info')
315
346
  .css('opacity', 0);
316
347
  } );
317
348
 
@@ -325,11 +356,11 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
325
356
  var group_last = null;
326
357
 
327
358
  api.column(context.alphabetSearch.column, { page: 'current' }).data().each(function (name, index){
328
- var group = name.charAt(0).toUpperCase();
359
+ var group = name.replace(/<.*?>/g, '').charAt(0).toUpperCase();
329
360
 
330
361
  if (group_last !== group) {
331
362
  $(rows).eq(index).before(
332
- '<tr class="alphabet_group"><td colspan="' + col_total + '">' + group + '</td></tr>'
363
+ '<tr class="alphabet-group"><td colspan="' + col_total + '">' + group + '</td></tr>'
333
364
  );
334
365
 
335
366
  group_last = group;
@@ -338,10 +369,10 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
338
369
 
339
370
  // If there are no rows found and letter is selected
340
371
  if(!rows.length && context.alphabetSearch){
341
- var letter = (context.alphabetSearch.letter === '#') ? '0-9' : context.alphabetSearch.letter;
372
+ var letter = context.alphabetSearch.letter;
342
373
 
343
374
  $(api.table().body()).prepend(
344
- '<tr class="alphabet_group"><td colspan="' + col_total + '">' + letter + '</td></tr>'
375
+ '<tr class="alphabet-group"><td colspan="' + col_total + '">' + letter + '</td></tr>'
345
376
  );
346
377
  }
347
378
  });
@@ -0,0 +1,36 @@
1
+ /**
2
+ * This plug-in will provide numeric sorting for currency columns (either
3
+ * detected automatically with the currency type detection plug-in or set
4
+ * manually) while taking account of the currency symbol ($ or £ by default).
5
+ *
6
+ * DataTables 1.10+ has currency sorting abilities built-in and will be
7
+ * automatically detected. As such this plug-in is marked as deprecated, but
8
+ * might be useful when working with old versions of DataTables.
9
+ *
10
+ * @name Currency
11
+ * @summary Sort data numerically when it has a leading currency symbol.
12
+ * @deprecated
13
+ * @author [Allan Jardine](http://sprymedia.co.uk)
14
+ *
15
+ * @example
16
+ * $('#example').dataTable( {
17
+ * columnDefs: [
18
+ * { type: 'currency', targets: 0 }
19
+ * ]
20
+ * } );
21
+ */
22
+
23
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
24
+ "currency-pre": function ( a ) {
25
+ a = (a==="-") ? 0 : a.replace( /[^\d\-\.]/g, "" );
26
+ return parseFloat( a );
27
+ },
28
+
29
+ "currency-asc": function ( a, b ) {
30
+ return a - b;
31
+ },
32
+
33
+ "currency-desc": function ( a, b ) {
34
+ return b - a;
35
+ }
36
+ } );
@@ -0,0 +1,42 @@
1
+ /**
2
+ * DataTables internal date sorting replies on `Date.parse()` which is part of
3
+ * the Javascript language, but you may wish to sort on dates which is doesn't
4
+ * recognise. The following is a plug-in for sorting dates in the format
5
+ * `dd/mm/yy`.
6
+ *
7
+ * An automatic type detection plug-in is available for this sorting plug-in.
8
+ *
9
+ * Please note that this plug-in is **deprecated*. The
10
+ * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
11
+ * functionality and flexibility.
12
+ *
13
+ * @name Date (dd/mm/YY)
14
+ * @summary Sort dates in the format `dd/mm/YY`
15
+ * @author Andy McMaster
16
+ * @deprecated
17
+ *
18
+ * @example
19
+ * $('#example').dataTable( {
20
+ * columnDefs: [
21
+ * { type: 'date-uk', targets: 0 }
22
+ * ]
23
+ * } );
24
+ */
25
+
26
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
27
+ "date-uk-pre": function ( a ) {
28
+ if (a == null || a == "") {
29
+ return 0;
30
+ }
31
+ var ukDatea = a.split('/');
32
+ return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
33
+ },
34
+
35
+ "date-uk-asc": function ( a, b ) {
36
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
37
+ },
38
+
39
+ "date-uk-desc": function ( a, b ) {
40
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
41
+ }
42
+ } );
@@ -22,6 +22,7 @@ jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
22
22
  var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );
23
23
  var multipliers = {
24
24
  b: 1,
25
+ bytes: 1,
25
26
  kb: 1000,
26
27
  kib: 1024,
27
28
  mb: 1000000,
@@ -40,4 +41,4 @@ jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
40
41
  } else {
41
42
  return -1;
42
43
  };
43
- };
44
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * This plug-in will provide numeric sorting for numeric columns which have
3
+ * extra formatting, such as thousands separators, currency symbols or any other
4
+ * non-numeric data.
5
+ *
6
+ * By default when a cell is found to have no numeric data its value is sorted
7
+ * numerically as if its value were 0. This could also be altered to be Inifnity
8
+ * or -Infinity as required.
9
+ *
10
+ * DataTables 1.10+ has formatted number detection and sorting abilities built-
11
+ * in. As such this plug-in is marked as deprecated, but might be useful when
12
+ * working with old versions of DataTables.
13
+ *
14
+ * @name Formatted numbers
15
+ * @summary Sort numbers which are displayed with thousand separators
16
+ * @deprecated
17
+ * @author [Allan Jardine](http://sprymedia.co.uk)
18
+ *
19
+ * @example
20
+ * $('#example').dataTable( {
21
+ * columnDefs: [
22
+ * { type: 'formatted-num', targets: 0 }
23
+ * ]
24
+ * } );
25
+ */
26
+
27
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
28
+ "formatted-num-pre": function ( a ) {
29
+ a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
30
+ return parseFloat( a );
31
+ },
32
+
33
+ "formatted-num-asc": function ( a, b ) {
34
+ return a - b;
35
+ },
36
+
37
+ "formatted-num-desc": function ( a, b ) {
38
+ return b - a;
39
+ }
40
+ } );
@@ -17,87 +17,88 @@
17
17
  */
18
18
 
19
19
  jQuery.extend( jQuery.fn.dataTableExt.oSort, {
20
- "ip-address-pre": function ( a ) {
21
- var i, item;
22
- var m = a.split("."),
23
- n = a.split(":"),
24
- x = "",
25
- xa = "";
20
+ "ip-address-pre": function ( a ) {
21
+ if (!a) { return 0 }
22
+ var i, item;
23
+ var m = a.split("."),
24
+ n = a.split(":"),
25
+ x = "",
26
+ xa = "";
26
27
 
27
- if (m.length == 4) {
28
- // IPV4
29
- for(i = 0; i < m.length; i++) {
30
- item = m[i];
28
+ if (m.length == 4) {
29
+ // IPV4
30
+ for(i = 0; i < m.length; i++) {
31
+ item = m[i];
31
32
 
32
- if(item.length == 1) {
33
- x += "00" + item;
34
- }
35
- else if(item.length == 2) {
36
- x += "0" + item;
37
- }
38
- else {
39
- x += item;
40
- }
41
- }
42
- }
43
- else if (n.length > 0) {
44
- // IPV6
45
- var count = 0;
46
- for(i = 0; i < n.length; i++) {
47
- item = n[i];
33
+ if(item.length == 1) {
34
+ x += "00" + item;
35
+ }
36
+ else if(item.length == 2) {
37
+ x += "0" + item;
38
+ }
39
+ else {
40
+ x += item;
41
+ }
42
+ }
43
+ }
44
+ else if (n.length > 0) {
45
+ // IPV6
46
+ var count = 0;
47
+ for(i = 0; i < n.length; i++) {
48
+ item = n[i];
48
49
 
49
- if (i > 0) {
50
- xa += ":";
51
- }
50
+ if (i > 0) {
51
+ xa += ":";
52
+ }
52
53
 
53
- if(item.length === 0) {
54
- count += 0;
55
- }
56
- else if(item.length == 1) {
57
- xa += "000" + item;
58
- count += 4;
59
- }
60
- else if(item.length == 2) {
61
- xa += "00" + item;
62
- count += 4;
63
- }
64
- else if(item.length == 3) {
65
- xa += "0" + item;
66
- count += 4;
67
- }
68
- else {
69
- xa += item;
70
- count += 4;
71
- }
72
- }
54
+ if(item.length === 0) {
55
+ count += 0;
56
+ }
57
+ else if(item.length == 1) {
58
+ xa += "000" + item;
59
+ count += 4;
60
+ }
61
+ else if(item.length == 2) {
62
+ xa += "00" + item;
63
+ count += 4;
64
+ }
65
+ else if(item.length == 3) {
66
+ xa += "0" + item;
67
+ count += 4;
68
+ }
69
+ else {
70
+ xa += item;
71
+ count += 4;
72
+ }
73
+ }
73
74
 
74
- // Padding the ::
75
- n = xa.split(":");
76
- var paddDone = 0;
75
+ // Padding the ::
76
+ n = xa.split(":");
77
+ var paddDone = 0;
77
78
 
78
- for (i = 0; i < n.length; i++) {
79
- item = n[i];
79
+ for (i = 0; i < n.length; i++) {
80
+ item = n[i];
80
81
 
81
- if (item.length === 0 && paddDone === 0) {
82
- for (var padding = 0 ; padding < (32-count) ; padding++) {
83
- x += "0";
84
- paddDone = 1;
85
- }
86
- }
87
- else {
88
- x += item;
89
- }
90
- }
91
- }
82
+ if (item.length === 0 && paddDone === 0) {
83
+ for (var padding = 0 ; padding < (32-count) ; padding++) {
84
+ x += "0";
85
+ paddDone = 1;
86
+ }
87
+ }
88
+ else {
89
+ x += item;
90
+ }
91
+ }
92
+ }
92
93
 
93
- return x;
94
- },
94
+ return x;
95
+ },
95
96
 
96
- "ip-address-asc": function ( a, b ) {
97
- return ((a < b) ? -1 : ((a > b) ? 1 : 0));
98
- },
97
+ "ip-address-asc": function ( a, b ) {
98
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
99
+ },
99
100
 
100
- "ip-address-desc": function ( a, b ) {
101
- return ((a < b) ? 1 : ((a > b) ? -1 : 0));
102
- }
101
+ "ip-address-desc": function ( a, b ) {
102
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
103
+ }
103
104
  });