Class Index | File Index

Classes


Function Namespace Pot.DOM


Defined in: <pot.js>.

Function Namespace Summary
Constructor Attributes Constructor Name and Description
 
DOM utilities.
Field Summary
Field Attributes Field Name and Description
<static>  
Pot.DOM.AttrMaps
Mapping the attribute names for access to property.
<static>  
Pot.DOM.NodeType
Enumeration for DOM node types (for reference)
<static>  
Pot.DOM.XPathResult
Enumeration for DOM XPath result types (for reference)
Method Summary
Method Attributes Method Name and Description
<static>  
Pot.DOM.addClass(elem, name)
Add the class name to the element.
<static>  
Pot.DOM.appendChilds(parent)
Appends all the child nodes on a DOM node.
<static>  
Pot.DOM.attr(elem, name, The)
Get or set the element's attributes.
<static>  
Pot.DOM.byId(id, (doc))
Alias for getElementById.
<static>  
Pot.DOM.coerceToNode(node)
Coerce to any DOM Node from argument value.
<static>  
Pot.DOM.convertToHTMLDocument(htmlString, (context))
Convert HTML string to HTML Document object.
<static>  
Pot.DOM.convertToHTMLString(context, (safe))
Convert to a HTML string from DOM document object.
<static>  
Pot.DOM.createDocument((rootTagName), (namespaceURI))
Creates an XML document object.
<static>  
Pot.DOM.detectDocument(x)
Detect Document object.
<static>  
Pot.DOM.detectWindow(x)
Detect Window object.
<static>  
Pot.DOM.evaluate(exp, (context), (all), (asis))
Evaluate the XPath expression and select the result node.
<static>  
Pot.DOM.getAttr(node, name)
Get the attribute value.
<static>  
Pot.DOM.getElement(selector, (context), (multi))
Get the element(s) by simple CSS selector expression.
<static>  
Pot.DOM.getElements(selector, (context))
A shortcut of getElement() method as multiple mode.
<static>  
Pot.DOM.getHTMLString(elem)
Get the HTML string from element.
<static>  
Pot.DOM.getOuterHTML(elem)
Get the outer HTML string to the element.
<static>  
Pot.DOM.getOwnerDocument(node)
Returns the owner document for a node.
<static>  
Pot.DOM.getSelectionContents(context)
Get the selection contents.
<static>  
Pot.DOM.getSelectionHTML(context)
Get the selection HTML string.
<static>  
Pot.DOM.getSelectionObject(context)
Get the selection object.
<static>  
Pot.DOM.getSelectionText(context)
Get the selection text.
<static>  
Pot.DOM.getTextContent(elem)
Get the text content string from element.
<static>  
Pot.DOM.getTextValue(node, buffer, normalizeSpace)
<static>  
Pot.DOM.getValue(elem)
Get the node value.
<static>  
Pot.DOM.hasAttr(node, name)
Check whether the attribute is exist.
<static>  
Pot.DOM.hasClass(elem, name)
Check whether the class name is exist.
<static>  
Pot.DOM.isDocument()
Check whether the argument object is Document.
<static>  
Pot.DOM.isElement()
Check whether the argument object is Element.
<static>  
Pot.DOM.isElementInView(element)
Checks whether element is in the view.
<static>  
Pot.DOM.isNodeLike()
Check whether the argument object like Node.
<static>  
Pot.DOM.isNodeList()
Check whether the argument object is NodeList.
<static>  
Pot.DOM.isWindow()
Check whether the argument object is Window.
<static>  
Pot.DOM.isXHTML(doc)
Check whether the argument object is XHTML Document.
<static>  
Pot.DOM.isXML(doc)
Check whether the argument object is XML Document.
<static>  
Pot.DOM.parseFromString(string)
Parse the HTML/XML string and convert to the document object.
<static>  
Pot.DOM.prependChilds(parent)
Prepends all the child nodes on a DOM node.
<static>  
Pot.DOM.removeAttr(node, name)
Remove the attribute.
<static>  
Pot.DOM.removeChilds(node)
Removes all the child nodes on a DOM node.
<static>  
Pot.DOM.removeClass(elem, name)
Remove the class name from the element.
<static>  
Pot.DOM.removeElement(elem)
Remove the element(s) from DOM tree.
<static>  
Pot.DOM.serializeToString(doc)
Serialize an element object or subtree to string.
<static>  
Pot.DOM.setAttr(node, name, (value))
Set the attribute value(s).
<static>  
Pot.DOM.setHTMLString(elem, value)
Set the HTML string to the element.
<static>  
Pot.DOM.setOuterHTML(elem, value)
Set the outer HTML string to the element.
<static>  
Pot.DOM.setTextContent(elem, value)
Set the Text content string to the element.
<static>  
Pot.DOM.setValue(elem, value)
Set the value to element.
<static>  
Pot.DOM.tagNameOf(elem)
Get the tagname of element as lower-case string.
<static>  
Pot.DOM.toggleClass(elem, name)
Toggle the specified class name.
<static>  
Pot.DOM.toString()
toString.
Function Namespace Detail
Pot.DOM()
DOM utilities.
Field Detail
<static> {Object} Pot.DOM.AttrMaps
Mapping the attribute names for access to property.

