Anton Shestakov <av6@dwimlabs.net>, Sat, 02 Apr 2016 00:51:36 +0800
coffee: various stylistic fixes
coffee/calls.coffee
Permissions: -rw-r--r--
class Tram.Call extends Backbone.Model @on('change:local/stream', @updateLocalStreamURL) @on('change:remote/stream', @updateRemoteStreamURL) updateStreamURL: (sattr, uattr) -> URL.revokeObjectURL(@get(uattr)) @set(uattr, URL.createObjectURL(stream)) @updateStreamURL('local/stream', 'local/stream/url') updateRemoteStreamURL: -> @updateStreamURL('remote/stream', 'remote/stream/url') class Tram.Calls extends Backbone.Collection class Tram.CallView extends Backbone.View template: $('#video-block-template').html() 'click [data-mute-cam]': -> @model.set('local/video/muted', true) 'click [data-unmute-cam]': -> @model.set('local/video/muted', false) 'click [data-mute-mic]': -> @model.set('local/audio/muted', true) 'click [data-unmute-mic]': -> @model.set('local/audio/muted', false) 'click [data-mute-audio]': -> @model.set('remote/audio/muted', true) 'click [data-unmute-audio]': -> @model.set('remote/audio/muted', false) @$local = @$('video.local') @$remote = @$('video.remote') @listenTo(@model, 'change:local/stream/url', @updateLocal) @listenTo(@model, 'change:remote/stream/url', @updateRemote) @listenTo(@model, 'change:local/video/muted', @muteCam) @listenTo(@model, 'change:local/audio/muted', @muteMic) @listenTo(@model, 'change:remote/audio/muted', @muteAudio) if @model.has('local/stream/url') @updateVideo(@$local, @model.get('local/stream/url')) if @model.has('remote/stream/url') @updateVideo(@$remote, @model.get('remote/stream/url')) updateVideo: ($video, url) -> enableTracks: (tracks, state) -> muted = @model.get('local/video/muted') @enableTracks(@model.get('local/stream')?.getVideoTracks?(), not muted) muted = @model.get('local/audio/muted') @enableTracks(@model.get('local/stream')?.getAudioTracks?(), not muted) muted = @model.get('remote/audio/muted') @enableTracks(@model.get('remote/stream')?.getAudioTracks?(), not muted) @rivet = rivets.bind(@el, model: @model, view: this) class Tram.CallsApp extends Backbone.View @listenTo(@collection, 'add', @onAdd) @listenTo(@collection, 'remove', @onRemove) model.view = new Tram.CallView(model: model) @$el.append model.view.render().el