summaryrefslogtreecommitdiff
path: root/vendor/javascripts/widget.coffee
blob: 7be3a5d5d2e725c01fcf97816d51236995e68ff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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}")


  @::on 'ready', ->
    Dashing.Widget.fire 'ready'

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