From f602a682f75907c7a4ce2d172de92873c6e533ef Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Feb 2013 17:31:47 -0500 Subject: [PATCH 1/9] basic implementation of enhancement request from issue #3 --- src/viewer.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index bbcd2fd3..445730a1 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -629,6 +629,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, if ( fullPage ) { + requestFullScreen( document.body ); + this.bodyOverflow = bodyStyle.overflow; this.docOverflow = docStyle.overflow; bodyStyle.overflow = "hidden"; @@ -686,16 +688,18 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, $.getWindowSize().y - $.getElementSize( this.toolbar.element ).y ) + 'px'; }else{ - this.element.style.height = $.getWindowSize().y + 'px'; + this.element.style.height = '100%'; } - this.element.style.width = $.getWindowSize().x + 'px'; + this.element.style.width = '100%'; // mouse will be inside container now - $.delegate( this, onContainerEnter )(); + $.delegate( this, onContainerEnter )(); } else { - + + cancelFullScreen( document ); + bodyStyle.overflow = this.bodyOverflow; docStyle.overflow = this.docOverflow; @@ -744,7 +748,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, this.element.style.width = THIS[ this.hash ].prevElementSize.x + 'px'; // mouse will likely be outside now - $.delegate( this, onContainerExit )(); + $.delegate( this, onContainerExit )(); } this.raiseEvent( 'fullpage', { fullpage: fullPage, viewer: this } ); @@ -1475,5 +1479,48 @@ function onNext(){ this.goToPage( next ); } +////////////////////////////////////////////////////////////////// +// True "Full Screen" as opposed to "Full Page" +// Implementation based on +// http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen/7525760#7525760 +////////////////////////////////////////////////////////////////// +function cancelFullScreen(el) { + var requestMethod = el.cancelFullScreen||el.webkitCancelFullScreen||el.mozCancelFullScreen||el.exitFullscreen; + if (requestMethod) { // cancel full screen. + requestMethod.call(el); + } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. + var wscript = new ActiveXObject("WScript.Shell"); + if (wscript !== null) { + wscript.SendKeys("{F11}"); + } + } +} + +function requestFullScreen(el) { + // Supports most browsers and their versions. + var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen; + + if (requestMethod) { // Native full screen. + requestMethod.call(el); + } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. + var wscript = new ActiveXObject("WScript.Shell"); + if (wscript !== null) { + wscript.SendKeys("{F11}"); + } + } + return false; +} + +function toggleFull() { + var elem = document.body; // Make the body go full screen. + var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) || (document.mozFullScreen || document.webkitIsFullScreen); + + if (isInFullScreen) { + cancelFullScreen(document); + } else { + requestFullScreen(elem); + } + return false; +} }( OpenSeadragon )); From d4b02e1abaaf43716b75d11d9125401551b2efb9 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Feb 2013 22:34:44 -0500 Subject: [PATCH 2/9] managed to get a more complete, though hacky, implementation of #3. the big sticky point was how firefox and safari beahved when switching between applications when already in full screen mode. because we didnt have an event listener for fullscreenchange, and because those browsers released full screen on application or window change (think alt+tab or cmd+tab), you would come back to a empty document. more work left here to make this worth merging into master --- src/openseadragon.js | 6 +++--- src/viewer.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index af41bf6a..43b465a1 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -481,7 +481,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ maxZoomLevel: null, //UI RESPONSIVENESS AND FEEL - springStiffness: 5.0, + springStiffness: 7.0, clickTimeThreshold: 300, clickDistThreshold: 5, zoomPerClick: 2.0, @@ -490,13 +490,13 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ animationTime: 1.5, blendTime: 1.5, alwaysBlend: false, - autoHideControls: true, - immediateRender: false, + immediateRender: true, //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE preserveViewport: false, //SEQUENCE showNavigationControl: true, //ZOOM/HOME/FULL/SEQUENCE + autoHideControls: true, controlsFadeDelay: 2000, //ZOOM/HOME/FULL/SEQUENCE controlsFadeLength: 1500, //ZOOM/HOME/FULL/SEQUENCE mouseNavEnabled: true, //GENERAL MOUSE INTERACTIVITY diff --git a/src/viewer.js b/src/viewer.js index 445730a1..f63a5dfa 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -615,6 +615,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, docStyle = document.documentElement.style, containerStyle = this.element.style, canvasStyle = this.canvas.style, + _this = this, oldBounds, newBounds, viewer, @@ -626,10 +627,30 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, if ( fullPage == this.isFullPage() ) { return; } + this.tmp = function( event ) { + // The event object doesn't carry information about the fullscreen state of the browser, + // but it is possible to retrieve it through the fullscreen API + if( (document.fullScreenElement && document.fullScreenElement !== null) || + (document.mozFullScreen || document.webkitIsFullScreen) ){ + console.log( document.webkitIsFullScreen ); + // The target of the event is always the document, + // but it is possible to retrieve the fullscreen element through the API + if( !_this.isFullPage() ){ + _this.setFullPage( true ); + } + } else { + _this.setFullPage( false ); + } + }; if ( fullPage ) { - + requestFullScreen( document.body ); + + + // Note that the API is still vendor-prefixed in browsers implementing it + document.addEventListener("mozfullscreenchange", this.tmp); + document.addEventListener("webkitfullscreenchange", this.tmp); this.bodyOverflow = bodyStyle.overflow; this.docOverflow = docStyle.overflow; @@ -698,7 +719,9 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, } else { - cancelFullScreen( document ); + // Note that the API is still vendor-prefixed in browsers implementing it + document.removeEventListener("mozfullscreenchange", this.tmp); + document.removeEventListener("webkitfullscreenchange", this.tmp); bodyStyle.overflow = this.bodyOverflow; docStyle.overflow = this.docOverflow; @@ -750,6 +773,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, // mouse will likely be outside now $.delegate( this, onContainerExit )(); + cancelFullScreen( document ); + } this.raiseEvent( 'fullpage', { fullpage: fullPage, viewer: this } ); @@ -1523,4 +1548,5 @@ function toggleFull() { return false; } + }( OpenSeadragon )); From a18460a3107e14bb4c4f1034d59347bb4bdcd0ff Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Feb 2013 23:32:09 -0500 Subject: [PATCH 3/9] reverting a couple changes to core openseadragon options unrelated to issue #3 . will explore these in #4 were they have already been referenced. --- src/openseadragon.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index 43b465a1..af41bf6a 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -481,7 +481,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ maxZoomLevel: null, //UI RESPONSIVENESS AND FEEL - springStiffness: 7.0, + springStiffness: 5.0, clickTimeThreshold: 300, clickDistThreshold: 5, zoomPerClick: 2.0, @@ -490,13 +490,13 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ animationTime: 1.5, blendTime: 1.5, alwaysBlend: false, - immediateRender: true, + autoHideControls: true, + immediateRender: false, //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE preserveViewport: false, //SEQUENCE showNavigationControl: true, //ZOOM/HOME/FULL/SEQUENCE - autoHideControls: true, controlsFadeDelay: 2000, //ZOOM/HOME/FULL/SEQUENCE controlsFadeLength: 1500, //ZOOM/HOME/FULL/SEQUENCE mouseNavEnabled: true, //GENERAL MOUSE INTERACTIVITY From d6cdd4028cfb4868f7d4c8429601723da3567062 Mon Sep 17 00:00:00 2001 From: thatcher Date: Wed, 27 Feb 2013 09:46:33 -0500 Subject: [PATCH 4/9] removing unneccessary if --- src/viewer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index f63a5dfa..c620ccdb 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -635,9 +635,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, console.log( document.webkitIsFullScreen ); // The target of the event is always the document, // but it is possible to retrieve the fullscreen element through the API - if( !_this.isFullPage() ){ - _this.setFullPage( true ); - } + _this.setFullPage( true ); } else { _this.setFullPage( false ); } From a4477cd7657293ec2b5a314439a13288f5be53e2 Mon Sep 17 00:00:00 2001 From: thatcher Date: Thu, 28 Feb 2013 14:28:05 -0500 Subject: [PATCH 5/9] better encapsulation of native fullscreen api --- src/openseadragon.js | 80 +++++++++++++++++++++++++++++ src/viewer.js | 117 ++++++++++++++++--------------------------- 2 files changed, 123 insertions(+), 74 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index af41bf6a..9cd7dd49 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1655,6 +1655,86 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ })(); + /** + * Determines the appropriate level of native full secreen support we can get + * from the browser. + * Thanks to John Dyer for the implementation and research + * http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ + * Also includes older IE support based on + * http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen/7525760 + * @name $.supportsFullScreen + */ + (function() { + var fullScreenApi = { + supportsFullScreen: false, + isFullScreen: function() { return false; }, + requestFullScreen: function() {}, + cancelFullScreen: function() {}, + fullScreenEventName: '', + prefix: '' + }, + browserPrefixes = 'webkit moz o ms khtml'.split(' '); + + // check for native support + if (typeof document.cancelFullScreen != 'undefined') { + fullScreenApi.supportsFullScreen = true; + } else { + // check for fullscreen support by vendor prefix + for (var i = 0, il = browserPrefixes.length; i < il; i++ ) { + fullScreenApi.prefix = browserPrefixes[i]; + + if (typeof document[fullScreenApi.prefix + 'CancelFullScreen' ] != 'undefined' ) { + fullScreenApi.supportsFullScreen = true; + + break; + } + } + } + + // update methods to do something useful + if (fullScreenApi.supportsFullScreen) { + fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange'; + + fullScreenApi.isFullScreen = function() { + switch (this.prefix) { + case '': + return document.fullScreen; + case 'webkit': + return document.webkitIsFullScreen; + default: + return document[this.prefix + 'FullScreen']; + } + }; + fullScreenApi.requestFullScreen = function( element ) { + return (this.prefix === '') ? + element.requestFullScreen() : + element[this.prefix + 'RequestFullScreen'](); + + }; + fullScreenApi.cancelFullScreen = function( element ) { + return (this.prefix === '') ? + document.cancelFullScreen() : + document[this.prefix + 'CancelFullScreen'](); + }; + } else if ( typeof window.ActiveXObject !== "undefined" ){ + // Older IE. + fullScreenApi.requestFullScreen = function(){ + var wscript = new ActiveXObject("WScript.Shell"); + if ( wscript !== null ) { + wscript.SendKeys("{F11}"); + } + return false; + }; + fullScreenApi.cancelFullScreen = fullScreenApi.requestFullScreen; + } + + + // export api + $.extend( $, fullScreenApi ); + + })(); + + //TODO: $.console is often used inside a try/catch block which generally // prevents allowings errors to occur with detection until a debugger // is attached. Although I've been guilty of the same anti-pattern diff --git a/src/viewer.js b/src/viewer.js index c620ccdb..3fe24002 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -128,7 +128,8 @@ $.Viewer = function( options ) { "lastZoomTime": null, // did we decide this viewer has a sequence of tile sources "sequenced": false, - "sequence": 0 + "sequence": 0, + "onfullscreenchange": null }; //Inherit some behaviors and properties @@ -627,28 +628,13 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, if ( fullPage == this.isFullPage() ) { return; } - this.tmp = function( event ) { - // The event object doesn't carry information about the fullscreen state of the browser, - // but it is possible to retrieve it through the fullscreen API - if( (document.fullScreenElement && document.fullScreenElement !== null) || - (document.mozFullScreen || document.webkitIsFullScreen) ){ - console.log( document.webkitIsFullScreen ); - // The target of the event is always the document, - // but it is possible to retrieve the fullscreen element through the API - _this.setFullPage( true ); - } else { - _this.setFullPage( false ); - } - }; + if ( fullPage ) { - requestFullScreen( document.body ); + if( $.supportsFullScreen ){ - - // Note that the API is still vendor-prefixed in browsers implementing it - document.addEventListener("mozfullscreenchange", this.tmp); - document.addEventListener("webkitfullscreenchange", this.tmp); + } this.bodyOverflow = bodyStyle.overflow; this.docOverflow = docStyle.overflow; @@ -695,21 +681,43 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, 'class', this.toolbar.element.className +" fullpage" ); - //this.toolbar.element.style.position = 'fixed'; - - //this.container.style.top = $.getElementSize( - // this.toolbar.element - //).y + 'px'; } + body.appendChild( this.element ); + + if( $.supportsFullScreen ){ + THIS[ this.hash ].onfullscreenchange = function( event ) { + // The event object doesn't carry information about the + // fullscreen state of the browser, but it is possible to + // retrieve it through the fullscreen API + if( $.isFullScreen() ){ + // The target of the event is always the document, + // but it is possible to retrieve the fullscreen element through the API + _this.setFullPage( true ); + } else { + _this.setFullPage( false ); + } + }; + + $.requestFullScreen( document.body ); + + // Note that the API is still vendor-prefixed in browsers implementing it + document.addEventListener( + $.fullScreenEventName, + THIS[ this.hash ].onfullscreenchange + ); + this.element.style.height = '100%'; + this.element.style.width = '100%'; + }else{ + this.element.style.height = $.getWindowSize().y + 'px'; + this.element.style.width = $.getWindowSize().x + 'px'; + } + if( this.toolbar && this.toolbar.element ){ this.element.style.height = ( - $.getWindowSize().y - $.getElementSize( this.toolbar.element ).y + $.getElementSize( this.element ).y - $.getElementSize( this.toolbar.element ).y ) + 'px'; - }else{ - this.element.style.height = '100%'; } - this.element.style.width = '100%'; // mouse will be inside container now $.delegate( this, onContainerEnter )(); @@ -717,9 +725,13 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, } else { - // Note that the API is still vendor-prefixed in browsers implementing it - document.removeEventListener("mozfullscreenchange", this.tmp); - document.removeEventListener("webkitfullscreenchange", this.tmp); + if( $.supportsFullScreen ){ + document.removeEventListener( + $.fullScreenEventName, + THIS[ this.hash ].onfullscreenchange + ); + $.cancelFullScreen( document ); + } bodyStyle.overflow = this.bodyOverflow; docStyle.overflow = this.docOverflow; @@ -771,7 +783,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, // mouse will likely be outside now $.delegate( this, onContainerExit )(); - cancelFullScreen( document ); } this.raiseEvent( 'fullpage', { fullpage: fullPage, viewer: this } ); @@ -1502,49 +1513,7 @@ function onNext(){ this.goToPage( next ); } -////////////////////////////////////////////////////////////////// -// True "Full Screen" as opposed to "Full Page" -// Implementation based on -// http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen/7525760#7525760 -////////////////////////////////////////////////////////////////// -function cancelFullScreen(el) { - var requestMethod = el.cancelFullScreen||el.webkitCancelFullScreen||el.mozCancelFullScreen||el.exitFullscreen; - if (requestMethod) { // cancel full screen. - requestMethod.call(el); - } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. - var wscript = new ActiveXObject("WScript.Shell"); - if (wscript !== null) { - wscript.SendKeys("{F11}"); - } - } -} -function requestFullScreen(el) { - // Supports most browsers and their versions. - var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen; - - if (requestMethod) { // Native full screen. - requestMethod.call(el); - } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. - var wscript = new ActiveXObject("WScript.Shell"); - if (wscript !== null) { - wscript.SendKeys("{F11}"); - } - } - return false; -} - -function toggleFull() { - var elem = document.body; // Make the body go full screen. - var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) || (document.mozFullScreen || document.webkitIsFullScreen); - - if (isInFullScreen) { - cancelFullScreen(document); - } else { - requestFullScreen(elem); - } - return false; -} }( OpenSeadragon )); From 5dd8798f7fb9c3da3f8067acd5803b2c6ffa927d Mon Sep 17 00:00:00 2001 From: thatcher Date: Thu, 28 Feb 2013 15:22:10 -0500 Subject: [PATCH 6/9] addressing venturo's review notes --- src/viewer.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index 3fe24002..b9ac1f09 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -631,10 +631,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, if ( fullPage ) { - - if( $.supportsFullScreen ){ - - } this.bodyOverflow = bodyStyle.overflow; this.docOverflow = docStyle.overflow; @@ -691,8 +687,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, // fullscreen state of the browser, but it is possible to // retrieve it through the fullscreen API if( $.isFullScreen() ){ - // The target of the event is always the document, - // but it is possible to retrieve the fullscreen element through the API _this.setFullPage( true ); } else { _this.setFullPage( false ); @@ -701,6 +695,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, $.requestFullScreen( document.body ); + // The target of the event is always the document, + // but it is possible to retrieve the fullscreen element through the API // Note that the API is still vendor-prefixed in browsers implementing it document.addEventListener( $.fullScreenEventName, From 096b02d1c828430956911550c5dd28eeeed08e21 Mon Sep 17 00:00:00 2001 From: thatcher Date: Wed, 6 Mar 2013 06:03:05 -0500 Subject: [PATCH 7/9] addressing typo in comment pointed out by @iangilian --- src/openseadragon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index 9cd7dd49..a353d372 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1656,7 +1656,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ })(); /** - * Determines the appropriate level of native full secreen support we can get + * Determines the appropriate level of native full screen support we can get * from the browser. * Thanks to John Dyer for the implementation and research * http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ From 3801326e4042a86816041ade62573902a1e52312 Mon Sep 17 00:00:00 2001 From: thatcher Date: Wed, 6 Mar 2013 15:36:52 -0500 Subject: [PATCH 8/9] pulling full screen api detection out into is own file per ians suggestion --- Gruntfile.js | 1 + src/fullscreen.js | 78 +++++++++++++++++++++++++++++++++++++++++++ src/openseadragon.js | 79 +------------------------------------------- 3 files changed, 80 insertions(+), 78 deletions(-) create mode 100644 src/fullscreen.js diff --git a/Gruntfile.js b/Gruntfile.js index bd21d089..c3006fbd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,6 +13,7 @@ module.exports = function(grunt) { minified = "build/openseadragon/openseadragon.min.js", sources = [ "src/openseadragon.js", + "src/fullscreen.js", "src/eventhandler.js", "src/mousetracker.js", "src/control.js", diff --git a/src/fullscreen.js b/src/fullscreen.js new file mode 100644 index 00000000..16c3a4d0 --- /dev/null +++ b/src/fullscreen.js @@ -0,0 +1,78 @@ +/** + * Determines the appropriate level of native full screen support we can get + * from the browser. + * Thanks to John Dyer for the implementation and research + * http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ + * Also includes older IE support based on + * http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen/7525760 + * @name $.supportsFullScreen + */ +(function( $ ) { + var fullScreenApi = { + supportsFullScreen: false, + isFullScreen: function() { return false; }, + requestFullScreen: function() {}, + cancelFullScreen: function() {}, + fullScreenEventName: '', + prefix: '' + }, + browserPrefixes = 'webkit moz o ms khtml'.split(' '); + + // check for native support + if (typeof document.cancelFullScreen != 'undefined') { + fullScreenApi.supportsFullScreen = true; + } else { + // check for fullscreen support by vendor prefix + for (var i = 0, il = browserPrefixes.length; i < il; i++ ) { + fullScreenApi.prefix = browserPrefixes[i]; + + if (typeof document[fullScreenApi.prefix + 'CancelFullScreen' ] != 'undefined' ) { + fullScreenApi.supportsFullScreen = true; + + break; + } + } + } + + // update methods to do something useful + if (fullScreenApi.supportsFullScreen) { + fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange'; + + fullScreenApi.isFullScreen = function() { + switch (this.prefix) { + case '': + return document.fullScreen; + case 'webkit': + return document.webkitIsFullScreen; + default: + return document[this.prefix + 'FullScreen']; + } + }; + fullScreenApi.requestFullScreen = function( element ) { + return (this.prefix === '') ? + element.requestFullScreen() : + element[this.prefix + 'RequestFullScreen'](); + + }; + fullScreenApi.cancelFullScreen = function( element ) { + return (this.prefix === '') ? + document.cancelFullScreen() : + document[this.prefix + 'CancelFullScreen'](); + }; + } else if ( typeof window.ActiveXObject !== "undefined" ){ + // Older IE. + fullScreenApi.requestFullScreen = function(){ + var wscript = new ActiveXObject("WScript.Shell"); + if ( wscript !== null ) { + wscript.SendKeys("{F11}"); + } + return false; + }; + fullScreenApi.cancelFullScreen = fullScreenApi.requestFullScreen; + } + + + // export api + $.extend( $, fullScreenApi ); + +})( OpenSeadragon ); \ No newline at end of file diff --git a/src/openseadragon.js b/src/openseadragon.js index a353d372..cd9700ca 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1655,84 +1655,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ })(); - /** - * Determines the appropriate level of native full screen support we can get - * from the browser. - * Thanks to John Dyer for the implementation and research - * http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ - * Also includes older IE support based on - * http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen/7525760 - * @name $.supportsFullScreen - */ - (function() { - var fullScreenApi = { - supportsFullScreen: false, - isFullScreen: function() { return false; }, - requestFullScreen: function() {}, - cancelFullScreen: function() {}, - fullScreenEventName: '', - prefix: '' - }, - browserPrefixes = 'webkit moz o ms khtml'.split(' '); - - // check for native support - if (typeof document.cancelFullScreen != 'undefined') { - fullScreenApi.supportsFullScreen = true; - } else { - // check for fullscreen support by vendor prefix - for (var i = 0, il = browserPrefixes.length; i < il; i++ ) { - fullScreenApi.prefix = browserPrefixes[i]; - - if (typeof document[fullScreenApi.prefix + 'CancelFullScreen' ] != 'undefined' ) { - fullScreenApi.supportsFullScreen = true; - - break; - } - } - } - - // update methods to do something useful - if (fullScreenApi.supportsFullScreen) { - fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange'; - - fullScreenApi.isFullScreen = function() { - switch (this.prefix) { - case '': - return document.fullScreen; - case 'webkit': - return document.webkitIsFullScreen; - default: - return document[this.prefix + 'FullScreen']; - } - }; - fullScreenApi.requestFullScreen = function( element ) { - return (this.prefix === '') ? - element.requestFullScreen() : - element[this.prefix + 'RequestFullScreen'](); - - }; - fullScreenApi.cancelFullScreen = function( element ) { - return (this.prefix === '') ? - document.cancelFullScreen() : - document[this.prefix + 'CancelFullScreen'](); - }; - } else if ( typeof window.ActiveXObject !== "undefined" ){ - // Older IE. - fullScreenApi.requestFullScreen = function(){ - var wscript = new ActiveXObject("WScript.Shell"); - if ( wscript !== null ) { - wscript.SendKeys("{F11}"); - } - return false; - }; - fullScreenApi.cancelFullScreen = fullScreenApi.requestFullScreen; - } - - - // export api - $.extend( $, fullScreenApi ); - - })(); + //TODO: $.console is often used inside a try/catch block which generally From 5203cc14b079346e35e526d1445b73e34c16b19a Mon Sep 17 00:00:00 2001 From: thatcher Date: Thu, 7 Mar 2013 23:50:27 -0500 Subject: [PATCH 9/9] removing extra whitespace per pull request review --- src/openseadragon.js | 2 -- src/viewer.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index cd9700ca..a697b523 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1655,8 +1655,6 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ })(); - - //TODO: $.console is often used inside a try/catch block which generally // prevents allowings errors to occur with detection until a debugger diff --git a/src/viewer.js b/src/viewer.js index b9ac1f09..abcbf8e6 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1510,6 +1510,4 @@ function onNext(){ } - - }( OpenSeadragon ));