mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-21 05:21:54 +00:00
Make preview window work on IE11
IE doesn't provide standard onload event listeners on opened windows, so this code did user-agent sniffing on the string 'MSIE' to bypass the onload animation. This failed on IE11, which drops 'MSIE' from the user agent string. The code now checks for the presence of addEventListener instead. As a bonus, it now falls back on IE's (non-standard?) attachEvent method, so the animation now works on IE after all.
This commit is contained in:
parent
6081ab5480
commit
4ee93914ce
1 changed files with 13 additions and 8 deletions
|
|
@ -416,13 +416,18 @@ $(function() {
|
|||
|
||||
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 (previewWindow.addEventListener) {
|
||||
previewWindow.addEventListener('load', function() {
|
||||
submitPreview.call($this, true);
|
||||
}
|
||||
}, false);
|
||||
} else if (previewWindow.attachEvent) {
|
||||
// for IE
|
||||
previewWindow.attachEvent('onload', function() {
|
||||
submitPreview.call($this, true);
|
||||
}, false);
|
||||
} else {
|
||||
// Can't trap onload event, so load contents immediately without fancy effects
|
||||
submitPreview.call($this, false);
|
||||
}
|
||||
|
||||
function submitPreview(enhanced) {
|
||||
|
|
@ -445,13 +450,13 @@ $(function() {
|
|||
var hideTimeout = setTimeout(function() {
|
||||
previewDoc.getElementById('loading-spinner-wrapper').className += ' remove';
|
||||
clearTimeout(hideTimeout);
|
||||
})
|
||||
});
|
||||
|
||||
// just enough to give effect without adding discernible slowness
|
||||
} else {
|
||||
previewDoc.open();
|
||||
previewDoc.write(data);
|
||||
previewDoc.close()
|
||||
previewDoc.close();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue