summaryrefslogtreecommitdiff
path: root/Miso/FFI/Fullscreen.hs
blob: db2e37e96ac3cc37e48631fd2f14035b2a5d86e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# LANGUAGE NoImplicitPrelude #-}
module Miso.FFI.Fullscreen where

import GHCJS.Types
import Protolude

-- | Requests that the user agent switch from full-screen mode back to windowed
-- mode. Returns a Promise which is resolved once full-screen mode has been
-- completely shut off.
--
-- https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen
foreign import javascript unsafe "$r = document.exitFullscreen();"
  exitFullscreen :: IO JSVal

exit :: IO JSVal
exit = exitFullscreen

-- | Asks the user agent to place the specified element (and, by extension, its
-- descendants) into full-screen mode, removing all of the browser's UI elements
-- as well as all other applications from the screen. Returns a Promise which is
-- resolved once full-screen mode has been activated.
--
-- https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen
foreign import javascript unsafe "$r = $1.requestFullscreen();"
  requestFullscreen :: JSVal -> IO JSVal

request :: JSVal -> IO JSVal
request = requestFullscreen