diff options
author | lain <lain@soykaf.club> | 2020-06-02 14:04:34 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-02 14:04:34 +0000 |
commit | 2860c66e88df6746b5ede2cfecf2392abf004fd2 (patch) | |
tree | 4eaba88349782c6b3e50afefd1d82224d8f9c96f /priv/static/embed.js | |
parent | cd2abcc0e3a67898fbadd073ff778e7342c09709 (diff) | |
parent | 6b84c62d4a51cb17192945d1b67999b2c56a23d2 (diff) | |
download | pleroma-2860c66e88df6746b5ede2cfecf2392abf004fd2.tar.gz |
Merge branch 'feature/embeddable-posts' into 'develop'
Add embeddable posts
Closes #1288
See merge request pleroma/pleroma!2319
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() + }) + }) +})() |