Merge branch 'admin_fe_dont_list_mrf_policies_any_more' into 'develop'
[akkoma] / priv / static / embed.js
1 (function () {
2 'use strict'
3
4 var ready = function (loaded) {
5 if (['interactive', 'complete'].indexOf(document.readyState) !== -1) {
6 loaded()
7 } else {
8 document.addEventListener('DOMContentLoaded', loaded)
9 }
10 }
11
12 ready(function () {
13 var iframes = []
14
15 window.addEventListener('message', function (e) {
16 var data = e.data || {}
17
18 if (data.type !== 'setHeightPleromaEmbed' || !iframes[data.id]) {
19 return
20 }
21
22 iframes[data.id].height = data.height
23 });
24
25 [].forEach.call(document.querySelectorAll('iframe.pleroma-embed'), function (iframe) {
26 iframe.scrolling = 'no'
27 iframe.style.overflow = 'hidden'
28
29 iframes.push(iframe)
30
31 var id = iframes.length - 1
32
33 iframe.onload = function () {
34 iframe.contentWindow.postMessage({
35 type: 'setHeightPleromaEmbed',
36 id: id
37 }, '*')
38 }
39
40 iframe.onload()
41 })
42 })
43 })()