Revert "Fullscreen from iframe (#1236)" (#1247)

This reverts commit 19cdc15aa314760446866a1bcc2db99a80479683.
pull/36/head
Samuel Mannehed 6 years ago committed by Lauri Kasanen
parent 4c635f65d3
commit e2d86788ba

@ -1537,67 +1537,28 @@ const UI = {
* ------v------*/ * ------v------*/
toggleFullscreen() { toggleFullscreen() {
// Determine the document using fullscreen. This may either be if (document.fullscreenElement || // alternative standard method
// just the "document", but if using the viewer in an iframe, you need document.mozFullScreenElement || // currently working methods
// to use the parent window's "document" instead. document.webkitFullscreenElement ||
let doc = document; document.msFullscreenElement) {
if (window.self !== window.top) { if (document.exitFullscreen) {
doc = window.parent.document; document.exitFullscreen();
} } else if (document.mozCancelFullScreen) {
// Check the fullscreen status using the correct document as document.mozCancelFullScreen();
// a reference. The same document is then used to exit fullscreen. } else if (document.webkitExitFullscreen) {
if (doc.fullscreenElement || // alternative standard method document.webkitExitFullscreen();
doc.mozFullScreenElement || // currently working methods } else if (document.msExitFullscreen) {
doc.webkitFullscreenElement || document.msExitFullscreen();
doc.msFullscreenElement) {
if (doc.exitFullscreen) {
doc.exitFullscreen();
} else if (doc.mozCancelFullScreen) {
doc.mozCancelFullScreen();
} else if (doc.webkitExitFullscreen) {
doc.webkitExitFullscreen();
} else if (doc.msExitFullscreen) {
doc.msExitFullscreen();
} }
} else { } else {
// To activate fullscreen, we need to find the correct document if (document.documentElement.requestFullscreen) {
// element, which is usually "document.documentElement". But when document.documentElement.requestFullscreen();
// using the viewer in an iframe, this is actually the iframe } else if (document.documentElement.mozRequestFullScreen) {
// element itself in the parent document. document.documentElement.mozRequestFullScreen();
let doc_el = document.documentElement; } else if (document.documentElement.webkitRequestFullscreen) {
if (window.self !== window.top) { document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
// Seek out the correct iframe from the parent document. } else if (document.body.msRequestFullscreen) {
let iframes = window.parent.document document.body.msRequestFullscreen();
.getElementsByTagName('iframe');
for (let i in iframes) {
let content_doc = null;
try {
content_doc = iframes[i].contentDocument;
} catch (err) {
// I may not be permitted to read the contentDocument
// of the iframe, but then it can't be me, so ignore.
}
if (content_doc === document) {
doc_el = iframes[i];
// To use .body.msRequestFullscreen in IE, we need to
// set the document element accordingly.
// Note that the <iframe> must have the attribute
// "allowfullscreen" set for IE to allow the feature.
doc = iframes[i].contentDocument;
break;
}
}
}
// Activate fullscreen. All except MS use the document element for
// this. The behaviour of body.msRequestFullscreen is untested.
if (doc_el.requestFullscreen) {
doc_el.requestFullscreen();
} else if (doc_el.mozRequestFullScreen) {
doc_el.mozRequestFullScreen();
} else if (doc_el.webkitRequestFullscreen) {
doc_el.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (doc.body.msRequestFullscreen) {
doc.body.msRequestFullscreen();
} }
} }
UI.updateFullscreenButton(); UI.updateFullscreenButton();

Loading…
Cancel
Save