Skip to content

Commit eaf7b3b

Browse files
committed
cherry-pick Shopify/dashing#402
1 parent 3bb1ba1 commit eaf7b3b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

vendor/assets/javascripts/dashing/dashing-src.coffee

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,17 @@ class Dashing.Widget extends Batman.View
5959

6060
receiveData: (data) =>
6161
@mixin(data)
62+
@addStatus(data)
6263
@onData(data)
6364

65+
addStatus: (data) =>
66+
if data.status
67+
# clear existing "status-*" classes
68+
$(@get('node')).attr 'class', (i,c) ->
69+
c.replace /\bstatus-\S+/g, ''
70+
# add new class
71+
$(@get('node')).addClass "status-#{data.status}"
72+
6473
onData: (data) =>
6574
# Widgets override this to handle incoming data
6675

vendor/assets/javascripts/dashing/default_widgets/number.coffee

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,3 @@ class Dashing.Number extends Dashing.Widget
1414
@accessor 'arrow', ->
1515
if @get('last')
1616
if parseInt(@get('current')) > parseInt(@get('last')) then 'fa fa-arrow-up' else 'fa fa-arrow-down'
17-
18-
onData: (data) ->
19-
if data.status
20-
# clear existing "status-*" classes
21-
$(@get('node')).attr 'class', (i,c) ->
22-
c.replace /\bstatus-\S+/g, ''
23-
# add new class
24-
$(@get('node')).addClass "status-#{data.status}"

0 commit comments

Comments
 (0)