summaryrefslogtreecommitdiff
path: root/vendor/javascripts/widget.coffee
blob: 980cae34c2622abd1adebd4629e8881d673228e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Dashing.Widget extends Batman.View
  constructor:  ->
    # Set the view path
    @constructor::source = Batman.Filters.underscore(@constructor.name)
    super

    @mixin($(@node).data())
    Dashing.widgets[@id] ||= []
    Dashing.widgets[@id].push(@)
    @mixin(Dashing.lastEvents[@id]) # in case the events from the server came before the widget was rendered

    type = Batman.Filters.dashize(@view)
    $(@node).addClass("widget widget-#{type} #{@id}")

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