You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/app/assets/javascripts/player/player_view.js.coffee

46 lines
1.0 KiB
CoffeeScript

class AsciiIo.PlayerView extends Backbone.View
initialize: (options) ->
@movie = new AsciiIo.Movie(@model)
@movie.load()
@terminalView = new AsciiIo.TerminalView(
cols: this.options.cols
lines: this.options.lines
)
@vt = new AsciiIo.VT(options.cols, options.lines, @terminalView)
@createChildViews()
@bindEvents()
createChildViews: ->
@$el.append(@terminalView.$el)
@terminalView.afterInsertedToDom()
@hudView = new AsciiIo.HudView()
@$el.append(@hudView.$el)
bindEvents: ->
@terminalView.on 'terminal-click', =>
@movie.togglePlay()
@hudView.on 'hud-play-click', =>
@movie.togglePlay()
@hudView.on 'hud-seek-click', (percent) =>
@movie.seek(percent)
@movie.on 'movie-frame', (frame) =>
@vt.feed(frame)
@movie.on 'movie-awake', (frame) =>
@terminalView.restartCursorBlink()
@movie.on 'movie-finished', =>
@terminalView.stopCursorBlink()
play: ->
if @movie.isLoaded()
@movie.play()