annotate DataTables-1.9.4/media/src/ext/ext.sorting.js @ 2:e8755431a0cd draft

fixed missing dependencies
author saskia-hiltemann
date Tue, 30 Sep 2014 09:47:14 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 $.extend( DataTable.ext.oSort, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 * text sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 "string-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 if ( typeof a != 'string' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 a = (a !== null && a.toString) ? a.toString() : '';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 return a.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 "string-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 "string-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 * html sorting (ignore html tags)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 "html-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 return a.replace( /<.*?>/g, "" ).toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 "html-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 "html-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 * date sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 "date-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 var x = Date.parse( a );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 if ( isNaN(x) || x==="" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 x = Date.parse( "01/01/1970 00:00:00" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 return x;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 "date-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 return x - y;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 "date-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 return y - x;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 * numerical sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 "numeric-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 return (a=="-" || a==="") ? 0 : a*1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 "numeric-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 return x - y;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 "numeric-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 return y - x;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 } );