mirror of
https://github.com/discourse/discourse.git
synced 2025-09-08 12:06:51 +08:00
Move embed.js to public
This commit is contained in:
parent
df220ae973
commit
5621a64579
1 changed files with 0 additions and 0 deletions
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);
|
||||
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue