jquery-datatables 1.10.19.1 → 1.10.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/README.md +28 -1
  4. data/app/assets/javascripts/datatables/dataTables.uikit.js +2 -2
  5. data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +42 -29
  6. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap.js +1 -1
  7. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap4.js +8 -2
  8. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +6 -3
  9. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.foundation.js +5 -4
  10. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +58 -6
  11. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +16 -5
  12. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.semanticui.js +1 -1
  13. data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +267 -152
  14. data/app/assets/javascripts/datatables/extensions/ColReorder/colReorder.foundation.js +1 -1
  15. data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +121 -52
  16. data/app/assets/javascripts/datatables/extensions/FixedColumns/dataTables.fixedColumns.js +32 -5
  17. data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +166 -63
  18. data/app/assets/javascripts/datatables/extensions/KeyTable/keyTable.foundation.js +1 -1
  19. data/app/assets/javascripts/datatables/extensions/RowGroup/dataTables.rowGroup.js +105 -53
  20. data/app/assets/javascripts/datatables/extensions/RowGroup/rowGroup.foundation.js +1 -1
  21. data/app/assets/javascripts/datatables/extensions/RowGroup/{rowGroup.semanicui.js → rowGroup.semanticui.js} +0 -0
  22. data/app/assets/javascripts/datatables/extensions/RowReorder/dataTables.rowReorder.js +10 -9
  23. data/app/assets/javascripts/datatables/extensions/RowReorder/rowReorder.foundation.js +1 -1
  24. data/app/assets/javascripts/datatables/extensions/Scroller/dataTables.scroller.js +519 -636
  25. data/app/assets/javascripts/datatables/extensions/Scroller/scroller.foundation.js +1 -1
  26. data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +49 -18
  27. data/app/assets/javascripts/datatables/extensions/Select/select.foundation.js +1 -1
  28. data/app/assets/javascripts/datatables/jquery.dataTables.js +97 -60
  29. data/app/assets/javascripts/datatables/plugins/api/average.js +7 -6
  30. data/app/assets/javascripts/datatables/plugins/api/sum.js +7 -6
  31. data/app/assets/javascripts/datatables/plugins/pagination/ellipses.js +160 -0
  32. data/app/assets/javascripts/datatables/plugins/pagination/extjs.js +137 -0
  33. data/app/assets/javascripts/datatables/plugins/pagination/four_button.js +110 -0
  34. data/app/assets/javascripts/datatables/plugins/pagination/full_numbers_no_ellipses.js +59 -0
  35. data/app/assets/javascripts/datatables/plugins/pagination/input.js +22 -19
  36. data/app/assets/javascripts/datatables/plugins/pagination/scrolling.js +130 -0
  37. data/app/assets/javascripts/datatables/plugins/pagination/select.js +97 -0
  38. data/app/assets/javascripts/datatables/plugins/pagination/simple_incremental_bootstrap.js +154 -0
  39. data/app/assets/javascripts/datatables/plugins/pagination/simple_numbers_no_ellipses.js +59 -0
  40. data/app/assets/javascripts/datatables/plugins/search/dataTables.alphabetSearch.js +440 -399
  41. data/app/assets/javascripts/datatables/plugins/sorting/enum.js +51 -0
  42. data/app/assets/javascripts/datatables/plugins/type-detection/date-dd-MMM-yyyy.js +63 -0
  43. data/app/assets/javascripts/datatables/plugins/type-detection/date-de.js +125 -0
  44. data/app/assets/javascripts/datatables/plugins/type-detection/date-eu.js +64 -0
  45. data/app/assets/javascripts/datatables/plugins/type-detection/date-euro.js +48 -0
  46. data/app/assets/javascripts/datatables/plugins/type-detection/date-uk.js +35 -12
  47. data/app/assets/javascripts/datatables/plugins/type-detection/datetime-moment.js +74 -0
  48. data/app/assets/javascripts/datatables/plugins/type-detection/datetime-us.js +86 -0
  49. data/app/assets/javascripts/datatables/plugins/type-detection/file-size.js +37 -13
  50. data/app/assets/javascripts/datatables/plugins/type-detection/ip-address.js +113 -11
  51. data/app/assets/javascripts/datatables/plugins/type-detection/numString.js +63 -0
  52. data/app/assets/javascripts/datatables/plugins/type-detection/percent.js +34 -0
  53. data/app/assets/javascripts/datatables/plugins/type-detection/time-elapsed-dhms.js +42 -0
  54. data/app/assets/javascripts/datatables/plugins/type-detection/time.js +56 -0
  55. data/app/assets/javascripts/datatables/plugins/type-detection/title-numeric.js +40 -0
  56. data/app/assets/javascripts/datatables/plugins/type-detection/title-string.js +36 -0
  57. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.dataTables.scss +10 -3
  58. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.scss +12 -3
  59. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.scss +13 -6
  60. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.scss +2 -0
  61. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.scss +5 -1
  62. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.scss +1 -0
  63. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.scss +2 -1
  64. data/app/assets/stylesheets/datatables/extensions/Buttons/common.scss +10 -0
  65. data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +42 -30
  66. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap.scss +11 -7
  67. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.foundation.scss +1 -0
  68. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.dataTables.scss +13 -5
  69. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.dataTables.scss +20 -2
  70. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.dataTables.scss +15 -2
  71. data/lib/jquery-datatables/version.rb +1 -1
  72. metadata +26 -12
  73. data/app/assets/javascripts/datatables/dataTables.bootstrap2.js +0 -162
  74. data/app/assets/javascripts/datatables/extensions/ColReorder/colReorder.semanicui.js +0 -38
  75. data/app/assets/javascripts/datatables/extensions/FixedColumns/fixedColumns.semanicui.js +0 -38
  76. data/app/assets/javascripts/datatables/extensions/FixedHeader/fixedHeader.semanicui.js +0 -38
  77. data/app/assets/javascripts/datatables/extensions/KeyTable/keyTable.semanicui.js +0 -38
  78. data/app/assets/javascripts/datatables/extensions/RowReorder/rowReorder.semanicui.js +0 -38
  79. data/app/assets/stylesheets/datatables/dataTables.bootstrap2.scss +0 -178
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Sort data by a defined enumerated (enum) list. The options for the values in
3
+ * the enum are defined by passing the values in an array to the method
4
+ * `$.fn.dataTable.enum`. Type detection and sorting plug-ins for DataTables will
5
+ * automatically be generated and added to the table.
6
+ *
7
+ * For full details and instructions please see [this DataTables blog
8
+ * post](//datatables.net/blog/2016-06-16).
9
+ *
10
+ * @name enum
11
+ * @summary Dynamically create enum sorting options for a DataTable
12
+ * @author [SpryMedia Ltd](http://datatables.net)
13
+ *
14
+ * @example
15
+ * $.fn.dataTable.enum( [ 'High', 'Medium', 'Low' ] );
16
+ *
17
+ * $('#example').DataTable();
18
+ */
19
+
20
+
21
+ (function ($) {
22
+
23
+
24
+ var unique = 0;
25
+ var types = $.fn.dataTable.ext.type;
26
+
27
+ // Using form $.fn.dataTable.enum breaks at least YuiCompressor since enum is
28
+ // a reserved word in JavaScript
29
+ $.fn.dataTable['enum'] = function ( arr ) {
30
+ var name = 'enum-'+(unique++);
31
+ var lookup = window.Map ? new Map() : {};
32
+
33
+ for ( var i=0, ien=arr.length ; i<ien ; i++ ) {
34
+ lookup[ arr[i] ] = i;
35
+ }
36
+
37
+ // Add type detection
38
+ types.detect.unshift( function ( d ) {
39
+ return lookup[ d ] !== undefined ?
40
+ name :
41
+ null;
42
+ } );
43
+
44
+ // Add sorting method
45
+ types.order[ name+'-pre' ] = function ( d ) {
46
+ return lookup[ d ];
47
+ };
48
+ };
49
+
50
+
51
+ })(jQuery);
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Adds a new sorting option to dataTables called `date-dd-mmm-yyyy`. Also
3
+ * includes a type detection plug-in. Matches and sorts date strings in
4
+ * the format: `dd/mmm/yyyy`. For example:
5
+ *
6
+ * * 02-FEB-1978
7
+ * * 17-MAY-2013
8
+ * * 31-JAN-2014
9
+ *
10
+ * Please note that this plug-in is **deprecated*. The
11
+ * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
12
+ * functionality and flexibility.
13
+ *
14
+ * @name Date (dd-mmm-yyyy)
15
+ * @summary Sort dates in the format `dd-mmm-yyyy`
16
+ * @author [Jeromy French](http://www.appliedinter.net/jeromy_works/)
17
+ * @deprecated
18
+ *
19
+ * @example
20
+ * $('#example').dataTable( {
21
+ * columnDefs: [
22
+ * { type: 'date-dd-mmm-yyyy', targets: 0 }
23
+ * ]
24
+ * } );
25
+ */
26
+
27
+ (function () {
28
+
29
+ var customDateDDMMMYYYYToOrd = function (date) {
30
+ "use strict"; //let's avoid tom-foolery in this function
31
+ // Convert to a number YYYYMMDD which we can use to order
32
+ var dateParts = date.split(/-/);
33
+ return (dateParts[2] * 10000) + ($.inArray(dateParts[1].toUpperCase(), ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]) * 100) + (dateParts[0]*1);
34
+ };
35
+
36
+ // This will help DataTables magic detect the "dd-MMM-yyyy" format; Unshift
37
+ // so that it's the first data type (so it takes priority over existing)
38
+ jQuery.fn.dataTableExt.aTypes.unshift(
39
+ function (sData) {
40
+ "use strict"; //let's avoid tom-foolery in this function
41
+ if (/^([0-2]?\d|3[0-1])-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)-\d{4}/i.test(sData)) {
42
+ return 'date-dd-mmm-yyyy';
43
+ }
44
+ return null;
45
+ }
46
+ );
47
+
48
+ // define the sorts
49
+ jQuery.fn.dataTableExt.oSort['date-dd-mmm-yyyy-asc'] = function (a, b) {
50
+ "use strict"; //let's avoid tom-foolery in this function
51
+ var ordA = customDateDDMMMYYYYToOrd(a),
52
+ ordB = customDateDDMMMYYYYToOrd(b);
53
+ return (ordA < ordB) ? -1 : ((ordA > ordB) ? 1 : 0);
54
+ };
55
+
56
+ jQuery.fn.dataTableExt.oSort['date-dd-mmm-yyyy-desc'] = function (a, b) {
57
+ "use strict"; //let's avoid tom-foolery in this function
58
+ var ordA = customDateDDMMMYYYYToOrd(a),
59
+ ordB = customDateDDMMMYYYYToOrd(b);
60
+ return (ordA < ordB) ? 1 : ((ordA > ordB) ? -1 : 0);
61
+ };
62
+
63
+ })();
@@ -0,0 +1,125 @@
1
+ /**
2
+ * This sorting plug-in for DataTables will correctly sort data in date time or date
3
+ * format typically used in Germany:
4
+ * date and time:`dd.mm.YYYY HH:mm`
5
+ * just date:`dd.mm.YYYY`.
6
+ *
7
+ * Please note that this plug-in is **deprecated*. The
8
+ * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
9
+ * functionality and flexibility.
10
+ *
11
+ * @name Date (dd.mm.YYYY) or date and time (dd.mm.YYYY HH:mm)
12
+ * @summary Sort date / time in the format `dd.mm.YYYY HH:mm` or `dd.mm.YYYY`.
13
+ * @author [Ronny Vedrilla](http://www.ambient-innovation.com)
14
+ * @deprecated
15
+ *
16
+ * @example
17
+ * $('#example').dataTable( {
18
+ * columnDefs: [
19
+ * { type: 'de_datetime', targets: 0 },
20
+ * { type: 'de_date', targets: 1 }
21
+ * ]
22
+ * } );
23
+ */
24
+
25
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
26
+ "de_datetime-asc": function ( a, b ) {
27
+ var x, y;
28
+ if (jQuery.trim(a) !== '') {
29
+ var deDatea = jQuery.trim(a).split(' ');
30
+ var deTimea = deDatea[1].split(':');
31
+ var deDatea2 = deDatea[0].split('.');
32
+ if(typeof deTimea[2] != 'undefined') {
33
+ x = (deDatea2[2] + deDatea2[1] + deDatea2[0] + deTimea[0] + deTimea[1] + deTimea[2]) * 1;
34
+ } else {
35
+ x = (deDatea2[2] + deDatea2[1] + deDatea2[0] + deTimea[0] + deTimea[1]) * 1;
36
+ }
37
+ } else {
38
+ x = -Infinity; // = l'an 1000 ...
39
+ }
40
+
41
+ if (jQuery.trim(b) !== '') {
42
+ var deDateb = jQuery.trim(b).split(' ');
43
+ var deTimeb = deDateb[1].split(':');
44
+ deDateb = deDateb[0].split('.');
45
+ if(typeof deTimeb[2] != 'undefined') {
46
+ y = (deDateb[2] + deDateb[1] + deDateb[0] + deTimeb[0] + deTimeb[1] + deTimeb[2]) * 1;
47
+ } else {
48
+ y = (deDateb[2] + deDateb[1] + deDateb[0] + deTimeb[0] + deTimeb[1]) * 1;
49
+ }
50
+ } else {
51
+ y = -Infinity;
52
+ }
53
+ var z = ((x < y) ? -1 : ((x > y) ? 1 : 0));
54
+ return z;
55
+ },
56
+
57
+ "de_datetime-desc": function ( a, b ) {
58
+ var x, y;
59
+ if (jQuery.trim(a) !== '') {
60
+ var deDatea = jQuery.trim(a).split(' ');
61
+ var deTimea = deDatea[1].split(':');
62
+ var deDatea2 = deDatea[0].split('.');
63
+ if(typeof deTimea[2] != 'undefined') {
64
+ x = (deDatea2[2] + deDatea2[1] + deDatea2[0] + deTimea[0] + deTimea[1] + deTimea[2]) * 1;
65
+ } else {
66
+ x = (deDatea2[2] + deDatea2[1] + deDatea2[0] + deTimea[0] + deTimea[1]) * 1;
67
+ }
68
+ } else {
69
+ x = Infinity;
70
+ }
71
+
72
+ if (jQuery.trim(b) !== '') {
73
+ var deDateb = jQuery.trim(b).split(' ');
74
+ var deTimeb = deDateb[1].split(':');
75
+ deDateb = deDateb[0].split('.');
76
+ if(typeof deTimeb[2] != 'undefined') {
77
+ y = (deDateb[2] + deDateb[1] + deDateb[0] + deTimeb[0] + deTimeb[1] + deTimeb[2]) * 1;
78
+ } else {
79
+ y = (deDateb[2] + deDateb[1] + deDateb[0] + deTimeb[0] + deTimeb[1]) * 1;
80
+ }
81
+ } else {
82
+ y = -Infinity;
83
+ }
84
+ var z = ((x < y) ? 1 : ((x > y) ? -1 : 0));
85
+ return z;
86
+ },
87
+
88
+ "de_date-asc": function ( a, b ) {
89
+ var x, y;
90
+ if (jQuery.trim(a) !== '') {
91
+ var deDatea = jQuery.trim(a).split('.');
92
+ x = (deDatea[2] + deDatea[1] + deDatea[0]) * 1;
93
+ } else {
94
+ x = Infinity; // = l'an 1000 ...
95
+ }
96
+
97
+ if (jQuery.trim(b) !== '') {
98
+ var deDateb = jQuery.trim(b).split('.');
99
+ y = (deDateb[2] + deDateb[1] + deDateb[0]) * 1;
100
+ } else {
101
+ y = -Infinity;
102
+ }
103
+ var z = ((x < y) ? -1 : ((x > y) ? 1 : 0));
104
+ return z;
105
+ },
106
+
107
+ "de_date-desc": function ( a, b ) {
108
+ var x, y;
109
+ if (jQuery.trim(a) !== '') {
110
+ var deDatea = jQuery.trim(a).split('.');
111
+ x = (deDatea[2] + deDatea[1] + deDatea[0]) * 1;
112
+ } else {
113
+ x = -Infinity;
114
+ }
115
+
116
+ if (jQuery.trim(b) !== '') {
117
+ var deDateb = jQuery.trim(b).split('.');
118
+ y = (deDateb[2] + deDateb[1] + deDateb[0]) * 1;
119
+ } else {
120
+ y = Infinity;
121
+ }
122
+ var z = ((x < y) ? 1 : ((x > y) ? -1 : 0));
123
+ return z;
124
+ }
125
+ } );
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Similar to the Date (dd/mm/YY) data sorting plug-in, this plug-in offers
3
+ * additional flexibility with support for spaces between the values and
4
+ * either . or / notation for the separators.
5
+ *
6
+ * Please note that this plug-in is **deprecated*. The
7
+ * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
8
+ * functionality and flexibility.
9
+ *
10
+ * @name Date (dd . mm[ . YYYY])
11
+ * @summary Sort dates in the format `dd/mm/YY[YY]` (with optional spaces)
12
+ * @author [Robert Sedovšek](http://galjot.si/)
13
+ * @deprecated
14
+ *
15
+ * @example
16
+ * $('#example').dataTable( {
17
+ * columnDefs: [
18
+ * { type: 'date-eu', targets: 0 }
19
+ * ]
20
+ * } );
21
+ */
22
+
23
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
24
+ "date-eu-pre": function ( date ) {
25
+ date = date.replace(" ", "");
26
+
27
+ if ( ! date ) {
28
+ return 0;
29
+ }
30
+
31
+ var year;
32
+ var eu_date = date.split(/[\.\-\/]/);
33
+
34
+ /*year (optional)*/
35
+ if ( eu_date[2] ) {
36
+ year = eu_date[2];
37
+ }
38
+ else {
39
+ year = 0;
40
+ }
41
+
42
+ /*month*/
43
+ var month = eu_date[1];
44
+ if ( month.length == 1 ) {
45
+ month = 0+month;
46
+ }
47
+
48
+ /*day*/
49
+ var day = eu_date[0];
50
+ if ( day.length == 1 ) {
51
+ day = 0+day;
52
+ }
53
+
54
+ return (year + month + day) * 1;
55
+ },
56
+
57
+ "date-eu-asc": function ( a, b ) {
58
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
59
+ },
60
+
61
+ "date-eu-desc": function ( a, b ) {
62
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
63
+ }
64
+ } );
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This plug-in will provide date sorting for the "dd/mm/YYYY hh:ii:ss"
3
+ * formatting, which is common in France and other European countries. It can
4
+ * also be quickly adapted for other formatting as required. Furthermore, this
5
+ * date sorting plug-in allows for empty values in the column.
6
+ *
7
+ * Please note that this plug-in is **deprecated*. The
8
+ * [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
9
+ * functionality and flexibility.
10
+ *
11
+ * @name Date (dd/mm/YYYY hh:ii:ss)
12
+ * @summary Sort date / time in the format `dd/mm/YYYY hh:ii:ss`
13
+ * @author [Ronan Guilloux](http://coolforest.net/)
14
+ * @deprecated
15
+ *
16
+ * @example
17
+ * $('#example').dataTable( {
18
+ * columnDefs: [
19
+ * { type: 'date-euro', targets: 0 }
20
+ * ]
21
+ * } );
22
+ */
23
+
24
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
25
+ "date-euro-pre": function ( a ) {
26
+ var x;
27
+
28
+ if ( $.trim(a) !== '' ) {
29
+ var frDatea = $.trim(a).split(' ');
30
+ var frTimea = (undefined != frDatea[1]) ? frDatea[1].split(':') : [00,00,00];
31
+ var frDatea2 = frDatea[0].split('/');
32
+ x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + ((undefined != frTimea[2]) ? frTimea[2] : 0)) * 1;
33
+ }
34
+ else {
35
+ x = Infinity;
36
+ }
37
+
38
+ return x;
39
+ },
40
+
41
+ "date-euro-asc": function ( a, b ) {
42
+ return a - b;
43
+ },
44
+
45
+ "date-euro-desc": function ( a, b ) {
46
+ return b - a;
47
+ }
48
+ } );
@@ -1,19 +1,42 @@
1
1
  /**
2
- * Automatically detect British (`dd/mm/yyyy`) date types. Goes with the UK
3
- * date sorting plug-in.
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.
4
8
  *
5
- * @name Date (`dd/mm/yyyy`)
6
- * @summary Detect data which is in the date format `dd/mm/yyyy`
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`
7
15
  * @author Andy McMaster
16
+ * @deprecated
17
+ *
18
+ * @example
19
+ * $('#example').dataTable( {
20
+ * columnDefs: [
21
+ * { type: 'date-uk', targets: 0 }
22
+ * ]
23
+ * } );
8
24
  */
