diff --git a/app/assets/javascripts/embed.js b/app/assets/javascripts/embed.js index 69db0eb..00d3f70 100644 --- a/app/assets/javascripts/embed.js +++ b/app/assets/javascripts/embed.js @@ -1,2 +1,3 @@ -//= require base +//= require es5-shim.min +//= require console-shim-min //= require asciinema-player diff --git a/app/helpers/asciicasts_helper.rb b/app/helpers/asciicasts_helper.rb index 70892bf..1c39921 100644 --- a/app/helpers/asciicasts_helper.rb +++ b/app/helpers/asciicasts_helper.rb @@ -9,6 +9,7 @@ module AsciicastsHelper def player_tag(asciicast, options, skip_titlebar) opts = { + id: 'player', src: asciicast.url, cols: asciicast.width, rows: asciicast.height, diff --git a/app/views/api/asciicasts/show.html.slim b/app/views/api/asciicasts/show.html.slim index 0df2e78..8918e04 100644 --- a/app/views/api/asciicasts/show.html.slim +++ b/app/views/api/asciicasts/show.html.slim @@ -4,18 +4,21 @@ p.powered a href=root_url target="_top" asciinema javascript: - $(function() { + + var player = document.getElementById('player'); + + player.addEventListener('attached', function() { var target = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined); if (typeof target != "undefined" && window !== window.parent) { - var w = $('.asciinema-player').width(); - var h = $(document).height(); + var w = player.getElementsByClassName('asciinema-player')[0].offsetWidth; + var h = Math.max(document.body.scrollHeight, document.body.offsetHeight); target.postMessage(['asciicast:size', { width: w, height: h }], '*'); } function onMessage(e) { var event = e.data[0]; if (event == 'asciicast:play') { - $('.start-prompt').click(); + // player.play(); // TODO } }