Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Adding status to all widgets #402

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions javascripts/dashing.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,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
7 changes: 0 additions & 7 deletions templates/project/widgets/number/number.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,3 @@ class Dashing.Number extends Dashing.Widget
if @get('last')
if parseInt(@get('current')) > parseInt(@get('last')) then 'icon-arrow-up' else 'icon-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}"