diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-06-02 18:50:37 +0400 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-06-02 18:50:37 +0400 |
commit | 68cb152a0861618035ac48a0e0b455f74d9b767c (patch) | |
tree | cb2f14ed088efa0ab5b6952ee7d74d69f524387a /priv/static/embed.js | |
parent | cbcd592300673582e38d0bf539dcdb9a2c1985a1 (diff) | |
parent | 879304dcd94c778b3cdaa2b82f69fccf2b37090c (diff) | |
download | pleroma-68cb152a0861618035ac48a0e0b455f74d9b767c.tar.gz pleroma-68cb152a0861618035ac48a0e0b455f74d9b767c.zip |
Merge branch 'develop' into openapi/admin/relay
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() + }) + }) +})() |