From 1e50d85e1f429e55df70004e65ea69bc4d52ddb4 Mon Sep 17 00:00:00 2001 From: Youssef Shahin Date: Wed, 4 Dec 2013 01:23:18 +0200 Subject: [PATCH] Support floats Now the number widget is more flexible and can display floating numbers like price with correct % increase and decrease --- templates/project/widgets/number/number.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/project/widgets/number/number.coffee b/templates/project/widgets/number/number.coffee index 645ee7f3..72ad794b 100644 --- a/templates/project/widgets/number/number.coffee +++ b/templates/project/widgets/number/number.coffee @@ -3,8 +3,8 @@ class Dashing.Number extends Dashing.Widget @accessor 'difference', -> if @get('last') - last = parseInt(@get('last')) - current = parseInt(@get('current')) + last = parseFloat(@get('last')) + current = parseFloat(@get('current')) if last != 0 diff = Math.abs(Math.round((current - last) / last * 100)) "#{diff}%" @@ -13,7 +13,7 @@ class Dashing.Number extends Dashing.Widget @accessor 'arrow', -> if @get('last') - if parseInt(@get('current')) > parseInt(@get('last')) then 'icon-arrow-up' else 'icon-arrow-down' + if parseFloat(@get('current')) > parseFloat(@get('last')) then 'icon-arrow-up' else 'icon-arrow-down' onData: (data) -> if data.status