haste-compiler-0.5.0: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.DOM

Description

DOM manipulation functions using String for string representation.

Synopsis

Documentation

class IsElem a where Source

The class of types backed by DOM elements.

Minimal complete definition

elemOf

Methods

elemOf :: a -> Elem Source

Get the element representing the object.

fromElem :: Elem -> IO (Maybe a) Source

Attempt to create an object from an Elem.

data Elem Source

A DOM node.

data AttrName Source

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

Instances

style :: String -> AttrName Source

Create a style attribute name.

attr :: String -> AttrName Source

Create an HTML attribute name.

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 :: (IsElem e, MonadIO m) => e -> PropID -> String -> m () Source

Set a property of the given element.

getProp :: (IsElem e, MonadIO m) => e -> PropID -> m String Source

Get a property of an element.

setAttr :: (IsElem e, MonadIO m) => e -> PropID -> String -> m () Source

Set an attribute of the given element.

getAttr :: (IsElem e, MonadIO m) => e -> PropID -> m String Source

Get an attribute of an element.

getValue :: (IsElem e, MonadIO m, JSType a) => e -> 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 :: (IsElem e, MonadIO m) => e -> QuerySelector -> ([Elem] -> m a) -> m a Source

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

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

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

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

Like mapQS but returns no value.

getStyle :: (IsElem e, MonadIO m) => e -> PropID -> m String Source

Get a CSS style property of an element.

setStyle :: (IsElem e, MonadIO m) => e -> PropID -> String -> m () Source

Set a CSS style property on an element.

getFileData :: (IsElem e, MonadIO m) => e -> Int -> m (Maybe Blob) Source

Get a file from a file input element.

getFileName :: (IsElem e, MonadIO m) => e -> 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 :: (IsElem e, MonadIO m) => e -> String -> Bool -> m () Source

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

toggleClass :: (IsElem e, MonadIO m) => e -> String -> m () Source

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

hasClass :: (IsElem e, MonadIO m) => e -> String -> m Bool Source

Does the given element have a particular class?