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.
- checksums.yaml +4 -4
- data/.gitattributes +1 -0
- data/README.md +28 -1
- data/app/assets/javascripts/datatables/dataTables.uikit.js +2 -2
- data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +42 -29
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap.js +1 -1
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap4.js +8 -2
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +6 -3
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.foundation.js +5 -4
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +58 -6
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +16 -5
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.semanticui.js +1 -1
- data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +267 -152
- data/app/assets/javascripts/datatables/extensions/ColReorder/colReorder.foundation.js +1 -1
- data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +121 -52
- data/app/assets/javascripts/datatables/extensions/FixedColumns/dataTables.fixedColumns.js +32 -5
- data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +166 -63
- data/app/assets/javascripts/datatables/extensions/KeyTable/keyTable.foundation.js +1 -1
- data/app/assets/javascripts/datatables/extensions/RowGroup/dataTables.rowGroup.js +105 -53
- data/app/assets/javascripts/datatables/extensions/RowGroup/rowGroup.foundation.js +1 -1
- data/app/assets/javascripts/datatables/extensions/RowGroup/{rowGroup.semanicui.js → rowGroup.semanticui.js} +0 -0
- data/app/assets/javascripts/datatables/extensions/RowReorder/dataTables.rowReorder.js +10 -9
- data/app/assets/javascripts/datatables/extensions/RowReorder/rowReorder.foundation.js +1 -1
- data/app/assets/javascripts/datatables/extensions/Scroller/dataTables.scroller.js +519 -636
- data/app/assets/javascripts/datatables/extensions/Scroller/scroller.foundation.js +1 -1
- data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +49 -18
- data/app/assets/javascripts/datatables/extensions/Select/select.foundation.js +1 -1
- data/app/assets/javascripts/datatables/jquery.dataTables.js +97 -60
- data/app/assets/javascripts/datatables/plugins/api/average.js +7 -6
- data/app/assets/javascripts/datatables/plugins/api/sum.js +7 -6
- data/app/assets/javascripts/datatables/plugins/pagination/ellipses.js +160 -0
- data/app/assets/javascripts/datatables/plugins/pagination/extjs.js +137 -0
- data/app/assets/javascripts/datatables/plugins/pagination/four_button.js +110 -0
- data/app/assets/javascripts/datatables/plugins/pagination/full_numbers_no_ellipses.js +59 -0
- data/app/assets/javascripts/datatables/plugins/pagination/input.js +22 -19
- data/app/assets/javascripts/datatables/plugins/pagination/scrolling.js +130 -0
- data/app/assets/javascripts/datatables/plugins/pagination/select.js +97 -0
- data/app/assets/javascripts/datatables/plugins/pagination/simple_incremental_bootstrap.js +154 -0
- data/app/assets/javascripts/datatables/plugins/pagination/simple_numbers_no_ellipses.js +59 -0
- data/app/assets/javascripts/datatables/plugins/search/dataTables.alphabetSearch.js +440 -399
- data/app/assets/javascripts/datatables/plugins/sorting/enum.js +51 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/date-dd-MMM-yyyy.js +63 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/date-de.js +125 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/date-eu.js +64 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/date-euro.js +48 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/date-uk.js +35 -12
- data/app/assets/javascripts/datatables/plugins/type-detection/datetime-moment.js +74 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/datetime-us.js +86 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/file-size.js +37 -13
- data/app/assets/javascripts/datatables/plugins/type-detection/ip-address.js +113 -11
- data/app/assets/javascripts/datatables/plugins/type-detection/numString.js +63 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/percent.js +34 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/time-elapsed-dhms.js +42 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/time.js +56 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/title-numeric.js +40 -0
- data/app/assets/javascripts/datatables/plugins/type-detection/title-string.js +36 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.dataTables.scss +10 -3
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.scss +12 -3
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.scss +13 -6
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.scss +2 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.scss +5 -1
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.scss +1 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.scss +2 -1
- data/app/assets/stylesheets/datatables/extensions/Buttons/common.scss +10 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +42 -30
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap.scss +11 -7
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.foundation.scss +1 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.dataTables.scss +13 -5
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.dataTables.scss +20 -2
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.dataTables.scss +15 -2
- data/lib/jquery-datatables/version.rb +1 -1
- metadata +26 -12
- data/app/assets/javascripts/datatables/dataTables.bootstrap2.js +0 -162
- data/app/assets/javascripts/datatables/extensions/ColReorder/colReorder.semanicui.js +0 -38
- data/app/assets/javascripts/datatables/extensions/FixedColumns/fixedColumns.semanicui.js +0 -38
- data/app/assets/javascripts/datatables/extensions/FixedHeader/fixedHeader.semanicui.js +0 -38
- data/app/assets/javascripts/datatables/extensions/KeyTable/keyTable.semanicui.js +0 -38
- data/app/assets/javascripts/datatables/extensions/RowReorder/rowReorder.semanicui.js +0 -38
- data/app/assets/stylesheets/datatables/dataTables.bootstrap2.scss +0 -178
@@ -0,0 +1,86 @@
|
|
1
|
+
/*
|
2
|
+
* Adds a new sorting option to dataTables called `datetime-us`.
|
3
|
+
*
|
4
|
+
* Also included is a type detection plug-in. Matches and sorts date / time
|
5
|
+
* strings in the format: `(m)m/(d)d/(yy)yy (h)h/m(m) (am|pm)`. For example:
|
6
|
+
*
|
7
|
+
* * 1/1/13 1:4 pm
|
8
|
+
* * 01/01/2013 01:04 PM
|
9
|
+
* * 1/1/2013 1:04 Pm
|
10
|
+
*
|
11
|
+
* Please note that this plug-in is **deprecated*. The
|
12
|
+
* [datetime](//datatables.net/blog/2014-12-18) plug-in provides enhanced
|
13
|
+
* functionality and flexibility.
|
14
|
+
*
|
15
|
+
* @name Date / time - US
|
16
|
+
* @summary Sort date / time in the format `m/d/yy h:m am|pm`
|
17
|
+
* @author [Kevin Gravier](http://mrkmg.com/)
|
18
|
+
* @deprecated
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* $('#example').dataTable( {
|
22
|
+
* columnDefs: [
|
23
|
+
* { type: 'datetime-us', targets: 0 }
|
24
|
+
* ]
|
25
|
+
* } );
|
26
|
+
*/
|
27
|
+
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
28
|
+
"datetime-us-pre": function (a) {
|
29
|
+
var b = a.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4}) (\d{1,2}):(\d{1,2}) (am|pm|AM|PM|Am|Pm)/),
|
30
|
+
month = b[1],
|
31
|
+
day = b[2],
|
32
|
+
year = b[3],
|
33
|
+
hour = b[4],
|
34
|
+
min = b[5],
|
35
|
+
ap = b[6].toLowerCase();
|
36
|
+
|
37
|
+
if (hour == '12') {
|
38
|
+
hour = '0';
|
39
|
+
if (ap == 'pm') {
|
40
|
+
hour = parseInt(hour, 10) + 12;
|
41
|
+
}
|
42
|
+
|
43
|
+
if (year.length == 2) {
|
44
|
+
if (parseInt(year, 10) < 70) {
|
45
|
+
year = '20' + year;
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
year = '19' + year;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
if (month.length == 1) {
|
52
|
+
month = '0' + month;
|
53
|
+
}
|
54
|
+
if (day.length == 1) {
|
55
|
+
day = '0' + day;
|
56
|
+
}
|
57
|
+
if (hour.length == 1) {
|
58
|
+
hour = '0' + hour;
|
59
|
+
}
|
60
|
+
if (min.length == 1) {
|
61
|
+
min = '0' + min;
|
62
|
+
}
|
63
|
+
|
64
|
+
var tt = year + month + day + hour + min;
|
65
|
+
return tt;
|
66
|
+
}
|
67
|
+
},
|
68
|
+
|
69
|
+
"datetime-us-asc": function (a, b) {
|
70
|
+
return a - b;
|
71
|
+
},
|
72
|
+
|
73
|
+
"datetime-us-desc": function (a, b) {
|
74
|
+
return b - a;
|
75
|
+
}
|
76
|
+
});
|
77
|
+
|
78
|
+
jQuery.fn.dataTableExt.aTypes.unshift(
|
79
|
+
function (sData) {
|
80
|
+
if (sData !== null && sData.match(/\d{1,2}\/\d{1,2}\/\d{2,4} \d{1,2}:\d{1,2} (am|pm|AM|PM|Am|Pm)/)) {
|
81
|
+
|
82
|
+
return 'datetime-us';
|
83
|
+
}
|
84
|
+
return null;
|
85
|
+
}
|
86
|
+
);
|
@@ -1,20 +1,44 @@
|
|
1
1
|
/**
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
2
|
+
* When dealing with computer file sizes, it is common to append a post fix
|
3
|
+
* such as B, KB, MB or GB to a string in order to easily denote the order of
|
4
|
+
* magnitude of the file size. This plug-in allows sorting to take these
|
5
|
+
* indicates of size into account.
|
6
|
+
*
|
7
|
+
* A counterpart type detection plug-in is also available.
|
5
8
|
*
|
6
9
|
* @name File size
|
7
|
-
* @summary
|
10
|
+
* @summary Sort abbreviated file sizes correctly (8MB, 4KB, etc)
|
8
11
|
* @author Allan Jardine - datatables.net
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* $('#example').DataTable( {
|
15
|
+
* columnDefs: [
|
16
|
+
* { type: 'file-size', targets: 0 }
|
17
|
+
* ]
|
18
|
+
* } );
|
9
19
|
*/
|
10
20
|
|
11
|
-
jQuery.fn.dataTable.ext.type.
|
12
|
-
|
13
|
-
|
14
|
-
|
21
|
+
jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function (data) {
|
22
|
+
var matches = data.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)/i);
|
23
|
+
var multipliers = {
|
24
|
+
b: 1,
|
25
|
+
bytes: 1,
|
26
|
+
kb: 1000,
|
27
|
+
kib: 1024,
|
28
|
+
mb: 1000000,
|
29
|
+
mib: 1048576,
|
30
|
+
gb: 1000000000,
|
31
|
+
gib: 1073741824,
|
32
|
+
tb: 1000000000000,
|
33
|
+
tib: 1099511627776,
|
34
|
+
pb: 1000000000000000,
|
35
|
+
pib: 1125899906842624
|
36
|
+
};
|
15
37
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
38
|
+
if (matches) {
|
39
|
+
var multiplier = multipliers[matches[2].toLowerCase()];
|
40
|
+
return parseFloat(matches[1]) * multiplier;
|
41
|
+
} else {
|
42
|
+
return -1;
|
43
|
+
};
|
44
|
+
};
|
@@ -1,18 +1,120 @@
|
|
1
1
|
/**
|
2
|
-
*
|
3
|
-
*
|
2
|
+
* Sorts a column containing IP addresses (IPv4 and IPv6) or IPv4 address and port delimited by ':' in typical dot
|
3
|
+
* notation / colon. This can be most useful when using DataTables for a
|
4
|
+
* networking application, and reporting information containing IP address.
|
4
5
|
*
|
5
|
-
* @name IP
|
6
|
-
* @summary
|
6
|
+
* @name IP addresses
|
7
|
+
* @summary Sort IP addresses numerically
|
8
|
+
* @author Dominique Fournier
|
7
9
|
* @author Brad Wasson
|
10
|
+
* @author Peter Vilhan
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* $('#example').dataTable( {
|
14
|
+
* columnDefs: [
|
15
|
+
* { type: 'ip-address', targets: 0 }
|
16
|
+
* ]
|
17
|
+
* } );
|
8
18
|
*/
|
9
19
|
|
10
|
-
|
11
|
-
|
12
|
-
{
|
13
|
-
|
14
|
-
|
20
|
+
|
21
|
+
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
22
|
+
"ip-address-pre": function (a) {
|
23
|
+
var i, item;
|
24
|
+
var m, n, t;
|
25
|
+
var x, xa;
|
26
|
+
|
27
|
+
if (!a) {
|
28
|
+
return 0
|
29
|
+
}
|
30
|
+
|
31
|
+
a = a.replace(/<[\s\S]*?>/g, "");
|
32
|
+
//IPv4:Port
|
33
|
+
t = a.split(":");
|
34
|
+
if (t.length == 2) {
|
35
|
+
m = t[0].split(".");
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
m = a.split(".");
|
39
|
+
}
|
40
|
+
n = a.split(":");
|
41
|
+
x = "";
|
42
|
+
xa = "";
|
43
|
+
|
44
|
+
if (m.length == 4) {
|
45
|
+
// IPV4
|
46
|
+
for (i = 0; i < m.length; i++) {
|
47
|
+
item = m[i];
|
48
|
+
|
49
|
+
if (item.length == 1) {
|
50
|
+
x += "00" + item;
|
51
|
+
}
|
52
|
+
else if (item.length == 2) {
|
53
|
+
x += "0" + item;
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
x += item;
|
57
|
+
}
|
58
|
+
}
|
15
59
|
}
|
16
|
-
|
60
|
+
else if (n.length > 0) {
|
61
|
+
// IPV6
|
62
|
+
var count = 0;
|
63
|
+
for (i = 0; i < n.length; i++) {
|
64
|
+
item = n[i];
|
65
|
+
|
66
|
+
if (i > 0) {
|
67
|
+
xa += ":";
|
68
|
+
}
|
69
|
+
|
70
|
+
if (item.length === 0) {
|
71
|
+
count += 0;
|
72
|
+
}
|
73
|
+
else if (item.length == 1) {
|
74
|
+
xa += "000" + item;
|
75
|
+
count += 4;
|
76
|
+
}
|
77
|
+
else if (item.length == 2) {
|
78
|
+
xa += "00" + item;
|
79
|
+
count += 4;
|
80
|
+
}
|
81
|
+
else if (item.length == 3) {
|
82
|
+
xa += "0" + item;
|
83
|
+
count += 4;
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
xa += item;
|
87
|
+
count += 4;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
// Padding the ::
|
92
|
+
n = xa.split(":");
|
93
|
+
var paddDone = 0;
|
94
|
+
|
95
|
+
for (i = 0; i < n.length; i++) {
|
96
|
+
item = n[i];
|
97
|
+
|
98
|
+
if (item.length === 0 && paddDone === 0) {
|
99
|
+
for (var padding = 0; padding < (32 - count); padding++) {
|
100
|
+
x += "0";
|
101
|
+
paddDone = 1;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
x += item;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
return x;
|
111
|
+
},
|
112
|
+
|
113
|
+
"ip-address-asc": function (a, b) {
|
114
|
+
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
115
|
+
},
|
116
|
+
|
117
|
+
"ip-address-desc": function (a, b) {
|
118
|
+
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
17
119
|
}
|
18
|
-
);
|
120
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* This plug in will sort only on the number value that is included anywhere in a Regex.
|
4
|
+
* This is useful for sorting data which requires some extra context to be included in the table.
|
5
|
+
*
|
6
|
+
* @name numString
|
7
|
+
* @summary Sorting for number value that is included anywhere in a regex.
|
8
|
+
* @author [Sandy Galloway](http://datatables.net)
|
9
|
+
*
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* //This example shows a mixture of text and number values, with the number at the start of the expression.
|
13
|
+
* //It is using regex and start and end of expression tags.
|
14
|
+
* //It will match "5 examples completed." for example.
|
15
|
+
* $(document).ready( function(){
|
16
|
+
* $.fn.dataTable.numString(/^\d+ examples? completed.$/);
|
17
|
+
* var table = $('#example').DataTable();
|
18
|
+
* })
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* //This example shows a mixture of text and number values, with the number at the end of the expression.
|
22
|
+
* //It is using regex and start and end of expression tags.
|
23
|
+
* //It will match "Examples left: 67" for example.
|
24
|
+
* $(document).ready( function(){
|
25
|
+
* $.fn.dataTable.numString(/^Examples? left: \d+$/);
|
26
|
+
* var table = $('#example').DataTable();
|
27
|
+
* })
|
28
|
+
*
|
29
|
+
* @example
|
30
|
+
* //This example shows a mixture of text and number values, with the number in the middle of the expression.
|
31
|
+
* //It is using regex and no start and end of expression tags.
|
32
|
+
* //It will match "Only 1 left." for example.
|
33
|
+
* $(document).ready(function(){
|
34
|
+
* $.fn.dataTable.numString(/Only \d+ left./);
|
35
|
+
* var table = $('example').DataTable();
|
36
|
+
* })
|
37
|
+
*
|
38
|
+
*/
|
39
|
+
$.fn.dataTable.numString = function(format) {
|
40
|
+
//This is the type detection plug in
|
41
|
+
$.fn.dataTable.ext.type.detect.unshift(function(data) {
|
42
|
+
if (typeof data !== "string") {
|
43
|
+
return null;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (data.match(format)) {
|
47
|
+
return "numString-" + format.source;
|
48
|
+
}
|
49
|
+
|
50
|
+
return null;
|
51
|
+
});
|
52
|
+
|
53
|
+
//This is the ordering plug in
|
54
|
+
$.fn.dataTable.ext.type.order[
|
55
|
+
"numString-" + format.source + "-pre"
|
56
|
+
] = function(data) {
|
57
|
+
var num = data.replace(/\D/g, "");
|
58
|
+
|
59
|
+
return num * 1;
|
60
|
+
};
|
61
|
+
// end plug-in
|
62
|
+
};
|
63
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* Sort numeric data which has a percent sign with it.
|
3
|
+
*
|
4
|
+
* DataTables 1.10+ has percentage data type detection and sorting abilities
|
5
|
+
* built-in. As such this plug-in is marked as deprecated, but might be useful
|
6
|
+
* when working with old versions of DataTables.
|
7
|
+
*
|
8
|
+
* @name Percentage
|
9
|
+
* @summary Sort numeric data with a postfixed percentage symbol
|
10
|
+
* @deprecated
|
11
|
+
* @author [Jonathan Romley](http://jonathanromley.org/)
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* $('#example').dataTable( {
|
15
|
+
* columnDefs: [
|
16
|
+
* { type: 'percent', targets: 0 }
|
17
|
+
* ]
|
18
|
+
* } );
|
19
|
+
*/
|
20
|
+
|
21
|
+
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
|
22
|
+
"percent-pre": function ( a ) {
|
23
|
+
var x = (a == "-") ? 0 : a.replace( /%/, "" );
|
24
|
+
return parseFloat( x );
|
25
|
+
},
|
26
|
+
|
27
|
+
"percent-asc": function ( a, b ) {
|
28
|
+
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
29
|
+
},
|
30
|
+
|
31
|
+
"percent-desc": function ( a, b ) {
|
32
|
+
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
33
|
+
}
|
34
|
+
} );
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Created by caochenghua on 2016/12/22.
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* When dealing with time elapsed, it is common to append a post fix
|
7
|
+
* such as d(day), h(hour), m(minute) or s(second) to a string in order to easily denote the brief duration
|
8
|
+
* of the time span from now. This plug-in allows sorting to take these
|
9
|
+
* indicates of size into account.
|
10
|
+
*
|
11
|
+
* A counterpart type detection plug-in is also available.
|
12
|
+
*
|
13
|
+
* @name Time span
|
14
|
+
* @summary Sort abbreviated time span correctly (2d 3h, 2h 8m, 3m 8s, 30s, etc)
|
15
|
+
* @author Allan Jardine - datatables.net
|
16
|
+
*
|
17
|
+
* @example
|
18
|
+
* $('#example').DataTable( {
|
19
|
+
* columnDefs: [
|
20
|
+
* { type: 'time-elapsed-dhms', targets: 0 }
|
21
|
+
* ]
|
22
|
+
* } );
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
jQuery.fn.dataTable.ext.type.order['time-elapsed-dhms-pre'] = function(data) {
|
27
|
+
|
28
|
+
var matches = data.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)/i);
|
29
|
+
var multipliers = {
|
30
|
+
s: 1,
|
31
|
+
m: 60,
|
32
|
+
h: 3600,
|
33
|
+
d: 86400
|
34
|
+
};
|
35
|
+
|
36
|
+
if (matches) {
|
37
|
+
var multiplier = multipliers[matches[2].toLowerCase()];
|
38
|
+
return parseFloat(matches[1]) * multiplier;
|
39
|
+
} else {
|
40
|
+
return -1;
|
41
|
+
};
|
42
|
+
};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/**
|
2
|
+
* This plug-in provides the ability to sort columns that contains time
|
3
|
+
* information in the most common formats used. It will automatically detect
|
4
|
+
* those date types.
|
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 Time (dd/mm/YY)
|
11
|
+
* @summary Sort Times in the formats: `hh:mm, hh:mm:ss, hh:mm tt, hh:mm:ss tt`
|
12
|
+
* e.g. '22:50, 22:50:40, 10:50 pm, 10:50:40 pm'
|
13
|
+
* am and pm are not case sensitive. white space is not compulsory
|
14
|
+
* @author David Stoneham
|
15
|
+
* @deprecated
|
16
|
+
*
|
17
|
+
* @example
|
18
|
+
* $('#example').dataTable( {
|
19
|
+
* columnDefs: [
|
20
|
+
* { type: 'time-uni', targets: 0 }
|
21
|
+
* ]
|
22
|
+
* } );
|
23
|
+
*/
|
24
|
+
|
25
|
+
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
26
|
+
"time-uni-pre": function (a) {
|
27
|
+
var uniTime;
|
28
|
+
|
29
|
+
if (a.toLowerCase().indexOf("am") > -1 || (a.toLowerCase().indexOf("pm") > -1 && Number(a.split(":")[0]) === 12)) {
|
30
|
+
uniTime = a.toLowerCase().split("pm")[0].split("am")[0];
|
31
|
+
while (uniTime.indexOf(":") > -1) {
|
32
|
+
uniTime = uniTime.replace(":", "");
|
33
|
+
}
|
34
|
+
} else if (a.toLowerCase().indexOf("pm") > -1 || (a.toLowerCase().indexOf("am") > -1 && Number(a.split(":")[0]) === 12)) {
|
35
|
+
uniTime = Number(a.split(":")[0]) + 12;
|
36
|
+
var leftTime = a.toLowerCase().split("pm")[0].split("am")[0].split(":");
|
37
|
+
for (var i = 1; i < leftTime.length; i++) {
|
38
|
+
uniTime = uniTime + leftTime[i].trim().toString();
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
uniTime = a.replace(":", "");
|
42
|
+
while (uniTime.indexOf(":") > -1) {
|
43
|
+
uniTime = uniTime.replace(":", "");
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return Number(uniTime);
|
47
|
+
},
|
48
|
+
|
49
|
+
"time-uni-asc": function (a, b) {
|
50
|
+
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
51
|
+
},
|
52
|
+
|
53
|
+
"time-uni-desc": function (a, b) {
|
54
|
+
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
55
|
+
}
|
56
|
+
});
|