Sha256: 15048655960441fcd264cdd1fd9fc9f973febf5aa8ea10f6e3d1842700b579ac

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

# Responsible for adding and removing a view's model(s) from Models.PubSub
class Lanes.Views.PubSub extends Lanes.Views.ModelObserver

    model_events:
        'remote-update': 'onChange'

    hideUpdate: (field)->
        Lanes.dom.removeClass(field,"updated")

    showUpdate: (field)->
        Lanes.dom.addClass(field,"updated")
        _.delay(@hideUpdate, 3000, field )

    onChange: (model,change)->
        return unless change.record == this.getModel()
        for field in change.fields
            this.showUpdate(field) if field = @view.query("[name=#{field}]")

    bindModel: (model)->
        Lanes.Models.PubSub.add(model)
        super

    unBindModel: (model)->
        Lanes.Models.PubSub.remove(model)
        super

    teardown: ->
        super
        Lanes.Models.PubSub.remove(model) if model = this.getModel()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lanes-0.1.2 client/lanes/views/PubSub.coffee
lanes-0.1.0 client/lanes/views/PubSub.coffee