Hide the control if the Fullscreen API is not supported

This commit is contained in:
Frederic Junod
2013-04-10 10:59:38 +02:00
committed by Tom Payne
parent 8206cf111f
commit 7b0e036b83
4 changed files with 17 additions and 4 deletions
+3
View File
@@ -99,6 +99,9 @@ a.ol-full-screen-true:after {
margin: 1px; margin: 1px;
padding: 0px 2px; padding: 0px 2px;
} }
.ol-unsupported {
display: none;
}
.ol-viewport .ol-unselectable { .ol-viewport .ol-unselectable {
-webkit-touch-callout: none; -webkit-touch-callout: none;
-webkit-user-select: none; -webkit-user-select: none;
+1
View File
@@ -49,6 +49,7 @@
<div class="span4"> <div class="span4">
<h4 id="title">Full screen control example</h4> <h4 id="title">Full screen control example</h4>
<p id="shortdesc">Example of a full screen control. Click the control in the top right corner to go full screen. Click it again to exit full screen.</p> <p id="shortdesc">Example of a full screen control. Click the control in the top right corner to go full screen. Click it again to exit full screen.</p>
<p>If there is no button on the map, your browser does not support the <a href="http://caniuse.com/#feat=fullscreen">Full Screen API</a>.</p>
<div id="docs"> <div id="docs">
<p>See the <a href="full-screen.js" target="_blank">full-screen.js source</a> to see how this is done.</p> <p>See the <a href="full-screen.js" target="_blank">full-screen.js source</a> to see how this is done.</p>
</div> </div>
+5 -4
View File
@@ -41,7 +41,8 @@ ol.control.FullScreen = function(opt_options) {
this.handleFullScreenChange_, false, this); this.handleFullScreenChange_, false, this);
var element = goog.dom.createDom(goog.dom.TagName.DIV, { var element = goog.dom.createDom(goog.dom.TagName.DIV, {
'class': this.cssClassName_ + ' ' + ol.css.CLASS_UNSELECTABLE 'class': this.cssClassName_ + ' ' + ol.css.CLASS_UNSELECTABLE +
(!goog.dom.fullscreen.isSupported() ? ol.css.CLASS_UNSUPPORTED : '')
}, aElement); }, aElement);
goog.base(this, { goog.base(this, {
@@ -65,14 +66,14 @@ goog.inherits(ol.control.FullScreen, ol.control.Control);
* @private * @private
*/ */
ol.control.FullScreen.prototype.handleClick_ = function(browserEvent) { ol.control.FullScreen.prototype.handleClick_ = function(browserEvent) {
if (!goog.dom.fullscreen.isSupported()) {
return;
}
browserEvent.preventDefault(); browserEvent.preventDefault();
var map = this.getMap(); var map = this.getMap();
if (goog.isNull(map)) { if (goog.isNull(map)) {
return; return;
} }
if (!goog.dom.fullscreen.isSupported()) {
return;
}
if (goog.dom.fullscreen.isFullScreen()) { if (goog.dom.fullscreen.isFullScreen()) {
goog.dom.fullscreen.exitFullScreen(); goog.dom.fullscreen.exitFullScreen();
} else { } else {
+8
View File
@@ -7,3 +7,11 @@ goog.provide('ol.css');
* @const {string} * @const {string}
*/ */
ol.css.CLASS_UNSELECTABLE = 'ol-unselectable'; ol.css.CLASS_UNSELECTABLE = 'ol-unselectable';
/**
* The CSS class for unsupported feature.
*
* @const {string}
*/
ol.css.CLASS_UNSUPPORTED = 'ol-unsupported';