From 7d1dc09ad0010924c6940832225e5eb2dc803f4f Mon Sep 17 00:00:00 2001 From: samhed Date: Thu, 18 Jun 2015 10:45:59 +0200 Subject: [PATCH] Fixes #498 - Add the ability to toggle fullscreen mode --- images/fullscreen.png | Bin 0 -> 851 bytes include/ui.js | 54 ++++++++++++++++++++++++++++++++++++++++++ vnc.html | 3 +++ 3 files changed, 57 insertions(+) create mode 100644 images/fullscreen.png diff --git a/images/fullscreen.png b/images/fullscreen.png new file mode 100644 index 0000000000000000000000000000000000000000..f4fa0ce8321de23929618a8d82ec0e42c094bafc GIT binary patch literal 851 zcmV-Z1FZasP)P000>X1^@s6#OZ}&00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-va^(3nu(M(YOEr0^mtR zK~zY`-Bv+s;y@IRx`*0@QVPXFFCKc8$+u~>Y$TrSyqG#dTNQ4bJ8V_B9{+$SK*ata|d z_Hu^3hQr~oH=E7W&xp)sGj%u|_Et8$s*dA0jYi{w=lQUY?Yo2L`EaArxNscD@p5vM zQfiu}NeChCjb^j?a~-L7yxPBk5JF7TG%2N&!x&>pk`fTY%yc?6m^Vy_=lRVKJlJFc z?A&xZH6Vl;Ns&A=C`x)X8a;YExk{O$k%5NkG@mu~yfX!NKkN}5v2 zI1g81E=f|tEo9ra4Iw=76M+z(*tTuE1tdvIFfV<>GF@`}7|ghHQ56<>}p_Yd&@ zhXp-|WrMKKuzF~*fjfK@hf8Rc)~>HVk7T%W}$3K$hi{VHgu;tEy^C5QJ^7NSNpOD4XPRxs7Z# zd!0-s(`=0p^1N6qUi?04u~@tiLY~vTG|`Fws00I=8X zcJJKPwBPUd%H?u$T`wt@%gKJf-*cbqcDr`~fW3S^zt!nkoc>D>vAZXilU$7{O2ZO;t_j0ZzBO&B@KA%6i*Mb(y`F#H5ehBaWNU(Scg0S-^SuF^{ dj`v;}eggqm-~P^IymkNp002ovPDHLkV1kszf;IpE literal 0 HcmV?d00001 diff --git a/include/ui.js b/include/ui.js index 3d3c41e..0d9ad82 100644 --- a/include/ui.js +++ b/include/ui.js @@ -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 () { @@ -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; @@ -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 diff --git a/vnc.html b/vnc.html index 6acd792..1a293d0 100644 --- a/vnc.html +++ b/vnc.html @@ -99,6 +99,9 @@ + -- 2.39.5