about summary refs log tree commit diff
path: root/app/javascript/core/embed.js
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-11-18 15:12:52 -0800
committerkibigo! <marrus-sh@users.noreply.github.com>2017-11-18 15:12:52 -0800
commita9ed85717163040fb202d49b0342e9e350cb12ba (patch)
tree542142fa2ed7c1ff5584671c9a678f4b64edc15c /app/javascript/core/embed.js
parent92cc79be7206534e8c9a9957cc89b5d0eb0bcfac (diff)
WIP static themeing
Diffstat (limited to 'app/javascript/core/embed.js')
-rw-r--r--app/javascript/core/embed.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/javascript/core/embed.js b/app/javascript/core/embed.js
new file mode 100644
index 000000000..8167706a3
--- /dev/null
+++ b/app/javascript/core/embed.js
@@ -0,0 +1,23 @@
+//  This file will be loaded on embed pages, regardless of theme.
+
+window.addEventListener('message', e => {
+  const data = e.data || {};
+
+  if (!window.parent || data.type !== 'setHeight') {
+    return;
+  }
+
+  function setEmbedHeight () {
+    window.parent.postMessage({
+      type: 'setHeight',
+      id: data.id,
+      height: document.getElementsByTagName('html')[0].scrollHeight,
+    }, '*');
+  });
+
+  if (['interactive', 'complete'].includes(document.readyState)) {
+    setEmbedHeight();
+  } else {
+    document.addEventListener('DOMContentLoaded', setEmbedHeight);
+  }
+});