haste-compiler-0.4.4: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.DOM

Synopsis

Documentation

newtype Elem Source

Constructors

Elem JSAny 

data Attribute Source

A key/value pair representing the value of an attribute. May represent a property, an HTML attribute or a style attribute.

data AttrName Source

The name of an attribute. May be either a common property, an HTML attribute or a style attribute.

Instances

set :: MonadIO m => Elem -> [Attribute] -> m () Source

Set a number of Attributes on an element.

style :: String -> AttrName Source

Create a style attribute name.

attr :: String -> AttrName Source

Create an HTML attribute name.

with :: MonadIO m => m Elem -> [Attribute] -> m Elem Source

Set a number of Attributes on the element produced by an IO action. Gives more convenient syntax when creating elements:

newElem "div" with [ style "border" := "1px solid black", ... ]

newElem :: MonadIO m => String -> m Elem Source

Create an element.

newTextElem :: MonadIO m => String -> m Elem Source

Create a text node.

elemById :: MonadIO m => ElemID -> m (Maybe Elem) Source

Get an element by its HTML ID attribute.

elemsByQS :: MonadIO m => Elem -> QuerySelector -> m [Elem] Source

Get all children elements matching a query selector.

elemsByClass :: MonadIO m => ElemClass -> m [Elem] Source

Get all elements of the given class.

setProp :: MonadIO m => Elem -> PropID -> String -> m () Source

Set a property of the given element.

getProp :: MonadIO m => Elem -> PropID -> m String Source

Get a property of an element.

setAttr :: MonadIO m => Elem -> PropID -> String -> m () Source

Set an attribute of the given element.

getAttr :: MonadIO m => Elem -> PropID -> m String Source

Get an attribute of an element.

setProp' :: MonadIO m => Elem -> JSString -> JSString -> m () Source

Set a property of the given element, JSString edition.

getProp' :: MonadIO m => Elem -> JSString -> m JSString Source

Get a property of an element, JSString edition.

getValue :: (MonadIO m, JSType a) => Elem -> m (Maybe a) Source

Get the value property of an element; a handy shortcut.

withElem :: MonadIO m => ElemID -> (Elem -> m a) -> m a Source

Perform an IO action on an element.

withElems :: MonadIO m => [ElemID] -> ([Elem] -> m a) -> m a Source

Perform an IO action over several elements. Throws an error if some of the elements are not found.

withElemsQS :: MonadIO m => Elem -> QuerySelector -> ([Elem] -> m a) -> m a Source

Perform an IO action over the a list of elements matching a query selector.

mapQS :: MonadIO m => Elem -> QuerySelector -> (Elem -> m a) -> m [a] Source

Map an IO computation over the list of elements matching a query selector.

mapQS_ :: MonadIO m => Elem -> QuerySelector -> (Elem -> m a) -> m () Source

Like mapQS but returns no value.

addChild :: MonadIO m => Elem -> Elem -> m () Source

Append the first element as a child of the second element.

addChildBefore :: MonadIO m => Elem -> Elem -> Elem -> m () Source

Insert the first element as a child into the second, before the third. For instance: addChildBefore childToAdd theContainer olderChild

removeChild :: MonadIO m => Elem -> Elem -> m () Source

Remove the first element from the second's children.

clearChildren :: MonadIO m => Elem -> m () Source

Remove all children from the given element.

getChildBefore :: MonadIO m => Elem -> m (Maybe Elem) Source

Get the sibling before the given one, if any.

getFirstChild :: MonadIO m => Elem -> m (Maybe Elem) Source

Get the first of an element's children.

getLastChild :: MonadIO m => Elem -> m (Maybe Elem) Source

Get the last of an element's children.

getChildren :: MonadIO m => Elem -> m [Elem] Source

Get a list of all children belonging to a certain element.

setChildren :: MonadIO m => Elem -> [Elem] -> m () Source

Clear the given element's list of children, and append all given children to it.

getStyle :: MonadIO m => Elem -> PropID -> m String Source

Get a CSS style property of an element.

setStyle :: MonadIO m => Elem -> PropID -> String -> m () Source

Set a CSS style property on an element.

getStyle' :: MonadIO m => Elem -> JSString -> m JSString Source

Get a CSS style property of an element, JSString style.

setStyle' :: MonadIO m => Elem -> JSString -> JSString -> m () Source

Set a CSS style property on an element, JSString style.

getFileData :: MonadIO m => Elem -> Int -> m (Maybe Blob) Source

Get a file from a file input element.

getFileName :: MonadIO m => Elem -> m String Source

Get the name of the currently selected file from a file input element. Any directory information is stripped, and only the actual file name is returned, as the directory information is useless (and faked) anyway.

setClass :: MonadIO m => Elem -> String -> Bool -> m () Source

Add or remove a class from an element's class list.

toggleClass :: MonadIO m => Elem -> String -> m () Source

Toggle the existence of a class within an elements class list.

hasClass :: MonadIO m => Elem -> String -> m Bool Source

Does the given element have a particular class?

click :: MonadIO m => Elem -> m () Source

Generate a click event on an element.

focus :: MonadIO m => Elem -> m () Source

Generate a focus event on an element.

blur :: MonadIO m => Elem -> m () Source

Generate a blur event on an element.

document :: Elem Source

The DOM node corresponding to document.

documentBody :: Elem Source

The DOM node corresponding to document.body.