Remove static methods from FullScreen

This commit is contained in:
Tim Schaub
2018-02-18 22:38:05 -07:00
parent 971d2d6f07
commit 2d46a15a3d
+19 -19
View File
@@ -80,7 +80,7 @@ const FullScreen = function(opt_options) {
const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen'; const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
const button = document.createElement('button'); const button = document.createElement('button');
button.className = this.cssClassName_ + '-' + FullScreen.isFullScreen(); button.className = this.cssClassName_ + '-' + isFullScreen();
button.setAttribute('type', 'button'); button.setAttribute('type', 'button');
button.title = tipLabel; button.title = tipLabel;
button.appendChild(this.labelNode_); button.appendChild(this.labelNode_);
@@ -90,7 +90,7 @@ const FullScreen = function(opt_options) {
const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE + const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE +
' ' + CLASS_CONTROL + ' ' + ' ' + CLASS_CONTROL + ' ' +
(!FullScreen.isFullScreenSupported() ? CLASS_UNSUPPORTED : ''); (!isFullScreenSupported() ? CLASS_UNSUPPORTED : '');
const element = document.createElement('div'); const element = document.createElement('div');
element.className = cssClasses; element.className = cssClasses;
element.appendChild(button); element.appendChild(button);
@@ -131,15 +131,15 @@ FullScreen.prototype.handleClick_ = function(event) {
* @private * @private
*/ */
FullScreen.prototype.handleFullScreen_ = function() { FullScreen.prototype.handleFullScreen_ = function() {
if (!FullScreen.isFullScreenSupported()) { if (!isFullScreenSupported()) {
return; return;
} }
const map = this.getMap(); const map = this.getMap();
if (!map) { if (!map) {
return; return;
} }
if (FullScreen.isFullScreen()) { if (isFullScreen()) {
FullScreen.exitFullScreen(); exitFullScreen();
} else { } else {
let element; let element;
if (this.source_) { if (this.source_) {
@@ -150,10 +150,10 @@ FullScreen.prototype.handleFullScreen_ = function() {
element = map.getTargetElement(); element = map.getTargetElement();
} }
if (this.keys_) { if (this.keys_) {
FullScreen.requestFullScreenWithKeys(element); requestFullScreenWithKeys(element);
} else { } else {
FullScreen.requestFullScreen(element); requestFullScreen(element);
} }
} }
}; };
@@ -165,7 +165,7 @@ FullScreen.prototype.handleFullScreen_ = function() {
FullScreen.prototype.handleFullScreenChange_ = function() { FullScreen.prototype.handleFullScreenChange_ = function() {
const button = this.element.firstElementChild; const button = this.element.firstElementChild;
const map = this.getMap(); const map = this.getMap();
if (FullScreen.isFullScreen()) { if (isFullScreen()) {
button.className = this.cssClassName_ + '-true'; button.className = this.cssClassName_ + '-true';
replaceNode(this.labelActiveNode_, this.labelNode_); replaceNode(this.labelActiveNode_, this.labelNode_);
} else { } else {
@@ -195,7 +195,7 @@ FullScreen.prototype.setMap = function(map) {
/** /**
* @return {boolean} Fullscreen is supported by the current platform. * @return {boolean} Fullscreen is supported by the current platform.
*/ */
FullScreen.isFullScreenSupported = function() { function isFullScreenSupported() {
const body = document.body; const body = document.body;
return !!( return !!(
body.webkitRequestFullscreen || body.webkitRequestFullscreen ||
@@ -203,23 +203,23 @@ FullScreen.isFullScreenSupported = function() {
(body.msRequestFullscreen && document.msFullscreenEnabled) || (body.msRequestFullscreen && document.msFullscreenEnabled) ||
(body.requestFullscreen && document.fullscreenEnabled) (body.requestFullscreen && document.fullscreenEnabled)
); );
}; }
/** /**
* @return {boolean} Element is currently in fullscreen. * @return {boolean} Element is currently in fullscreen.
*/ */
FullScreen.isFullScreen = function() { function isFullScreen() {
return !!( return !!(
document.webkitIsFullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.mozFullScreen ||
document.msFullscreenElement || document.fullscreenElement document.msFullscreenElement || document.fullscreenElement
); );
}; }
/** /**
* Request to fullscreen an element. * Request to fullscreen an element.
* @param {Node} element Element to request fullscreen * @param {Node} element Element to request fullscreen
*/ */
FullScreen.requestFullScreen = function(element) { function requestFullScreen(element) {
if (element.requestFullscreen) { if (element.requestFullscreen) {
element.requestFullscreen(); element.requestFullscreen();
} else if (element.msRequestFullscreen) { } else if (element.msRequestFullscreen) {
@@ -229,26 +229,26 @@ FullScreen.requestFullScreen = function(element) {
} else if (element.webkitRequestFullscreen) { } else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen(); element.webkitRequestFullscreen();
} }
}; }
/** /**
* Request to fullscreen an element with keyboard input. * Request to fullscreen an element with keyboard input.
* @param {Node} element Element to request fullscreen * @param {Node} element Element to request fullscreen
*/ */
FullScreen.requestFullScreenWithKeys = function(element) { function requestFullScreenWithKeys(element) {
if (element.mozRequestFullScreenWithKeys) { if (element.mozRequestFullScreenWithKeys) {
element.mozRequestFullScreenWithKeys(); element.mozRequestFullScreenWithKeys();
} else if (element.webkitRequestFullscreen) { } else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else { } else {
FullScreen.requestFullScreen(element); requestFullScreen(element);
} }
}; }
/** /**
* Exit fullscreen. * Exit fullscreen.
*/ */
FullScreen.exitFullScreen = function() { function exitFullScreen() {
if (document.exitFullscreen) { if (document.exitFullscreen) {
document.exitFullscreen(); document.exitFullscreen();
} else if (document.msExitFullscreen) { } else if (document.msExitFullscreen) {
@@ -258,6 +258,6 @@ FullScreen.exitFullScreen = function() {
} else if (document.webkitExitFullscreen) { } else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen(); document.webkitExitFullscreen();
} }
}; }
export default FullScreen; export default FullScreen;