about summary refs log tree commit diff
path: root/public
diff options
context:
space:
mode:
authorbeatrix <beatrix.bitrot@gmail.com>2017-09-10 13:34:14 -0400
committerGitHub <noreply@github.com>2017-09-10 13:34:14 -0400
commitc9df53044a333276853f7dc7ef2aed6d48df087f (patch)
tree011ea44fc94bcff6f8ec4e23c3edf887359243d2 /public
parent3dff74eecf5387b92b862893248710d2efb90eec (diff)
parent67ad4533732f2e5cfc8c7f7ad3abaf7a5eb2647b (diff)
Merge pull request #142 from glitch-soc/sync/upstream-1.6.0rc4
Merge with 1.6.0rc4

STRAP IN BUCKAWOO HERE WE GO AGAIN
Diffstat (limited to 'public')
-rw-r--r--public/embed.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/public/embed.js b/public/embed.js
new file mode 100644
index 000000000..dac507453
--- /dev/null
+++ b/public/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 !== 'setHeight' || !iframes[data.id]) {
+        return;
+      }
+
+      iframes[data.id].height = data.height;
+    });
+
+    [].forEach.call(document.querySelectorAll('iframe.mastodon-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: 'setHeight',
+          id: id,
+        }, '*');
+      };
+
+      iframe.onload();
+    });
+  });
+})();