kopia lustrzana https://github.com/wagtail/wagtail
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.pull/2616/merge
rodzic
83a11ecee4
commit
b1c6063b41
|
@ -452,13 +452,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) {
|
||||
|
@ -481,13 +486,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 {
|
||||
|
|
Ładowanie…
Reference in New Issue