Safe Haskell | None |
---|---|
Language | Haskell98 |
DOM manipulation functions using String
for string representation.
- class IsElem a where
- data Elem
- type PropID = String
- type ElemID = String
- type QuerySelector = String
- type ElemClass = String
- data AttrName
- type AttrValue = String
- style :: String -> AttrName
- attr :: String -> AttrName
- (=:) :: AttrName -> AttrValue -> Attribute
- newElem :: MonadIO m => String -> m Elem
- newTextElem :: MonadIO m => String -> m Elem
- elemById :: MonadIO m => ElemID -> m (Maybe Elem)
- elemsByQS :: MonadIO m => Elem -> QuerySelector -> m [Elem]
- elemsByClass :: MonadIO m => ElemClass -> m [Elem]
- setProp :: (IsElem e, MonadIO m) => e -> PropID -> String -> m ()
- getProp :: (IsElem e, MonadIO m) => e -> PropID -> m String
- setAttr :: (IsElem e, MonadIO m) => e -> PropID -> String -> m ()
- getAttr :: (IsElem e, MonadIO m) => e -> PropID -> m String
- getValue :: (IsElem e, MonadIO m, JSType a) => e -> m (Maybe a)
- withElem :: MonadIO m => ElemID -> (Elem -> m a) -> m a
- withElems :: MonadIO m => [ElemID] -> ([Elem] -> m a) -> m a
- withElemsQS :: (IsElem e, MonadIO m) => e -> QuerySelector -> ([Elem] -> m a) -> m a
- mapQS :: (IsElem e, MonadIO m) => e -> QuerySelector -> (Elem -> m a) -> m [a]
- mapQS_ :: (IsElem e, MonadIO m) => e -> QuerySelector -> (Elem -> m a) -> m ()
- getStyle :: (IsElem e, MonadIO m) => e -> PropID -> m String
- setStyle :: (IsElem e, MonadIO m) => e -> PropID -> String -> m ()
- getFileData :: (IsElem e, MonadIO m) => e -> Int -> m (Maybe Blob)
- getFileName :: (IsElem e, MonadIO m) => e -> m String
- setClass :: (IsElem e, MonadIO m) => e -> String -> Bool -> m ()
- toggleClass :: (IsElem e, MonadIO m) => e -> String -> m ()
- hasClass :: (IsElem e, MonadIO m) => e -> String -> m Bool
Documentation
The class of types backed by DOM elements.
type QuerySelector = String Source
The name of an attribute. May be either a common property, an HTML attribute or a style attribute.
newTextElem :: MonadIO m => String -> m Elem Source
Create a text node.
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.
setAttr :: (IsElem e, MonadIO m) => e -> PropID -> String -> m () Source
Set an attribute of the given element.
getValue :: (IsElem e, MonadIO m, JSType a) => e -> m (Maybe a) Source
Get the value property of an element; a handy shortcut.
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.