{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.Notification
(newNotification, show, close, requestPermission, getPermission,
click, error, cLoseEvent, display, showEvent, setTag, getTag,
Notification(..), gTypeNotification)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
newNotification ::
(MonadDOM m, ToJSString title) =>
title -> Maybe NotificationOptions -> m Notification
newNotification title options
= liftDOM
(Notification <$>
new (jsg "Notification") [toJSVal title, toJSVal options])
show :: (MonadDOM m) => Notification -> m ()
show self = liftDOM (void (self ^. jsf "show" ()))
close :: (MonadDOM m) => Notification -> m ()
close self = liftDOM (void (self ^. jsf "close" ()))
requestPermission ::
(MonadDOM m, ToJSString callback) =>
Maybe (NotificationPermissionCallback callback) -> m ()
requestPermission callback
= liftDOM
(void
((jsg "Notification") ^. jsf "requestPermission"
[toJSVal callback]))
getPermission ::
(MonadDOM m, FromJSString result) => Notification -> m result
getPermission self
= liftDOM ((self ^. js "permission") >>= fromJSValUnchecked)
click :: EventName Notification MouseEvent
click = unsafeEventName (toJSString "click")
error :: EventName Notification UIEvent
error = unsafeEventNameAsync (toJSString "error")
cLoseEvent :: EventName Notification CloseEvent
cLoseEvent = unsafeEventNameAsync (toJSString "close")
display :: EventName Notification ondisplay
display = unsafeEventName (toJSString "display")
showEvent :: EventName Notification MouseEvent
showEvent = unsafeEventName (toJSString "show")
setTag ::
(MonadDOM m, ToJSString val) => Notification -> val -> m ()
setTag self val = liftDOM (self ^. jss "tag" (toJSVal val))
getTag ::
(MonadDOM m, FromJSString result) => Notification -> m result
getTag self = liftDOM ((self ^. js "tag") >>= fromJSValUnchecked)