mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Move embed.js to public
This commit is contained in:
27
public/javascripts/embed.js
Normal file
27
public/javascripts/embed.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/* global discourseUrl */
|
||||
/* global discourseEmbedUrl */
|
||||
(function() {
|
||||
|
||||
var comments = document.getElementById('discourse-comments'),
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.src = discourseUrl + "embed/best?embed_url=" + encodeURIComponent(discourseEmbedUrl);
|
||||
iframe.id = 'discourse-embed-frame';
|
||||
iframe.width = "100%";
|
||||
iframe.frameBorder = "0";
|
||||
iframe.scrolling = "no";
|
||||
comments.appendChild(iframe);
|
||||
|
||||
|
||||
function postMessageReceived(e) {
|
||||
if (!e) { return; }
|
||||
if (discourseUrl.indexOf(e.origin) === -1) { return; }
|
||||
|
||||
if (e.data) {
|
||||
if (e.data.type === 'discourse-resize' && e.data.height) {
|
||||
iframe.height = e.data.height + "px";
|
||||
}
|
||||
}
|
||||
}
|
||||
window.addEventListener('message', postMessageReceived, false);
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user