Sha256: b0289879edaf52a6260a4ff8e1c71dc25ce636e87c12bc0019ed4f48df1a6c8d

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 Bytes

Contents

class Dashing.Number extends Dashing.Widget

  @accessor 'current', Dashing.AnimatedValue

  @accessor 'difference', ->
    if @get('last')
      last = parseInt(@get('last'))
      current = parseInt(@get('current'))
      if last != 0
        diff = Math.abs(Math.round((current - last) / last * 100))
        "#{diff}%"
    else
      ""

  @accessor 'arrow', ->
    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}"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dashing-rails-2.0.2 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.0.1 vendor/assets/javascripts/dashing/default_widgets/number.coffee