Sorting: Fix mix of tabs and spaces for datetime-moment plug-in

- Also use $.trim for whitespace removal. We've got jQuery, so might as
  well use it for compatibility
pull/295/head
Allan Jardine 8 years ago
parent 0e201c0016
commit 280402d05e

@ -35,14 +35,13 @@ $.fn.dataTable.moment = function ( format, locale ) {
types.detect.unshift( function ( d ) { types.detect.unshift( function ( d ) {
if ( d ) { if ( d ) {
// Strip HTML tags and newline characters if possible // Strip HTML tags and newline characters if possible
if ( d.replace ) { if ( d.replace ) {
d = d.replace(/(<.*?>)|(\r?\n|\r)/g, ''); d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
} }
// Strip out surrounding whitespace if possible
if ( d.trim ) { // Strip out surrounding white space
d = d.trim(); d = $.trim( d );
} }
}
// Null and empty values are acceptable // Null and empty values are acceptable
if ( d === '' || d === null ) { if ( d === '' || d === null ) {
@ -57,15 +56,14 @@ $.fn.dataTable.moment = function ( format, locale ) {
// Add sorting method - use an integer for the sorting // Add sorting method - use an integer for the sorting
types.order[ 'moment-'+format+'-pre' ] = function ( d ) { types.order[ 'moment-'+format+'-pre' ] = function ( d ) {
if ( d ) { if ( d ) {
// Strip HTML tags and newline characters if possible // Strip HTML tags and newline characters if possible
if ( d.replace ) { if ( d.replace ) {
d = d.replace(/(<.*?>)|(\r?\n|\r)/g, ''); d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
} }
// Strip out surrounding whitespace if possible
if ( d.trim ) { // Strip out surrounding white space
d = d.trim(); d = $.trim( d );
} }
}
return d === '' || d === null ? return d === '' || d === null ?
-Infinity : -Infinity :

Loading…
Cancel
Save