<static> Pot.DOM.NodeType
Enumeration for DOM node types (for reference)
See:
http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950641247

<static> Pot.DOM.XPathResult
Enumeration for DOM XPath result types (for reference)
See:
http://www.w3.org/TR/DOM-Level-3-XPath/ecma-script-binding.html
Method Detail
<static> {Function} Pot.DOM.addClass(elem, name)
Add the class name to the element.
Parameters:
{Element} elem
The target element.
{String} name
The class name.
Returns:
{Element} Returns `elem`.

<static> {Function} Pot.DOM.appendChilds(parent)
Appends all the child nodes on a DOM node.
Parameters:
{Node|Element} parent
The target parent node.
{Node|...Node} (...)
Nodes to append children from.
Returns:
{Node} Return the last child node appended.

<static> {Function} Pot.DOM.attr(elem, name, The)
Get or set the element's attributes.
Parameters:
{Element} elem
The target element node.
{String|Object} name
Get the attribute if you pass a string. Set each attributes if you pass an object.
{String|*} The
value to set.
Returns:
{*} Return the obtained attribute value, or if you set the value then will return the element.

<static> {Function} Pot.DOM.byId(id, (doc))
Alias for getElementById.
Parameters:
{String|Element} id
Element ID or a DOM node.
{Element|Document} (doc)
(Optional) A context node.
Returns:
{Element} The element with the given ID, or the node passed in.

<static> {Function} Pot.DOM.coerceToNode(node)
Coerce to any DOM Node from argument value.
Parameters:
{Node|*} node
The input node.
Returns:
{Node|*} The coerced node.

<static> {Function} Pot.DOM.convertToHTMLDocument(htmlString, (context))
Convert HTML string to HTML Document object.
Parameters:
{String} htmlString
A subject HTML string.
{Object} (context)
(Optional) A context object. e.g. document.
Returns:
{Object} Return the HTML Document object.

<static> {Function} Pot.DOM.convertToHTMLString(context, (safe))
Convert to a HTML string from DOM document object. from: Taberareloo lib. via: http://nanto.asablo.jp/blog/2010/02/05/4858761
Parameters:
{Document|Node} context
The input context.
{Boolean} (safe)
Whether sanitize the HTML nodes, for safely.
Returns:
{String} The result HTML string.

<static> {Function} Pot.DOM.createDocument((rootTagName), (namespaceURI))
Creates an XML document object.
Parameters:
{String} (rootTagName)
(Optional) The root tag name.
{String} (namespaceURI)
(Optional) Namespace URI of the document element.
Returns:
{Document} Return the new document.

<static> {Function} Pot.DOM.detectDocument(x)
Detect Document object.
Parameters:
{Window|Element|Node|*} x
The target object.
Returns:
{Document|undefined} Result of detected object.

<static> {Function} Pot.DOM.detectWindow(x)
Detect Window object.
Parameters:
{Document|Element|Node|*} x
The target object.
Returns:
{Window|undefined} Result of detected object.

<static> {Function} Pot.DOM.evaluate(exp, (context), (all), (asis))
Evaluate the XPath expression and select the result node.
Parameters:
{String} exp
The XPath expression.
{Document|Element} (context)
The conetxt object. e.g. document.
{Boolean} (all)
Whether to make multiple selections.
{Boolean} (asis)
Whether to return the results as is.
Returns:
{Array|Element} Return the selected node(s).

<static> {Function} Pot.DOM.getAttr(node, name)
Get the attribute value.
Parameters:
{Element} node
The target element.
{String} name
The attribute name.
Returns:
{String|*} The arrtibute value.

