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

Loading…
Cancel
Save