Hide the control if the Fullscreen API is not supported
This commit is contained in:
committed by
Tom Payne
parent
8206cf111f
commit
7b0e036b83
@@ -99,6 +99,9 @@ a.ol-full-screen-true:after {
|
||||
margin: 1px;
|
||||
padding: 0px 2px;
|
||||
}
|
||||
.ol-unsupported {
|
||||
display: none;
|
||||
}
|
||||
.ol-viewport .ol-unselectable {
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<div class="span4">
|
||||
<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>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">
|
||||
<p>See the <a href="full-screen.js" target="_blank">full-screen.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,8 @@ ol.control.FullScreen = function(opt_options) {
|
||||
this.handleFullScreenChange_, false, this);
|
||||
|
||||
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);
|
||||
|
||||
goog.base(this, {
|
||||
@@ -65,14 +66,14 @@ goog.inherits(ol.control.FullScreen, ol.control.Control);
|
||||
* @private
|
||||
*/
|
||||
ol.control.FullScreen.prototype.handleClick_ = function(browserEvent) {
|
||||
if (!goog.dom.fullscreen.isSupported()) {
|
||||
return;
|
||||
}
|
||||
browserEvent.preventDefault();
|
||||
var map = this.getMap();
|
||||
if (goog.isNull(map)) {
|
||||
return;
|
||||
}
|
||||
if (!goog.dom.fullscreen.isSupported()) {
|
||||
return;
|
||||
}
|
||||
if (goog.dom.fullscreen.isFullScreen()) {
|
||||
goog.dom.fullscreen.exitFullScreen();
|
||||
} else {
|
||||
|
||||
@@ -7,3 +7,11 @@ goog.provide('ol.css');
|
||||
* @const {string}
|
||||
*/
|
||||
ol.css.CLASS_UNSELECTABLE = 'ol-unselectable';
|
||||
|
||||
|
||||
/**
|
||||
* The CSS class for unsupported feature.
|
||||
*
|
||||
* @const {string}
|
||||
*/
|
||||
ol.css.CLASS_UNSUPPORTED = 'ol-unsupported';
|
||||
|
||||
Reference in New Issue
Block a user