Skip to content

Commit

Permalink
Fixes #498 - Add the ability to toggle fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
samhed committed Jun 25, 2015
1 parent b098afc commit 7d1dc09
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Binary file added images/fullscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions include/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ var UI;
UI.setBarPosition();
} );

// Hide the button if fullscreen isn't supported
if (!document.documentElement.requestFullscreen &&
!document.documentElement.mozRequestFullScreen &&
!document.documentElement.webkitRequestFullscreen &&
!document.body.msRequestFullscreen) {
$D('fullscreenButton').style.display = "none";
} else {
Util.addEvent(window, 'fullscreenchange', UI.updateFullscreenButton);
Util.addEvent(window, 'mozfullscreenchange', UI.updateFullscreenButton);
Util.addEvent(window, 'webkitfullscreenchange', UI.updateFullscreenButton);
Util.addEvent(window, 'msfullscreenchange', UI.updateFullscreenButton);
}

Util.addEvent(window, 'load', UI.keyboardinputReset);

Util.addEvent(window, 'beforeunload', function () {
Expand Down Expand Up @@ -201,6 +214,7 @@ var UI;
$D("noVNC_popup_status").onclick = UI.togglePopupStatus;
$D("xvpButton").onclick = UI.toggleXvpPanel;
$D("clipboardButton").onclick = UI.toggleClipboardPanel;
$D("fullscreenButton").onclick = UI.toggleFullscreen;
$D("settingsButton").onclick = UI.toggleSettingsPanel;
$D("connectButton").onclick = UI.toggleConnectPanel;
$D("disconnectButton").onclick = UI.disconnect;
Expand Down Expand Up @@ -437,6 +451,46 @@ var UI;
}
},

// Toggle fullscreen mode
toggleFullscreen: function() {
if (document.fullscreenElement || // alternative standard method
document.mozFullScreenElement || // currently working methods
document.webkitFullscreenElement ||
document.msFullscreenElement ) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
} else {
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (document.body.msRequestFullscreen) {
document.body.msRequestFullscreen();
}
}
UI.updateFullscreenButton();
},

updateFullscreenButton: function() {
if (document.fullscreenElement || // alternative standard method
document.mozFullScreenElement || // currently working methods
document.webkitFullscreenElement ||
document.msFullscreenElement ) {
$D('fullscreenButton').className = "noVNC_status_button_selected";
} else {
$D('fullscreenButton').className = "noVNC_status_button";
}
},

// Show the connection settings panel/menu
toggleConnectPanel: function() {
// Close the description panel
Expand Down
3 changes: 3 additions & 0 deletions vnc.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
<input type="image" alt="Clipboard" src="images/clipboard.png"
id="clipboardButton" class="noVNC_status_button"
title="Clipboard" />
<input type="image" alt="Fullscreen" src="images/fullscreen.png"
id="fullscreenButton" class="noVNC_status_button"
title="Fullscreen" />
<input type="image" alt="Settings" src="images/settings.png"
id="settingsButton" class="noVNC_status_button"
title="Settings" />
Expand Down

0 comments on commit 7d1dc09

Please sign in to comment.