haste-compiler-0.5.4.1: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.DOM.JSString

Description

DOM manipulation functions using JSString for string representation.

Synopsis

Documentation

data AttrName Source

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

data Attribute Source

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

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 a DOM element backed object from an Elem. The default instance always returns Nothing.

newtype Elem Source

A DOM node.

Constructors

Elem JSAny 

set :: (IsElem e, MonadIO m) => e -> [Attribute] -> m () Source

Set a number of Attributes on an element.

with :: (IsElem e, MonadIO m) => m e -> [Attribute] -> m e 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",
    ...
  ]

children :: [Elem] -> Attribute Source

Attribute adding a list of child nodes to an element.

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

Generate a click event on an element.

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

Generate a focus event on an element.

blur :: (IsElem e, MonadIO m) => e -> 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.

appendChild :: (IsElem parent, IsElem child, MonadIO m) => parent -> child -> m () Source

Append the second element as a child of the first.

addChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m () Source

Deprecated: Use appendChild instead. Note that appendChild == flip addChild.

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

addChildBefore :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> child -> m () Source

Deprecated: Use insertChildBefore instead. Note insertChildBefore == parent new old -> addChildBefore new parent old.

Insert an element into a container, before another element. For instance: addChildBefore childToAdd theContainer olderChild

insertChildBefore :: (IsElem parent, IsElem before, IsElem child, MonadIO m) => parent -> before -> child -> m () Source

Insert an element into a container, before another element. For instance: insertChildBefore theContainer olderChild childToAdd

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

Get the first of an element's children.

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

Get the last of an element's children.

getChildren :: (IsElem e, MonadIO m) => e -> m [Elem] Source

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

setChildren :: (IsElem parent, IsElem child, MonadIO m) => parent -> [child] -> m () Source

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

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

Remove all children from the given element.

deleteChild :: (IsElem parent, IsElem child, MonadIO m) => parent -> child -> m () Source

Remove the second element from the first's children.

removeChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m () Source

Deprecated: Use deleteChild instead. Note that deleteChild = flip removeChild.

DEPRECATED: use deleteChild instead! Note that deleteChild = flip removeChild.

prop :: JSString -> AttrName Source

Create a DOM property name. See http://stackoverflow.com/questions/6003819/properties-and-attributes-in-html for more information about the difference between attributes and properties.

style :: JSString -> AttrName Source

Create a style attribute name.

attr :: JSString -> AttrName Source

Create an HTML attribute name.

(=:) :: AttrName -> AttrValue -> Attribute infixl 4 Source

Create an Attribute.

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

Create an element.

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

Create a text node.

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

Get an element by its HTML ID attribute.

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

Set a property of the given element.

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

Get a property of an element.

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

Set an attribute of the given element.

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

Get a CSS style property of an element.

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

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

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

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

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

Does the given element have a particular class?