Option to disable HUD

openid
Marcin Kulik 12 years ago
parent 4edd5ead9e
commit b1ecbc16c0

@ -5,7 +5,7 @@ class AsciiIo.PlayerView extends Backbone.View
initialize: (options) -> initialize: (options) ->
@prepareSelfView() @prepareSelfView()
@createRendererView() @createRendererView()
@createHudView() @createHudView() if options.hud
@fetchModel() @fetchModel()
@showLoadingIndicator() @showLoadingIndicator()
@ -24,7 +24,7 @@ class AsciiIo.PlayerView extends Backbone.View
createHudView: -> createHudView: ->
@hudView = new AsciiIo.HudView(cols: @options.cols) @hudView = new AsciiIo.HudView(cols: @options.cols)
@$el.append(@hudView.$el) @$el.append @hudView.$el
fetchModel: -> fetchModel: ->
@model.fetch success: => @onModelFetched() @model.fetch success: => @onModelFetched()
@ -53,7 +53,7 @@ class AsciiIo.PlayerView extends Backbone.View
onModelReady: -> onModelReady: ->
@hideLoadingIndicator() @hideLoadingIndicator()
@hudView.setDuration @model.get('duration') @hudView.setDuration @model.get('duration') if @options.hud
@createMovie() @createMovie()
@bindEvents() @bindEvents()
@ -79,9 +79,12 @@ class AsciiIo.PlayerView extends Backbone.View
@movie.on 'reset', => @vt.reset() @movie.on 'reset', => @vt.reset()
@movie.on 'finished', => @vt.stopCursorBlink() @movie.on 'finished', => @vt.stopCursorBlink()
@movie.on 'wakeup', => @vt.restartCursorBlink() @movie.on 'wakeup', => @vt.restartCursorBlink()
@movie.on 'paused', => @hudView.onPause()
@movie.on 'resumed', => @hudView.onResume() if @options.hud
@movie.on 'time', (time) => @hudView.updateTime(time) @movie.on 'paused', => @hudView.onPause()
@movie.on 'resumed', => @hudView.onResume()
@movie.on 'time', (time) => @hudView.updateTime(time)
@movie.on 'started', => @$el.removeClass('not-started') @movie.on 'started', => @$el.removeClass('not-started')
@movie.on 'data', (data) => @movie.on 'data', (data) =>
@ -94,8 +97,9 @@ class AsciiIo.PlayerView extends Backbone.View
@vt.on 'cursor:show', => @rendererView.showCursor true @vt.on 'cursor:show', => @rendererView.showCursor true
@vt.on 'cursor:hide', => @rendererView.showCursor false @vt.on 'cursor:hide', => @rendererView.showCursor false
@hudView.on 'play-click', => @movie.togglePlay() if @options.hud
@hudView.on 'seek-click', (percent) => @movie.seek(percent) @hudView.on 'play-click', => @movie.togglePlay()
@hudView.on 'seek-click', (percent) => @movie.seek(percent)
if @options.benchmark if @options.benchmark
@movie.on 'started', => @movie.on 'started', =>

@ -4,6 +4,7 @@ module AsciicastsHelper
speed = (options[:speed] || 1).to_f speed = (options[:speed] || 1).to_f
benchmark = !!params[:bm] benchmark = !!params[:bm]
auto_play = options.key?(:auto_play) ? !!options[:auto_play] : false auto_play = options.key?(:auto_play) ? !!options[:auto_play] : false
hud = options.key?(:hud) ? !!options[:hud] : true
if custom_renderer = params[:renderer] if custom_renderer = params[:renderer]
renderer_class = "AsciiIo.Renderer.#{custom_renderer.capitalize}" renderer_class = "AsciiIo.Renderer.#{custom_renderer.capitalize}"
@ -23,6 +24,7 @@ module AsciicastsHelper
model: new AsciiIo.Asciicast({ id: #{asciicast.id} }), model: new AsciiIo.Asciicast({ id: #{asciicast.id} }),
rendererClass: #{renderer_class}, rendererClass: #{renderer_class},
autoPlay: #{auto_play}, autoPlay: #{auto_play},
hud: #{hud},
snapshot: "#{j asciicast.snapshot.to_s}" snapshot: "#{j asciicast.snapshot.to_s}"
}); });
}); });

@ -1,2 +1,5 @@
<div class="player"></div> <div class="player"></div>
<%= player_script(asciicast, :speed => local_assigns[:speed]) %> <%= player_script(asciicast,
:speed => local_assigns[:speed],
:hud => local_assigns[:hud]
) %>

@ -2,7 +2,8 @@
<div class="asciicast-wrapper"> <div class="asciicast-wrapper">
<%= render :partial => 'asciicasts/player', :locals => { <%= render :partial => 'asciicasts/player', :locals => {
:asciicast => @asciicast, :asciicast => @asciicast,
:speed => params[:speed] :speed => params[:speed],
:hud => true
} %> } %>
</div> </div>

@ -20,7 +20,8 @@
<% if @asciicast -%> <% if @asciicast -%>
<%= render :partial => 'asciicasts/player', :locals => { <%= render :partial => 'asciicasts/player', :locals => {
:asciicast => @asciicast, :asciicast => @asciicast,
:speed => 2.0 :speed => 2.0,
:hud => false
} %> } %>
<% end -%> <% end -%>
</div> </div>

Loading…
Cancel
Save