about summary refs log tree commit diff
path: root/public
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-09-09 23:56:21 -0500
committerDavid Yip <yipdw@member.fsf.org>2017-09-09 23:56:21 -0500
commit67ad4533732f2e5cfc8c7f7ad3abaf7a5eb2647b (patch)
tree011ea44fc94bcff6f8ec4e23c3edf887359243d2 /public
parent3dff74eecf5387b92b862893248710d2efb90eec (diff)
parent90712d42933efd9978e4bbae82f81a4650aa4d84 (diff)
Merge tag 'v1.6.0rc4' into sync/upstream-1.6.0rc4
Conflicts:
      app/javascript/mastodon/features/getting_started/index.js
      app/javascript/packs/public.js
      app/javascript/styles/components.scss
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();
+    });
+  });
+})();