diff options
-rw-r--r-- | js/read.js | 18 | ||||
-rw-r--r-- | read.html | 2 |
2 files changed, 8 insertions, 12 deletions
@@ -2,20 +2,16 @@ var _store_position = 0; -function request_fullscreen() { +function toggle_fullscreen() { var element = document.documentElement; - if (element.requestFullscreen) { - element.requestFullscreen(); - } else if (element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if (element.webkitRequestFullScreen) { - element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); - } -} + var isFullscreen = document.webkitIsFullScreen || document.mozFullScreen || false; + + element.requestFullScreen = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || function () { return false; }; + + document.cancelFullScreen = document.cancelFullScreen || document.webkitCancelFullScreen || document.mozCancelFullScreen || function () { return false; }; -function disable_fullscreen() { - document.webkitExitFullscreen(); + isFullscreen ? document.cancelFullScreen() : element.requestFullScreen(); } function show_ui(show) { @@ -200,7 +200,7 @@ <span class="glyphicon glyphicon-search" aria-hidden="true"></span> </span> - <span onclick="request_fullscreen()"> + <span onclick="toggle_fullscreen()"> <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span> </span> |