discourse/app/views/layouts/embed.html.erb

69 lines
1.9 KiB
Plaintext
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag 'embed' %>
<%- unless customization_disabled? %>
<%= SiteCustomization.custom_stylesheet(session[:preview_style], :embedded) %>
<%- end %>
<%= javascript_include_tag 'break_string' %>
<script>
(function() {
function postUp(msg) {
if (parent) {
parent.postMessage(msg, '<%= request.referer %>');
}
}
function clickPostLink(e) {
var postId = e.target.getAttribute('data-link-to-post');
if (postId) {
var postElement = document.getElementById('post-' + postId);
if (postElement) {
var rect = postElement.getBoundingClientRect();
if (rect && rect.top) {
postUp({type: 'discourse-scroll', top: rect.top});
e.preventDefault();
return false;
}
}
}
}
window.onload = function() {
// Send a post message with our loaded height
postUp({type: 'discourse-resize', height: document['body'].offsetHeight});
var postLinks = document.querySelectorAll("a[data-link-to-post]"),
i;
for (i=0; i<postLinks.length; i++) {
postLinks[i].onclick = clickPostLink;
}
// Make sure all links in the iframe point to _blank
var cookedLinks = document.querySelectorAll('.cooked a');
for (i=0; i<cookedLinks.length; i++) {
cookedLinks[i].target = "_blank";
}
// Adjust all names
var names = document.querySelectorAll('.username a');
for (i=0; i<names.length; i++) {
var username = names[i].innerHTML;
if (username) {
names[i].innerHTML = new BreakString(username).break();
}
}
};
})();
</script>
</head>
<body>
<%= yield %>
</body>
</html>