aboutsummaryrefslogtreecommitdiff
path: root/priv/static/embed.js
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-06-30 15:09:03 -0500
committerMark Felder <feld@FreeBSD.org>2020-06-30 15:09:03 -0500
commit0883a706dc376fdfb7de9df1366803e87c8e7c98 (patch)
treedc43f7b09dddd3300efd7b3ebbc0e82e60a978c5 /priv/static/embed.js
parent954acdda2072cac343409b3d17d831b86ac6a18c (diff)
parentb9e6ad571ac5925431466d6e6b27c0b372bb7727 (diff)
downloadpleroma-0883a706dc376fdfb7de9df1366803e87c8e7c98.tar.gz
Merge branch 'develop' into activation-meta
Diffstat (limited to 'priv/static/embed.js')
-rw-r--r--priv/static/embed.js43
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()
+ })
+ })
+})()