| 2 |
lars |
1 |
/**
|
|
|
2 |
* Often a list of data which has titles in it (books, albums etc) will have
|
|
|
3 |
* the word "the" at the start of some individual titles, which you don't want
|
|
|
4 |
* to include in your sorting order. This plug-in will strip the word "the"
|
|
|
5 |
* from the start of a string and sort on what is left.
|
|
|
6 |
*
|
|
|
7 |
* @name Anti-"the"
|
|
|
8 |
* @summary Sort with the prefixed word `dt-string The` removed, if present
|
|
|
9 |
* @author [Allan Jardine](http://sprymedia.co.uk)
|
|
|
10 |
*
|
|
|
11 |
* @example
|
|
|
12 |
* $('#example').dataTable( {
|
|
|
13 |
* columnDefs: [
|
|
|
14 |
* { type: 'anti-the', targets: 0 }
|
|
|
15 |
* ]
|
|
|
16 |
* } );
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
|
|
|
20 |
"anti-the-pre": function ( a ) {
|
|
|
21 |
return a.replace(/^the /i, "");
|
|
|
22 |
},
|
|
|
23 |
|
|
|
24 |
"anti-the-asc": function ( a, b ) {
|
|
|
25 |
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
|
|
26 |
},
|
|
|
27 |
|
|
|
28 |
"anti-the-desc": function ( a, b ) {
|
|
|
29 |
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
|
|
30 |
}
|
|
|
31 |
} );
|