jmonkey-0.1.0.1: Jmonkey is very restricted but handy EDSL for JavaScript.

Safe HaskellSafe
LanguageHaskell2010

JMonkey.Action

Contents

Description

JMonkey actions.

Synopsis

Types

type JMonkey = JMonkeyM () Source #

Empty JMonkey monad.

type JMonkeyM = Free Action Source #

JMonkey monad designed with free monad.

data Action n Source #

JMonkey action AST.

Instances
Functor Action Source # 
Instance details

Defined in JMonkey.Action

Methods

fmap :: (a -> b) -> Action a -> Action b #

(<$) :: a -> Action b -> Action a #

data Cond Source #

JMonkey conditions. These mean boolean value.

Constructors

Possess Target Selector

if all the target have the selector

YOffset CompOp Double

if window.pageYOffset satisfies with given comparision operator and threshold value

Show

putLog :: String -> JMonkey Source #

Show console log.

alert :: String -> JMonkey Source #

Show alert.

Selection

select :: Selector -> JMonkeyM Target Source #

Select target by given selector.

Selector Modification

add :: Target -> Selector -> JMonkey Source #

Add class or id to the target.

For multiple selectors

f :: Target -> [Selector] -> JMonkey
f t = mapM_ (add t)

adds :: [Target] -> Selector -> JMonkey Source #

Add class or id to the targets.

For multiple selectors

f :: [Target] -> [Selector] -> JMonkey
f ts = mapM_ (adds ts)

remove :: Target -> Selector -> JMonkey Source #

Remove class or id from the target.

removes :: [Target] -> Selector -> JMonkey Source #

Remove class or id from the targets.

On Event

on Source #

Arguments

:: String

an event name like "click", "scroll", ...etc

-> Target

a target related to the event

-> JMonkey

an action triggered by the event

-> JMonkey 

Make event.

onClick :: Target -> JMonkey -> JMonkey Source #

Same as on "click".

onScroll :: Target -> JMonkey -> JMonkey Source #

Same as on "scroll".

onChange :: Target -> JMonkey -> JMonkey Source #

Same as on "change".

Time Triggered Event

onTime Source #

Arguments

:: Repeat

repetition

-> Int

delay time (milliseconds)

-> JMonkey

an action on the time

-> JMonkey 

Make time triggered event.

Conditional Action

ifel Source #

Arguments

:: Cond

a condition

-> JMonkey

an action do when the condition is satisfied

-> JMonkey

an action do when the condition is not satisfied

-> JMonkey 

Make conditional action.

ifThen :: Cond -> JMonkey -> JMonkey Source #

Only true conditional action of ifel

elThen :: Cond -> JMonkey -> JMonkey Source #

Only false conditional action of ifel