Skip to content
Browse files

Use https://github.com/neovov/Fullscreen-API-Polyfill/

  • Loading branch information...
1 parent 52eb48c commit 8afdf9b7025331ab0450f92b6bf3654173f5061f @fredj committed Apr 26, 2012
Showing with 7 additions and 58 deletions.
  1. +1 −0 examples/fullscreen.html
  2. +6 −58 lib/OpenLayers/Control/FullScreen.js
View
1 examples/fullscreen.html
@@ -12,6 +12,7 @@
<link rel="stylesheet" href="../css/fullscreen.css" type="text/css">
<script src="http://openlayers.org/dev/OpenLayers.js"></script>
+ <script src="https://raw.github.com/neovov/Fullscreen-API-Polyfill/master/fullscreen-api-polyfill.js"></script>
<script src="../lib/OpenLayers/Control/FullScreen.js"></script>
<style>
.smallmap {
View
64 lib/OpenLayers/Control/FullScreen.js
@@ -17,17 +17,17 @@ OpenLayers.Control.FullScreen = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Control.prototype.setMap.apply(this, arguments);
// handle 'Esc' key press
- OpenLayers.Event.observe(this.map.div, fullScreenApi.fullScreenEventName, OpenLayers.Function.bind(function() {
- if (fullScreenApi.isFullScreen() === false) {
+ OpenLayers.Event.observe(document, "fullscreenchange", OpenLayers.Function.bind(function() {
+ if (!document.fullscreenEnabled) {
this.deactivate();
}
}, this));
},
activate: function() {
if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {
- if (fullScreenApi.supportsFullScreen) {
- fullScreenApi.requestFullScreen(this.map.div);
+ if (this.map.div.requestFullscreen) {
+ this.map.div.requestFullscreen();
}
OpenLayers.Element.addClass(this.map.div, this.fullscreenClass);
this.map.updateSize();
@@ -39,8 +39,8 @@ OpenLayers.Control.FullScreen = OpenLayers.Class(OpenLayers.Control, {
deactivate: function() {
if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {
- if (fullScreenApi.supportsFullScreen) {
- fullScreenApi.cancelFullScreen();
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
}
OpenLayers.Element.removeClass(this.map.div, this.fullscreenClass);
this.map.updateSize();
@@ -52,55 +52,3 @@ OpenLayers.Control.FullScreen = OpenLayers.Class(OpenLayers.Control, {
CLASS_NAME: "OpenLayers.Control.FullScreen"
});
-
-
-// from http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
-(function() {
- var fullScreenApi = {
- supportsFullScreen: false,
- isFullScreen: function() { return false; },
- requestFullScreen: function() {},
- cancelFullScreen: function() {},
- fullScreenEventName: '',
- prefix: ''
- }
- var 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(el) {
- return (this.prefix === '') ? el.requestFullScreen() : el[this.prefix + 'RequestFullScreen']();
- }
- fullScreenApi.cancelFullScreen = function(el) {
- return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen']();
- }
- }
-
- // export api
- window.fullScreenApi = fullScreenApi;
-})();

0 comments on commit 8afdf9b

Please sign in to comment.
Something went wrong with that request. Please try again.