|
| CDOM.Level2.DomUtils | | Portability | non-portable (needs Yhc Javascript backend) | | Stability | stable | | Maintainer | Dmitry Golubovsky <golubovsky@gmail.com> |
|
|
|
|
|
| Description |
| Hand-written utilities to operate on DOM objects
|
|
| Synopsis |
|
|
|
| Documentation |
|
| Although most of DOM access functions are auto-generated from Web Consortium's
IDL specifications, some useful functions need to be hand-written, just for the sake
of convenience. Many DOM access functions have type constraints on their return value
specified as class instance rather than a type. This, while adds a lot of flexibility
in some cases, also leads to inconvenience of writing explicit type signatures
in other situations. Thus, some type-constrained versions of these functions may be
introduced, which have convenient type signatures, sometimes better order of arguments,
etc.
|
|
| getLocation :: CPS b String |
| Access the current location: same as if window.location were accessed from
bare Javascript.
|
|
| jumpLocation :: String -> Bool |
| Jump to another location. This function does not return.
|
|
| getDocument :: CPS b TDocument |
| Access the root Document: same as if window.document were accessed from
bare Javascript.
|
|
| getHTMLDocument :: CPS b THTMLDocument |
| Same as getDocument, but return value is cast to the THTMLDocument
type rather than TDocument. This is more convenient when implementing
HTML-oriented algorithms.
|
|
| documentBody :: CHTMLDocument doc => doc -> CPS b THTMLBodyElement |
| Access the BODY node of the current HTML document.
|
|
| documentHead :: CHTMLDocument doc => doc -> CPS b THTMLHeadElement |
| Access the HEAD node of the current HTML document.
|
|
| Type-constrained Manipulation with DOM Objects
|
|
| insertChild |
| :: (CNode refChild, CNode newChild, CNode parent) | | | => refChild | existing child: insert new child before it
| | -> newChild | new child node to add
| | -> parent | parent node
| | -> CPS b parent | the function returns the same parent node reference.
This allows to chain calls to insertChild if multiple
children are to be inserted:
... (insertChild r1 c1) (insertChild r2 c2) (... etc.
| | Insert a new child node before the given child node.
|
|
|
| addChild |
| :: (CNode newChild, CNode parent) | | | => newChild | new child node to add
| | -> parent | parent node
| | -> CPS b parent | the function returns the same parent node reference.
This allows to chain calls to addChild if multiple
children are to be added:
... (addChild c1) (addChild c2) (... etc.
| | Add a child node to the end of the parent node's children list.
|
|
|
| mkText :: CHTMLDocument doc => doc -> String -> CPS b TText |
| Create a text node. This is necessary to insert any text inside
DIV or any other HTML element. The return value is cast to
TText. Since TText is an instance of CNode, it may be supplied
to functions like addChild or insertChild.
|
|
| inlineStyle :: CHTMLElement a => a -> CPS b TCSS2Properties |
| Obtain an inline style (TCSS2Properties) interface of an object
|
|
| inlineStyleDecl :: CHTMLElement a => a -> CPS b TCSSStyleDeclaration |
| Obtain an inline style (TCSSStyleDeclaration) interface of an object
|
|
| parentElement :: (CHTMLElement a, CHTMLElement b) => a -> CPS z b |
| Obtain a reference to the parent element
|
|
| targetElement :: CEvent e => e -> CPS b THTMLElement |
| Given a CEvent, obtain a THTMLElement which is event's target
|
|
| Special Constants
|
|
| nodeNothing :: Maybe TNode |
| Nothing, properly typed to Maybe TNode.
|
|
| Casts
|
|
| eventTarget :: CNode a => a -> CPS b TEventTarget |
| Obtain an EventTarget interface on a node; basically itself
|
|
| elementNode :: CNode a => a -> CPS b TNode |
| Cast a Node subclass to Node: basically itself
|
|
| htmlElement :: CHTMLElement a => a -> CPS b THTMLElement |
| Cast a HTMLElement subclass to HTMLElement: basically itself
|
|
| Produced by Haddock version 0.8 |