From d9f858f1656a06e82100945d697a740c06f12dcd Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 21 Apr 2012 22:14:37 -0400 Subject: [PATCH] Added error handling for failed full screen attempt. --- src/js/pannellum.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index c0a6a6d..39e1f89 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -126,6 +126,9 @@ function init() { document.addEventListener('mozfullscreenchange',onFullScreenChange,false); document.addEventListener('webkitfullscreenchange',onFullScreenChange,false); document.addEventListener('fullscreenchange',onFullScreenChange,false); + document.addEventListener('mozfullscreenerror',fullScreenError,false); + document.addEventListener('webkitfullscreenerror',fullScreenError,false); + document.addEventListener('fullscreenerror',fullScreenError,false); window.addEventListener('resize',onDocumentResize,false); document.addEventListener('keydown',onDocumentKeyPress,false) @@ -293,20 +296,7 @@ function toggleFullWindow() { page.webkitRequestFullScreen(); } } catch(event) { - if(getURLParameter('popout') != 'yes') { - // open new window instead - var windowspecs = 'width=' + screen.width + ',height=' + screen.height + ',left=0,top=0'; - var windowlocation = window.location.href + '&popout=yes'; - try { - camera.aspect = window.innerWidth / window.innerHeight; - windowlocation += '&popoutautoload=yes'; - } catch(event) { - // panorama not loaded - } - window.open(windowlocation,null,windowspecs) - } else { - window.close(); - } + fullScreenError(); } } else { if (document.exitFullscreen) { @@ -334,6 +324,23 @@ function onFullScreenChange() { } } +function fullScreenError() { + if(getURLParameter('popout') != 'yes') { + // open new window instead + var windowspecs = 'width=' + screen.width + ',height=' + screen.height + ',left=0,top=0'; + var windowlocation = window.location.href + '&popout=yes'; + try { + camera.aspect = window.innerWidth / window.innerHeight; + windowlocation += '&popoutautoload=yes'; + } catch(event) { + // panorama not loaded + } + window.open(windowlocation,null,windowspecs) + } else { + window.close(); + } +} + function zoomIn() { if( fov >= 40 ) { fov -= 5;