From c38e140a5214d5ae4348f9df80db8c8b0b9301ad Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Wed, 18 Jun 2014 14:24:30 +0100 Subject: [PATCH] Fix: `number` renderer displayed numbers incorrectly for negative numbers --- .datatables-commit-sync | 2 +- media/js/jquery.dataTables.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index e2d78731..af939057 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -1fcedce42d4cb20dfa1e82e6bf7f9f871baac309 +89ab148ad45a219c2623fcc75b15a59b7d0c7a2e diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index dfc8cff6..af53b04e 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -14139,13 +14139,15 @@ number: function ( thousands, decimal, precision, prefix ) { return { display: function ( d ) { - d = parseFloat( d ); + var negative = d < 0 ? '-' : ''; + d = Math.abs( parseFloat( d ) ); + var intPart = parseInt( d, 10 ); var floatPart = precision ? decimal+(d - intPart).toFixed( precision ).substring( 2 ): ''; - return (prefix||'') + + return negative + (prefix||'') + intPart.toString().replace( /\B(?=(\d{3})+(?!\d))/g, thousands ) +