diff --git a/app/assets/javascripts/player/player_view.js.coffee b/app/assets/javascripts/player/player_view.js.coffee index c9735ba..6edf6e0 100644 --- a/app/assets/javascripts/player/player_view.js.coffee +++ b/app/assets/javascripts/player/player_view.js.coffee @@ -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() - @movie.on 'paused', => @hudView.onPause() - @movie.on 'resumed', => @hudView.onResume() - @movie.on 'time', (time) => @hudView.updateTime(time) + + 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,8 +97,9 @@ class AsciiIo.PlayerView extends Backbone.View @vt.on 'cursor:show', => @rendererView.showCursor true @vt.on 'cursor:hide', => @rendererView.showCursor false - @hudView.on 'play-click', => @movie.togglePlay() - @hudView.on 'seek-click', (percent) => @movie.seek(percent) + if @options.hud + @hudView.on 'play-click', => @movie.togglePlay() + @hudView.on 'seek-click', (percent) => @movie.seek(percent) if @options.benchmark @movie.on 'started', => diff --git a/app/helpers/asciicasts_helper.rb b/app/helpers/asciicasts_helper.rb index 0e2dad8..122d710 100644 --- a/app/helpers/asciicasts_helper.rb +++ b/app/helpers/asciicasts_helper.rb @@ -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}" }); }); diff --git a/app/views/asciicasts/_player.html.erb b/app/views/asciicasts/_player.html.erb index 3230b84..5a15295 100644 --- a/app/views/asciicasts/_player.html.erb +++ b/app/views/asciicasts/_player.html.erb @@ -1,2 +1,5 @@
-<%= player_script(asciicast, :speed => local_assigns[:speed]) %> +<%= player_script(asciicast, + :speed => local_assigns[:speed], + :hud => local_assigns[:hud] +) %> diff --git a/app/views/asciicasts/show.html.erb b/app/views/asciicasts/show.html.erb index 4e6f918..1401315 100644 --- a/app/views/asciicasts/show.html.erb +++ b/app/views/asciicasts/show.html.erb @@ -2,7 +2,8 @@