From b3f7a9395cc575cedbd345e38977a40407e9b6bc Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 26 Nov 2016 15:23:16 -0800 Subject: [PATCH] Size embedded Tweets correctly. #1021 --- src/Linkification/Embedding.coffee | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index 2ef669517..b24f25862 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -363,9 +363,18 @@ Embedding = , key: 'Twitter' regExp: /^\w+:\/\/(?:www\.)?twitter\.com\/(\w+\/status\/\d+)/ + style: 'border: none; width: 550px; height: 250px;' el: (a) -> - $.el 'iframe', - src: "https://twitframe.com/show?url=https://twitter.com/#{a.dataset.uid}" + el = $.el 'iframe' + $.on el, 'load', -> + @contentWindow.postMessage {element: 't', query: 'height'}, 'https://twitframe.com' + onMessage = (e) -> + if e.source is el.contentWindow and e.origin is 'https://twitframe.com' + $.off window, 'message', onMessage + el.style.height = "#{+e.data.height}px" + $.on window, 'message', onMessage + el.src = "https://twitframe.com/show?url=https://twitter.com/#{a.dataset.uid}" + el , key: 'Vimeo' regExp: /^\w+:\/\/(?:www\.)?vimeo\.com\/(\d+)/