Skip to content

Commit

Permalink
cherry-pick Shopify/dashing#402
Browse files Browse the repository at this point in the history
  • Loading branch information
gottfrois committed Jan 17, 2017
1 parent 3bb1ba1 commit eaf7b3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 9 additions & 0 deletions vendor/assets/javascripts/dashing/dashing-src.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,17 @@ class Dashing.Widget extends Batman.View

receiveData: (data) =>
@mixin(data)
@addStatus(data)
@onData(data)

addStatus: (data) =>
if data.status
# clear existing "status-*" classes
$(@get('node')).attr 'class', (i,c) ->
c.replace /\bstatus-\S+/g, ''
# add new class
$(@get('node')).addClass "status-#{data.status}"

onData: (data) =>
# Widgets override this to handle incoming data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,3 @@ class Dashing.Number extends Dashing.Widget
@accessor 'arrow', ->
if @get('last')
if parseInt(@get('current')) > parseInt(@get('last')) then 'fa fa-arrow-up' else 'fa fa-arrow-down'

onData: (data) ->
if data.status
# clear existing "status-*" classes
$(@get('node')).attr 'class', (i,c) ->
c.replace /\bstatus-\S+/g, ''
# add new class
$(@get('node')).addClass "status-#{data.status}"

0 comments on commit eaf7b3b

Please sign in to comment.