{-# 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 :: forall (m :: * -> *) title.
(MonadDOM m, ToJSString title) =>
title -> Maybe NotificationOptions -> m Notification
newNotification title
title Maybe NotificationOptions
options
= DOM Notification -> m Notification
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSVal -> Notification
Notification (JSVal -> Notification) -> JSM JSVal -> DOM Notification
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
JSM JSVal -> [JSM JSVal] -> JSM JSVal
forall constructor args.
(MakeObject constructor, MakeArgs args) =>
constructor -> args -> JSM JSVal
new (String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"Notification") [title -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal title
title, Maybe NotificationOptions -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe NotificationOptions
options])
show :: (MonadDOM m) => Notification -> m ()
show :: forall (m :: * -> *). MonadDOM m => Notification -> m ()
show Notification
self = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Notification
self Notification
-> Getting (JSM JSVal) Notification (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"show" ()))
close :: (MonadDOM m) => Notification -> m ()
close :: forall (m :: * -> *). MonadDOM m => Notification -> m ()
close Notification
self = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Notification
self Notification
-> Getting (JSM JSVal) Notification (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"close" ()))
requestPermission ::
(MonadDOM m, ToJSString callback) =>
Maybe (NotificationPermissionCallback callback) -> m ()
requestPermission :: forall (m :: * -> *) callback.
(MonadDOM m, ToJSString callback) =>
Maybe (NotificationPermissionCallback callback) -> m ()
requestPermission Maybe (NotificationPermissionCallback callback)
callback
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
((String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"Notification") JSM JSVal
-> Getting (JSM JSVal) (JSM JSVal) (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"requestPermission"
[Maybe (NotificationPermissionCallback callback) -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe (NotificationPermissionCallback callback)
callback]))
getPermission ::
(MonadDOM m, FromJSString result) => Notification -> m result
getPermission :: forall (m :: * -> *) result.
(MonadDOM m, FromJSString result) =>
Notification -> m result
getPermission Notification
self
= DOM result -> m result
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((Notification
self Notification
-> Getting (JSM JSVal) Notification (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter Notification (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"permission") JSM JSVal -> (JSVal -> DOM result) -> DOM result
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM result
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
click :: EventName Notification MouseEvent
click :: EventName Notification MouseEvent
click = DOMString -> EventName Notification MouseEvent
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"click")
error :: EventName Notification UIEvent
error :: EventName Notification UIEvent
error = DOMString -> EventName Notification UIEvent
forall t e. DOMString -> EventName t e
unsafeEventNameAsync (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"error")
cLoseEvent :: EventName Notification CloseEvent
cLoseEvent :: EventName Notification CloseEvent
cLoseEvent = DOMString -> EventName Notification CloseEvent
forall t e. DOMString -> EventName t e
unsafeEventNameAsync (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"close")
display :: EventName Notification ondisplay
display :: forall ondisplay. EventName Notification ondisplay
display = DOMString -> EventName Notification ondisplay
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"display")
showEvent :: EventName Notification MouseEvent
showEvent :: EventName Notification MouseEvent
showEvent = DOMString -> EventName Notification MouseEvent
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"show")
setTag ::
(MonadDOM m, ToJSString val) => Notification -> val -> m ()
setTag :: forall (m :: * -> *) val.
(MonadDOM m, ToJSString val) =>
Notification -> val -> m ()
setTag Notification
self val
val = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (Notification
self Notification -> Getting (DOM ()) Notification (DOM ()) -> DOM ()
forall s a. s -> Getting a s a -> a
^. String
-> JSM JSVal
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
forall name val.
(ToJSString name, ToJSVal val) =>
name
-> val
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
jss String
"tag" (val -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal val
val))
getTag ::
(MonadDOM m, FromJSString result) => Notification -> m result
getTag :: forall (m :: * -> *) result.
(MonadDOM m, FromJSString result) =>
Notification -> m result
getTag Notification
self = DOM result -> m result
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((Notification
self Notification
-> Getting (JSM JSVal) Notification (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter Notification (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"tag") JSM JSVal -> (JSVal -> DOM result) -> DOM result
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM result
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)