diff options
author | David Yip <yipdw@member.fsf.org> | 2017-09-09 23:56:21 -0500 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-09-09 23:56:21 -0500 |
commit | 67ad4533732f2e5cfc8c7f7ad3abaf7a5eb2647b (patch) | |
tree | 011ea44fc94bcff6f8ec4e23c3edf887359243d2 /public | |
parent | 3dff74eecf5387b92b862893248710d2efb90eec (diff) | |
parent | 90712d42933efd9978e4bbae82f81a4650aa4d84 (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.js | 43 |
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(); + }); + }); +})(); |