<static> {Function} Pot.DOM.getElement(selector, (context), (multi))
Get the element(s) by simple CSS selector expression. If .querySelector is available then will use it.
  var elem;
  elem = getElement('#foo');
  // @results  elem = Element e.g. <div id="foo"/>
  elem = getElement('.bar');
  // @results  elem = Element e.g. <div class="bar"/>
  elem = getElement('span.bar');
  // @results  elem = Element e.g. <span class="bar"/>
  elem = getElement('textarea');
  // @results  elem = Element e.g. <textarea>...</textarea>
  elem = getElement('[name="foo"]');
  // @results  elem = Element e.g. <div name="foo"/>
  elem = getElement('input[type="text"]');
  // @results  elem = Element e.g. <input type="text"/>
  elem = getElement('[action]');
  // @results  elem = Element e.g. <form action="..."/>
  elem = getElement('<div/>');
  // @results  elem = new Element e.g. <div/>
  elem = getElement('<div name="foo">Hello foo.</div>');
  // @results  elem = new Element e.g. <div name="foo">Hello foo.</div>
  elem = getElement('*');
  // @results  elem = All Elements, but will be returned first item.
  //                              e.g. <html lang="ja"/>
  // Multiple:
  var elems;
  elems = getElement('#foo, .bar, *[name="baz"]', document, true);
  // @results
  //   elems = [<div id="foo"/>, <div class="bar"/>, <div name="baz"/>]
  elems = getElement('*', getElement('div#foo'), true);
  // @results
  //   elems = Return all childNodes in <div id="foo">...</div>
Parameters:
{String} selector
The simple CSS selector.
{Document|Element} (context)
The target context or element.
{Boolean} (multi)
Whether to get the multiple elements. Default is single mode.
Returns:
{Array|Element} The result element(s).

<static> {Function} Pot.DOM.getElements(selector, (context))
A shortcut of getElement() method as multiple mode. Get the elements by simple CSS selector expression. If .querySelectorAll is available then will use it.
  var elems;
  elems = getElement('#foo, .bar, *[@name="baz"]', document, true);
  // @results
  //   elems = [<div id="foo"/>, <div class="bar"/>, <div name="baz"/>]
  elems = getElement('*', getElement('div#foo'), true);
  // @results
  //   elems = Return all childNodes in <div id="foo">...</div>
Parameters:
{String} selector
The simple CSS selector.
{Document|Element} (context)
The target context or element.
Returns:
{Array} The result elements as an Array.
See:
Pot.DOM.getElement

<static> {Function} Pot.DOM.getHTMLString(elem)
Get the HTML string from element.
Parameters:
{Element} elem
The target element.
Returns:
{String} The result HTML string.

<static> {Function} Pot.DOM.getOuterHTML(elem)
Get the outer HTML string to the element.
Parameters:
{Element} elem
The input element.
Returns:
{String} The value of result.

<static> {Function} Pot.DOM.getOwnerDocument(node)
Returns the owner document for a node.
Parameters:
{Node|Window|Element} node
The node to get the document for.
Returns:
{Document} The document owning the node.

<static> {Function} Pot.DOM.getSelectionContents(context)
Get the selection contents.
Parameters:
{Window|Document|Node|*} context
The input context.
Returns:
{Object} The result contents.

<static> {Function} Pot.DOM.getSelectionHTML(context)
Get the selection HTML string.
Parameters:
{Window|Document|Node|*} context
The input context.
Returns:
{String} The selection HTML.

<static> {Function} Pot.DOM.getSelectionObject(context)
Get the selection object.
Parameters:
{Document|Window|Element|*} context
The input context.
Returns:
{Selection|*} The Selection object.

<static> {Function} Pot.DOM.getSelectionText(context)
Get the selection text.
Parameters:
{Window|Document|Node|*} context
The input context.
Returns:
{String} The selection text.

<static> {Function} Pot.DOM.getTextContent(elem)
Get the text content string from element.
Parameters:
{Element} elem
The target element.
Returns:
{String} The result text content string.

<static> Pot.DOM.getTextValue(node, buffer, normalizeSpace)
Parameters:
node
buffer
normalizeSpace

<static> {Function} Pot.DOM.getValue(elem)
Get the node value.
Parameters:
{Element} elem
The input node.
Returns:
{String|*} The result value.

<static> {Function} Pot.DOM.hasAttr(node, name)
Check whether the attribute is exist.
Parameters:
{Element} node
The target element.
{String} name
The attribute name.
Returns:
{Boolean} Whether the attribute is exist.

