Fix the size of the embed widget when embedding public recording via private URL

element
Marcin Kulik 9 years ago
parent fa12e1fcf2
commit 466a21a7e8

@ -70,9 +70,11 @@
function receiveSize(e) {
if (e.origin === apiHost) {
var event = e.data[0];
var name = e.data[0];
var data = e.data[1];
if (event == 'asciicast:size' && data.id == asciicastId) {
var iframeWindow = iframe.contentWindow || iframe;
if (e.source == iframeWindow && name == 'asciicast:size') {
iframe.style.width = '' + data.width + 'px';
iframe.style.height = '' + data.height + 'px';
}

@ -17,8 +17,4 @@ class BareAsciicastPagePresenter
@playback_options = playback_options
end
def asciicast_id
asciicast.to_param
end
end

@ -9,7 +9,7 @@ javascript:
if (typeof target != "undefined" && window !== window.parent) {
var w = $('.asciinema-player').width();
var h = $(document).height();
target.postMessage(['asciicast:size', { id: '#{page.asciicast_id}', width: w, height: h }], '*');
target.postMessage(['asciicast:size', { width: w, height: h }], '*');
}
function onMessage(e) {

@ -10,7 +10,7 @@ p
p
' And now again. There should be an embedded player below this paragraph.
= embed_script(@asciicast).html_safe
= embed_script(Asciicast.where('id <> ?', @asciicast.id).first || @asciicast).html_safe
p
' This is at the bottom of the page, below all players.

@ -19,13 +19,4 @@ describe BareAsciicastPagePresenter do
end
end
let(:presenter) { described_class.new(asciicast, nil) }
let(:asciicast) { stub_model(Asciicast, id: 123) }
describe '#asciicast_id' do
subject { presenter.asciicast_id }
it { should eq('123') }
end
end

Loading…
Cancel
Save