Merge branch 'master' of github.com:torchbox/wagtail

This commit is contained in:
Matt Westcott 2014-03-28 14:27:16 +00:00
commit 20da2468d2
4 changed files with 25 additions and 15 deletions

View file

@ -1,4 +1,4 @@
/* No jQuery to speed up loading */
"use strict";
document.addEventListener('DOMContentLoaded', function(){
var body = document.querySelectorAll('body')[0];
var nav = document.querySelectorAll('nav')[0];

View file

@ -1,19 +1,25 @@
(function(w,d){
var l, f, h, frame_height;
"use strict";
var l, f, t, frame_height;
function callback(e){
var h;
if(e.origin !== w.wagtail.userbar.origin){return;};
// Get the height from the passed data.
try{
h = Number(e.data.replace( /.*fh=(\d+)(?:&|$)/, '$1' ) );
if (!isNaN( h ) && h > 0 && h !== frame_height) {
f.style.opacity = 1;
f.style.height = h + "px";
}
} catch(e){}
}
if(!w.wagtail) return;
if(w.postMessage){
function callback(e){
f.style.opacity=1;
// Get the height from the passed data.
var h = Number(e.data.replace( /.*fh=(\d+)(?:&|$)/, '$1' ) );
if (!isNaN( h ) && h > 0 && h !== frame_height) {
f.style.height = h + "px";
}
}
if (w.addEventListener) {
w.addEventListener('message', callback, false);
} else {
@ -25,12 +31,12 @@
l.rel = 'stylesheet';
l.href = w.wagtail.static_root + 'scss/userbar_embed.css';
f = d.createElement('iframe');
f = d.createElement('iframe');
f.id = 'wagtail-userbar';
f.frameborder = '0';
f.allowtransparency = 'true';
f.scrolling = 'no';
f.src = w.wagtail.userbar_src;
f.src = w.wagtail.userbar.src;
// if postMessage is supported, hide iframe till it is loaded
if(w.postMessage){

View file

@ -3,7 +3,10 @@
<script type="text/javascript">
var wagtail = wagtail || {};
wagtail.static_root = '{% static "wagtailadmin/" %}';
wagtail.userbar_src = '{% if revision_id %}{% url "wagtailadmin_userbar_moderation" revision_id %}{% else %}{% url "wagtailadmin_userbar_frontend" page.self.id %}{% endif %}';
wagtail.userbar = {
src: '{% if revision_id %}{% url "wagtailadmin_userbar_moderation" revision_id %}{% else %}{% url "wagtailadmin_userbar_frontend" page.self.id %}{% endif %}',
origin:'{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}'
};
(function(d) {
var u = d.createElement('script'); u.type = 'text/javascript'; u.async = true;
u.src = '{% static "wagtailadmin/js/userbar_embed.js" %}';

View file

@ -18,6 +18,7 @@ def render_edit_frame(request, context):
# Render the frame to contain the userbar items
return render_to_string('wagtailadmin/userbar/frame.html', {
'request': request,
'page': context,
'revision_id': revision_id
})