/**
* @classdesc
* This control expands fullscreen the map<br/>
* If {@link cercalia.widget.MainMenu} is created, also will be expanded.
*
* @constructor
* @param {Object} options
* @extends {ol.control.Control}
*/
cercalia.Control.FullScreen = function(options) {
/**
* @private
* @type {string}
*/
this.name_ = cercalia.MapControls.FullScreen;
/**
* Class name
* @private
* @type {string}
*/
this.CLASS_NAME_ = "cercalia.Control.FullScreen";
/**
* @private
* @type {number}
*/
this.top_ = options.top ? options.top : 0;
/**
* @private
* @type {string}
*/
this.element_ = null;
var className = 'ol-full-screen ol-unselectable ol-control';
var anchor = document.createElement('button');
var self = this;
var clickFn = function(){
self.isFullScreen() ? self.exitFullScreen_() : self.requestFullScreen_();
};
anchor.addEventListener('click', clickFn, false);
anchor.addEventListener('touchstart', clickFn, false);
this.element_ = document.createElement('div');
this.element_.className = className;
this.element_.appendChild(anchor);
cercalia.jQuery(this.element_).css("top", this.top_ + "px");
cercalia.jQuery(anchor).button({ icons: { primary: "cercalia-icon ol-full-screen-false" }, text: true }).attr("title", cercalia.i18n._("TOOLTIP_FULLSCREEN"));
cercalia.jQuery(this.element_).addClass("cercalia-tool-button");
ol.control.Control.call(this, {
element: this.element_,
target: options.target //??
});
};
ol.inherits(cercalia.Control.FullScreen, ol.control.Control);
/**
* Returns a boolean showing if API is in fullscreen mode or not.
* @return {boolean} isFullScreen
*/
cercalia.Control.FullScreen.prototype.isFullScreen = function() {
return !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
};
/**
* Enable fullscreen
* @private
*/
cercalia.Control.FullScreen.prototype.requestFullScreen_ = function(){
var cercaliaMap = this.getMap().getCercalia();
var target = this.getMap().getTarget();
var element = cercaliaMap.getMainMenu() ? document.getElementById(target).parentNode.parentNode : element = document.getElementById(target);
if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.requestFullscreen) {
element.requestFullscreen();
}
};
/**
* Disable fullscreen
* @private
*/
cercalia.Control.FullScreen.prototype.exitFullScreen_ = function() {
if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (doc.exitFullscreen) {
document.exitFullscreen();
}
};