Pass the asciicast with the options object to player partial

openid
Marcin Kulik 11 years ago
parent a9913a966d
commit 0e85e9ac28

@ -1,17 +1,8 @@
module AsciicastsHelper module AsciicastsHelper
def player(asciicast, options = PlaybackOptions.new) def player(asciicast, options = PlaybackOptions.new)
render :partial => 'asciicasts/player', :locals => { render 'asciicasts/player', asciicast: serialized_asciicast(asciicast),
asciicast: serialized_asciicast(asciicast), options: options
player_class: options.player_class,
speed: options.speed,
benchmark: options.benchmark,
container_width: options.max_width,
renderer_class: options.renderer_class,
auto_play: options.autoplay,
hud: !options.hide_hud,
size: options.size,
}
end end
# TODO: move to AsciicastDecorator # TODO: move to AsciicastDecorator

@ -1,18 +1,18 @@
.player class="#{size}-font" .player class="#{options.size}-font"
javascript: javascript:
$(function() { $(function() {
var playerClass = #{player_class}; var playerClass = #{options.player_class};
var containerWidth = #{container_width || 'null'}; var containerWidth = #{options.max_width || 'null'};
window.player = new playerClass({ window.player = new playerClass({
el: $('.player'), el: $('.player'),
speed: #{speed}, speed: #{options.speed},
benchmark: #{benchmark}, benchmark: #{options.benchmark},
model: new Asciinema.Asciicast(#{asciicast.html_safe}), model: new Asciinema.Asciicast(#{asciicast.html_safe}),
containerWidth: containerWidth || $('.cinema .player').parent().width(), containerWidth: containerWidth || $('.cinema .player').parent().width(),
rendererClass: #{renderer_class}, rendererClass: #{options.renderer_class},
autoPlay: #{auto_play}, autoPlay: #{options.autoplay},
hud: #{hud} hud: #{!options.hide_hud}
}); });
}); });

Loading…
Cancel
Save