9
25
 
10
- jQuery.fn.dataTableExt.aTypes.unshift(
11
- function ( sData )
12
- {
13
- if (sData !== null && sData.match(/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/(19|20|21)\d\d$/))
14
- {
15
- return 'date-uk';
26
+ jQuery.extend(jQuery.fn.dataTableExt.oSort, {
27
+ "date-uk-pre": function (a) {
28
+ if (a == null || a == "") {
29
+ return 0;
16
30
  }
17
- return null;
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));
18
41
  }
19
- );
42
+ });
@@ -0,0 +1,74 @@
1
+ /**
2
+ * This plug-in for DataTables represents the ultimate option in extensibility
3
+ * for sorting date / time strings correctly. It uses
4
+ * [Moment.js](http://momentjs.com) to create automatic type detection and
5
+ * sorting plug-ins for DataTables based on a given format. This way, DataTables
6
+ * will automatically detect your temporal information and sort it correctly.
7
+ *
8
+ * For usage instructions, please see the DataTables blog
9
+ * post that [introduces it](//datatables.net/blog/2014-12-18).
10
+ *
11
+ * @name Ultimate Date / Time sorting
12
+ * @summary Sort date and time in any format using Moment.js
13
+ * @author [Allan Jardine](//datatables.net)
14
+ * @depends DataTables 1.10+, Moment.js 1.7+
15
+ *
16
+ * @example
17
+ * $.fn.dataTable.moment( 'HH:mm MMM D, YY' );
18
+ * $.fn.dataTable.moment( 'dddd, MMMM Do, YYYY' );
19
+ *
20
+ * $('#example').DataTable();
21
+ */
22
+
23
+ (function (factory) {
24
+ if (typeof define === "function" && define.amd) {
25
+ define(["jquery", "moment", "datatables.net"], factory);
26
+ } else {
27
+ factory(jQuery, moment);
28
+ }
29
+ }(function ($, moment) {
30
+
31
+ $.fn.dataTable.moment = function ( format, locale, reverseEmpties ) {
32
+ var types = $.fn.dataTable.ext.type;
33
+
34
+ // Add type detection
35
+ types.detect.unshift( function ( d ) {
36
+ if ( d ) {
37
+ // Strip HTML tags and newline characters if possible
38
+ if ( d.replace ) {
39
+ d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
40
+ }
41
+
42
+ // Strip out surrounding white space
43
+ d = $.trim( d );
44
+ }
45
+
46
+ // Null and empty values are acceptable
47
+ if ( d === '' || d === null ) {
48
+ return 'moment-'+format;
49
+ }
50
+
51
+ return moment( d, format, locale, true ).isValid() ?
52
+ 'moment-'+format :
53
+ null;
54
+ } );
55
+
56
+ // Add sorting method - use an integer for the sorting
57
+ types.order[ 'moment-'+format+'-pre' ] = function ( d ) {
58
+ if ( d ) {
59
+ // Strip HTML tags and newline characters if possible
60
+ if ( d.replace ) {
61
+ d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
62
+ }
63
+
64
+ // Strip out surrounding white space
65
+ d = $.trim( d );
66
+ }
67
+
68
+ return !moment(d, format, locale, true).isValid() ?
69
+ (reverseEmpties ? -Infinity : Infinity) :
70
+ parseInt( moment( d, format, locale, true ).format( 'x' ), 10 );
71
+ };
72
+ };
73
+
74
+ }));