Sha256: 681601c4e4528a2e87ac85a83a79097d1e1dd9cfc355e7659e063b21c5882d0b

Contents?: true

Size: 734 Bytes

Versions: 13

Compression:

Stored size: 734 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 '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}"

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dashing-rails-2.5.0 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.4.5 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.4.4 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.4.3 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.4.2 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.4.1 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.4.0 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.3.2 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.3.1 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.3.0 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.2.0 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.1.1 vendor/assets/javascripts/dashing/default_widgets/number.coffee
dashing-rails-2.1.0 vendor/assets/javascripts/dashing/default_widgets/number.coffee