fullscreen api #24

Merged
merged 6 commits into from Jan 28, 2016
Jump to file or symbol
Failed to load files and symbols.
+43 −6
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

Add fullscreen api

  • Loading branch information...
taisel committed Jan 28, 2016
commit f59bab989f8a09e6f13df787ccfa97d6d233e8f8
View
@@ -110,6 +110,9 @@
</li>
</ul>
</li>
+ <li>
+ <span id="fullscreen">Fullscreen</span>
+ </li>
<li>
<span id="speed"></div>
</li>
View
@@ -105,7 +105,7 @@ div#menu ul ul li {
background-color: rgb(255, 255, 255);
}
-div#menu ul ul span, div#menu ul ul button {
+div#menu ul ul a, div#menu ul ul span, div#menu ul ul button {
line-height: 120%;
padding: 10px 15px;
}
@@ -54,6 +54,7 @@ function registerGUIEvents() {
addEvent("click", document.getElementById("toggleDynamicSpeed"), function () {
IodineGUI.Iodine.toggleDynamicSpeed(this.checked);
});
+ addEvent("click", document.getElementById("fullscreen"), toggleFullScreen);
addEvent("change", document.getElementById("import"), function (e) {
if (typeof this.files != "undefined") {
try {
@@ -1,11 +1,11 @@
"use strict";
/*
Copyright (C) 2012-2015 Grant Galitz
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function keyDown(e) {
@@ -53,8 +53,41 @@ function keyUpPreprocess(e) {
case 53:
IodineGUI.Iodine.setSpeed(1);
break;
+ case 54:
+ toggleFullScreen();
+ break;
default:
//Control keys / other
- keyUp(keyCode);
+ keyUp(keyCode | 0);
+ }
+}
+function toggleFullScreen() {
+ if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) {
+ if (document.documentElement.requestFullscreen) {
+ document.documentElement.requestFullscreen();
+ }
+ else if (document.documentElement.msRequestFullscreen) {
+ document.documentElement.msRequestFullscreen();
+ }
+ else if (document.documentElement.mozRequestFullScreen) {
+ document.documentElement.mozRequestFullScreen();
+ }
+ else if (document.documentElement.webkitRequestFullscreen) {
+ document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
+ }
}
-}
+ else {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ }
+ else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ }
+ else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ }
+ else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ }
+}
+}