aboutsummaryrefslogtreecommitdiff
path: root/priv/static/embed.js
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-06-25 14:16:28 -0500
committerMark Felder <feld@FreeBSD.org>2020-06-25 14:26:21 -0500
commit433c01b370f4bf68d3f016d86c1527b1319e7a0c (patch)
tree607d6c7e4e578d6e0ff95963b5565baefc207d85 /priv/static/embed.js
parentd4b20c96c4030ebb5eb908dc6efcf45be7a8355d (diff)
parent1d0804b49f56fe722b12f83269d98acfdee7ac77 (diff)
downloadpleroma-433c01b370f4bf68d3f016d86c1527b1319e7a0c.tar.gz
Merge branch 'develop' into refactor/notification_settings
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()
+ })
+ })
+})()