Option to disable HUD
This commit is contained in:
parent
4edd5ead9e
commit
b1ecbc16c0
@ -5,7 +5,7 @@ class AsciiIo.PlayerView extends Backbone.View
|
||||
initialize: (options) ->
|
||||
@prepareSelfView()
|
||||
@createRendererView()
|
||||
@createHudView()
|
||||
@createHudView() if options.hud
|
||||
@fetchModel()
|
||||
@showLoadingIndicator()
|
||||
|
||||
@ -24,7 +24,7 @@ class AsciiIo.PlayerView extends Backbone.View
|
||||
|
||||
createHudView: ->
|
||||
@hudView = new AsciiIo.HudView(cols: @options.cols)
|
||||
@$el.append(@hudView.$el)
|
||||
@$el.append @hudView.$el
|
||||
|
||||
fetchModel: ->
|
||||
@model.fetch success: => @onModelFetched()
|
||||
@ -53,7 +53,7 @@ class AsciiIo.PlayerView extends Backbone.View
|
||||
|
||||
onModelReady: ->
|
||||
@hideLoadingIndicator()
|
||||
@hudView.setDuration @model.get('duration')
|
||||
@hudView.setDuration @model.get('duration') if @options.hud
|
||||
@createMovie()
|
||||
@bindEvents()
|
||||
|
||||
@ -79,9 +79,12 @@ class AsciiIo.PlayerView extends Backbone.View
|
||||
@movie.on 'reset', => @vt.reset()
|
||||
@movie.on 'finished', => @vt.stopCursorBlink()
|
||||
@movie.on 'wakeup', => @vt.restartCursorBlink()
|
||||
|
||||
if @options.hud
|
||||
@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 'data', (data) =>
|
||||
@ -94,6 +97,7 @@ class AsciiIo.PlayerView extends Backbone.View
|
||||
@vt.on 'cursor:show', => @rendererView.showCursor true
|
||||
@vt.on 'cursor:hide', => @rendererView.showCursor false
|
||||
|
||||
if @options.hud
|
||||
@hudView.on 'play-click', => @movie.togglePlay()
|
||||
@hudView.on 'seek-click', (percent) => @movie.seek(percent)
|
||||
|
||||
|
@ -4,6 +4,7 @@ module AsciicastsHelper
|
||||
speed = (options[:speed] || 1).to_f
|
||||
benchmark = !!params[:bm]
|
||||
auto_play = options.key?(:auto_play) ? !!options[:auto_play] : false
|
||||
hud = options.key?(:hud) ? !!options[:hud] : true
|
||||
|
||||
if custom_renderer = params[:renderer]
|
||||
renderer_class = "AsciiIo.Renderer.#{custom_renderer.capitalize}"
|
||||
@ -23,6 +24,7 @@ module AsciicastsHelper
|
||||
model: new AsciiIo.Asciicast({ id: #{asciicast.id} }),
|
||||
rendererClass: #{renderer_class},
|
||||
autoPlay: #{auto_play},
|
||||
hud: #{hud},
|
||||
snapshot: "#{j asciicast.snapshot.to_s}"
|
||||
});
|
||||
});
|
||||
|
@ -1,2 +1,5 @@
|
||||
<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">
|
||||
<%= render :partial => 'asciicasts/player', :locals => {
|
||||
:asciicast => @asciicast,
|
||||
:speed => params[:speed]
|
||||
:speed => params[:speed],
|
||||
:hud => true
|
||||
} %>
|
||||
|
||||
</div>
|
||||
|
@ -20,7 +20,8 @@
|
||||
<% if @asciicast -%>
|
||||
<%= render :partial => 'asciicasts/player', :locals => {
|
||||
:asciicast => @asciicast,
|
||||
:speed => 2.0
|
||||
:speed => 2.0,
|
||||
:hud => false
|
||||
} %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user