mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-12 02:50:59 +00:00
Merge branch 'master' of github.com:torchbox/wagtail
This commit is contained in:
commit
20da2468d2
4 changed files with 25 additions and 15 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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" %}';
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue