mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 09:13:14 +00:00
tweaks for firefox
This commit is contained in:
parent
8e3c9e9721
commit
67f2db1e61
2 changed files with 40 additions and 15 deletions
|
|
@ -340,31 +340,55 @@ $(function() {
|
|||
});
|
||||
|
||||
/* Set up behaviour of preview button */
|
||||
var previewWindow = null;
|
||||
var previewOnloadRun = false;
|
||||
|
||||
$('.action-preview').click(function(e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
|
||||
var previewWindow = window.open($this.data('placeholder'), $this.data('windowname'));
|
||||
|
||||
if(!previewWindow || previewWindow.closed){
|
||||
previewOnloadRun = false;
|
||||
previewWindow = window.open($this.data('placeholder'), $this.data('windowname'));
|
||||
}
|
||||
|
||||
if(/MSIE/.test(navigator.userAgent)){
|
||||
// If IE, load contents immediately without fancy effects
|
||||
submitPreview.call($this, false);
|
||||
} else {
|
||||
previewWindow.onload = function(){
|
||||
// If not IE, check if the onload has already fired
|
||||
if(!previewOnloadRun){
|
||||
// This only runs once per new window creation
|
||||
previewWindow.onload = function(){
|
||||
previewOnloadRun = true;
|
||||
submitPreview.call($this, true);
|
||||
}
|
||||
}else{
|
||||
submitPreview.call($this, true);
|
||||
}
|
||||
}
|
||||
|
||||
function submitPreview(enhanced){
|
||||
var previewDoc = previewWindow.document;
|
||||
|
||||
// If onload already fired, make window appear like it's loading the content again
|
||||
var spinner = previewDoc.getElementById('loading-spinner-wrapper');
|
||||
previewWindow.focus();
|
||||
|
||||
if(spinner){
|
||||
spinner.className = spinner.className.replace('remove','');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: $this.data('action'),
|
||||
data: $('#page-edit-form').serialize(),
|
||||
success: function(data, textStatus, request) {
|
||||
if (request.getResponseHeader('X-Wagtail-Preview') == 'ok') {
|
||||
var pdoc = previewWindow.document;
|
||||
|
||||
if(enhanced){
|
||||
var frame = pdoc.getElementById('preview-frame');
|
||||
var frame = previewDoc.getElementById('preview-frame');
|
||||
|
||||
frame = frame.contentWindow || frame.contentDocument.document || frame.contentDocument;
|
||||
frame.document.open();
|
||||
|
|
@ -372,14 +396,15 @@ $(function() {
|
|||
frame.document.close();
|
||||
|
||||
var hideTimeout = setTimeout(function(){
|
||||
pdoc.getElementById('loading-spinner-wrapper').className += 'remove';
|
||||
spinner.className += ' remove';
|
||||
clearTimeout(hideTimeout);
|
||||
}) // just enough to give effect without adding discernible slowness
|
||||
} else {
|
||||
pdoc.open();
|
||||
pdoc.write(data);
|
||||
pdoc.close()
|
||||
previewDoc.open();
|
||||
previewDoc.write(data);
|
||||
previewDoc.close()
|
||||
}
|
||||
|
||||
} else {
|
||||
previewWindow.close();
|
||||
document.open();
|
||||
|
|
@ -394,9 +419,9 @@ $(function() {
|
|||
developers can debug template errors. (On a production site, we'd
|
||||
typically be serving a friendly custom 500 page anyhow.) */
|
||||
|
||||
previewWindow.document.open();
|
||||
previewWindow.document.write(xhr.responseText);
|
||||
previewWindow.document.close();
|
||||
previewDoc.open();
|
||||
previewDoc.write(xhr.responseText);
|
||||
previewDoc.close();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ html,body {
|
|||
font-size:0em;
|
||||
z-index:999999;
|
||||
background:white;
|
||||
@include transition(all 0.3s ease);
|
||||
|
||||
|
||||
&.remove{
|
||||
@include transition(all 0.3s ease);
|
||||
bottom:-100%;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue