diff options
author | Mark Felder <feld@FreeBSD.org> | 2020-06-04 17:29:20 -0500 |
---|---|---|
committer | Mark Felder <feld@FreeBSD.org> | 2020-06-04 17:29:20 -0500 |
commit | 55825b46bef6e397778adc58276f634f2006a823 (patch) | |
tree | db1a310f77afaf0c4b1a93f87fa57aac10a79d7c /priv/static/embed.js | |
parent | 9d2c2a83a4f405ea36ef45144dcad972e2234a23 (diff) | |
parent | f5cb1f3616e9cb9430038697532eb49161937dec (diff) | |
download | pleroma-55825b46bef6e397778adc58276f634f2006a823.tar.gz |
Merge branch 'develop' into fix/mediaproxy-http-invalidation
Diffstat (limited to 'priv/static/embed.js')
-rw-r--r-- | priv/static/embed.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/priv/static/embed.js b/priv/static/embed.js new file mode 100644 index 000000000..f675f6417 --- /dev/null +++ b/priv/static/embed.js @@ -0,0 +1,43 @@ +(function () { + 'use strict' + + var ready = function (loaded) { + if (['interactive', 'complete'].indexOf(document.readyState) !== -1) { + loaded() + } else { + document.addEventListener('DOMContentLoaded', loaded) + } + } + + ready(function () { + var iframes = [] + + window.addEventListener('message', function (e) { + var data = e.data || {} + + if (data.type !== 'setHeightPleromaEmbed' || !iframes[data.id]) { + return + } + + iframes[data.id].height = data.height + }); + + [].forEach.call(document.querySelectorAll('iframe.pleroma-embed'), function (iframe) { + iframe.scrolling = 'no' + iframe.style.overflow = 'hidden' + + iframes.push(iframe) + + var id = iframes.length - 1 + + iframe.onload = function () { + iframe.contentWindow.postMessage({ + type: 'setHeightPleromaEmbed', + id: id + }, '*') + } + + iframe.onload() + }) + }) +})() |