summaryrefslogtreecommitdiff
path: root/priv/static/embed.js
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2020-06-08 19:21:07 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2020-06-08 19:21:07 +0300
commit604a83ae3efe21b231fb524203a883a062102546 (patch)
tree610d04900503ec700fe7307fb73fd90bb5865009 /priv/static/embed.js
parent1be6b3056e97654612f377eaf3c8d80de6d8d77f (diff)
parentd1924926585a477682b8fcc3176521dacb0766dd (diff)
downloadpleroma-604a83ae3efe21b231fb524203a883a062102546.tar.gz
pleroma-604a83ae3efe21b231fb524203a883a062102546.zip
merge develop
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()
+ })
+ })
+})()