<static> {Function} Pot.DOM.hasClass(elem, name)
Check whether the class name is exist.
Parameters:
{Element} elem
The target element.
{String} name
The class name.
Returns:
{Boolean} Whether the class name is exist.

<static> {Function} Pot.DOM.isDocument()
Check whether the argument object is Document.
See:
Pot.isDocument

<static> {Function} Pot.DOM.isElement()
Check whether the argument object is Element.
See:
Pot.isElement

<static> {Function} Pot.DOM.isElementInView(element)
Checks whether element is in the view.
Parameters:
{Element} element
The target element.
Returns:
{Boolean} Whether element is in the view.

<static> {Function} Pot.DOM.isNodeLike()
Check whether the argument object like Node.
See:
Pot.isNodeLike

<static> {Function} Pot.DOM.isNodeList()
Check whether the argument object is NodeList.
See:
Pot.isNodeList

<static> {Function} Pot.DOM.isWindow()
Check whether the argument object is Window.
See:
Pot.isWindow

<static> {Function} Pot.DOM.isXHTML(doc)
Check whether the argument object is XHTML Document.
Parameters:
{Document} doc
The input document object.
Returns:
{Boolean} Whether `doc` is XHTML.

<static> {Function} Pot.DOM.isXML(doc)
Check whether the argument object is XML Document.
Parameters:
{Document} doc
The input document object.
Returns:
{Boolean} Whether `doc` is XML.

<static> {Function} Pot.DOM.parseFromString(string)
Parse the HTML/XML string and convert to the document object.
Parameters:
{String} string
The target text.
Returns:
{Document} XML/HTML document from the text.

<static> {Function} Pot.DOM.prependChilds(parent)
Prepends all the child nodes on a DOM node.
Parameters:
{Node|Element} parent
The target parent node.
{Node|...Node} (...)
Nodes to prepend children from.
Returns:
{Node} Return the last child node prepended.

<static> {Function} Pot.DOM.removeAttr(node, name)
Remove the attribute.
Parameters:
{Element} node
The target element.
{String} name
The attribute name.

<static> {Function} Pot.DOM.removeChilds(node)
Removes all the child nodes on a DOM node.
Parameters:
{Node|Element} node
Node to remove children from.
Returns:
{Node|Element} Returns `node`.

<static> {Function} Pot.DOM.removeClass(elem, name)
Remove the class name from the element.
Parameters:
{Element} elem
The target element.
{String} name
The class name to remove.
Returns:
Returns `elem`.

<static> {Function} Pot.DOM.removeElement(elem)
Remove the element(s) from DOM tree.
Parameters:
{Element} elem
The input elemenet(s).
Returns:
{Element} Returns `elem`.

<static> {Function} Pot.DOM.serializeToString(doc)
Serialize an element object or subtree to string.
Parameters:
{Document|Element} doc
The document or the root node of the subtree.
Returns:
{String} The serialized XML/HTML string.

<static> {Function} Pot.DOM.setAttr(node, name, (value))
Set the attribute value(s).
Parameters:
{Element} node
The target element.
{String|Object} name
The attribute name or key-value object.
{String|*} (value)
The attribute value to set.

<static> {Function} Pot.DOM.setHTMLString(elem, value)
Set the HTML string to the element.
Parameters:
{Element} elem
The input element.
{String|*} value
The value to set.

<static> {Function} Pot.DOM.setOuterHTML(elem, value)
Set the outer HTML string to the element.
Parameters:
{Element} elem
The input element.
{String|*} value
The value to set.

<static> {Function} Pot.DOM.setTextContent(elem, value)
Set the Text content string to the element.
Parameters:
{Element} elem
The input element.
{String|*} value
The value to set.

<static> {Function} Pot.DOM.setValue(elem, value)
Set the value to element.
Parameters:
{Element} elem
The input element.
{*} value
The value to set.

<static> {Function} Pot.DOM.tagNameOf(elem)
Get the tagname of element as lower-case string.
  var elem = document.getElementsByTagName('*')[15];
  if (tagNameOf(elem) === 'div') {
    // do something
  }
Parameters:
{Element} elem
The target element node.
Returns:
{String} The result of tagname.

<static> {Function} Pot.DOM.toggleClass(elem, name)
Toggle the specified class name.
Parameters:
{Element} elem
The target element.
{String} name
The class name to toggle.
Returns:
{Element} Returns `elem`.

<static> {Function} Pot.DOM.toString()
toString.
Returns:
{String} The string representation of object.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 21 2012 19:32:22 GMT+0900 (JST)