| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
;( function( $ ) { |
| 7 |
'use strict'; |
| 8 |
|
| 9 |
|
| 10 |
$.tablesorter.addParser({ |
| 11 |
id: 'globalize-date', |
| 12 |
is: function () { |
| 13 |
return false; |
| 14 |
}, |
| 15 |
format: function ( str, table, cell, cellIndex ) { |
| 16 |
var globalize, date, |
| 17 |
c = table.config, |
| 18 |
|
| 19 |
|
| 20 |
options = c.globalize && ( c.globalize[ cellIndex ] || c.globalize ) || {}; |
| 21 |
if ( Globalize ) { |
| 22 |
globalize = typeof options.Globalize === 'object' ? |
| 23 |
|
| 24 |
options.Globalize : |
| 25 |
|
| 26 |
Globalize( options.lang || 'en' ); |
| 27 |
if ( !options.Globalize ) { |
| 28 |
|
| 29 |
options.Globalize = globalize; |
| 30 |
} |
| 31 |
} |
| 32 |
date = globalize && globalize.dateParser ? globalize.dateParser( options )( str ) : |
| 33 |
str ? new Date( str ) : str; |
| 34 |
return date instanceof Date && isFinite( date ) ? date.getTime() : str; |
| 35 |
}, |
| 36 |
type: 'numeric' |
| 37 |
}); |
| 38 |
|
| 39 |
|
| 40 |
$.tablesorter.addParser({ |
| 41 |
id: 'globalize-number', |
| 42 |
is: function () { |
| 43 |
return false; |
| 44 |
}, |
| 45 |
format: function ( str, table, cell, cellIndex ) { |
| 46 |
var globalize, num, |
| 47 |
c = table.config, |
| 48 |
|
| 49 |
|
| 50 |
options = c.globalize && ( c.globalize[ cellIndex ] || c.globalize ) || {}; |
| 51 |
if ( Globalize ) { |
| 52 |
globalize = typeof options.Globalize === 'object' ? |
| 53 |
|
| 54 |
options.Globalize : |
| 55 |
|
| 56 |
Globalize( options.lang || 'en' ); |
| 57 |
if ( !options.Globalize ) { |
| 58 |
|
| 59 |
options.Globalize = globalize; |
| 60 |
} |
| 61 |
} |
| 62 |
num = globalize && globalize.numberParser ? globalize.numberParser( options )( str ) : |
| 63 |
str ? $.tablesorter.formatFloat( ( str || '' ).replace( /[^\w,. \-()]/g, '' ), table ) : str; |
| 64 |
return str && typeof num === 'number' ? num : str; |
| 65 |
}, |
| 66 |
type: 'numeric' |
| 67 |
}); |
| 68 |
|
| 69 |
})( jQuery ); |