diff options
author | Andrew Dolgov <[email protected]> | 2018-07-02 15:48:11 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-07-02 15:48:11 +0300 |
commit | c49bf9b1e35f320fbc713d48ea6c4881337d835e (patch) | |
tree | c83cf842ee79b8281127da143fbcc988bc6cf5a1 /js/read.js | |
parent | d4e70d08f88559c942e5231bdf77512ce7934214 (diff) |
make fullscreen toolbar button a toggle
Diffstat (limited to 'js/read.js')
-rw-r--r-- | js/read.js | 18 |
1 files changed, 7 insertions, 11 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) { |