diff options
author | lain <lain@soykaf.club> | 2020-06-05 16:53:56 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-05 16:53:56 +0200 |
commit | a8ca030d85368285af1b960e14dab5b847ecb35a (patch) | |
tree | 5d8c8922eea940f455946435c073d534df1dec57 /priv/static/embed.js | |
parent | 115d08a7542b92c5e1d889da41c0ee6837a1235e (diff) | |
parent | 657e1583f8af1ecdf218ba283de4234233bfe5fd (diff) | |
download | pleroma-a8ca030d85368285af1b960e14dab5b847ecb35a.tar.gz pleroma-a8ca030d85368285af1b960e14dab5b847ecb35a.zip |
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
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() + }) + }) +})() |