~cytrogen/masto-fe

ref: 496fd5987ecb67ac51888fde30b7fb76cf829edf masto-fe/app/javascript/core/embed.js -rw-r--r-- 607 bytes
496fd598 — Zoë Bijl [bugfix] correct import of `@rails/ujs` / fix lint issues (#92) 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//  This file will be loaded on embed pages, regardless of theme.

import 'packs/public-path';

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);
  }
});