diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-06-04 13:28:00 +0400 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-06-04 13:28:00 +0400 |
commit | b4d5bdd6f1c473280b8b9bbad96e9efecb45b298 (patch) | |
tree | 6d08f332f7bd1bc20f7bd3904987850173f90af0 /priv/static/embed.js | |
parent | 06f20e918129b1f434783b64d59b5ae6b4b4ed51 (diff) | |
parent | d6693a91028ab3ee7865f530f3ad2532542fc2d2 (diff) | |
download | pleroma-b4d5bdd6f1c473280b8b9bbad96e9efecb45b298.tar.gz pleroma-b4d5bdd6f1c473280b8b9bbad96e9efecb45b298.zip |
Merge branch 'develop' into openapi/admin/config
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() + }) + }) +})() |