mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 21:26:10 +03:00
be20645876
See discussion in #10.
113 lines
4.3 KiB
JavaScript
113 lines
4.3 KiB
JavaScript
/*
|
|
* OpenSeadragon
|
|
*
|
|
* Copyright (C) 2009 CodePlex Foundation
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions are
|
|
* met:
|
|
*
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
*
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* - Neither the name of CodePlex Foundation nor the names of its
|
|
* contributors may be used to endorse or promote products derived from
|
|
* this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
|
|
/**
|
|
* 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 );
|