summaryrefslogtreecommitdiff
path: root/priv/static/embed.js
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-07-02 16:36:54 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-07-02 16:36:54 +0300
commit61180ab6f4b85ab78de2eaf1bc1b974c9e7908af (patch)
tree0970691b2060e06b6feaf4e645021298a7efda0d /priv/static/embed.js
parent0e23138b50f1fdd9ea78df31eec1b3caac905e2c (diff)
parent4c044f62258b33a95b8281e1eb42a5e0ce47d42d (diff)
downloadpleroma-61180ab6f4b85ab78de2eaf1bc1b974c9e7908af.tar.gz
pleroma-61180ab6f4b85ab78de2eaf1bc1b974c9e7908af.zip
Merge remote-tracking branch 'remotes/origin/develop' into 2168-media-preview-proxy
# Conflicts: # config/config.exs # lib/pleroma/web/media_proxy/media_proxy.ex # lib/pleroma/web/media_proxy/media_proxy_controller.ex
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()
+ })
+ })
+})()