Class Index | File Index

Classes


Class core.DomUtilsImpl


Defined in: DomUtils.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
A collection of Dom utilities
Method Summary
Method Attributes Method Name and Description
<inner>  
adaptRangeDifferenceToZoomLevel(inputNumber, zoomLevel)
Scale the supplied number by the specified zoom transformation if the bowser does not transform range client rectangles correctly.
<inner>  
cloneEvent(event)
Clones an event object.
<inner>  
comparePoints(c1, o1, c2, o2)
Return a number > 0 when point 1 precedes point 2.
<inner>  
containsNode(parent, descendant)
Whether a node contains another node Wrapper around Node.contains http://www.w3.org/TR/domcore/#dom-node-contains
<inner>  
containsNodeForBrokenWebKit(parent, descendant)
Whether a node contains another node
<inner>  
containsRange(container, insideRange)
Returns true if the container range completely contains the insideRange.
<inner>  
findStablePoint(container, offset)
Find the inner-most child point that is equivalent to the provided container and offset.
<inner>  
Get the bounding client rect for the specified node.
<inner>  
getElementsByTagName(node, tagName)
Get an array of nodes below the specified node with the specific name tag name.
<inner>  
getElementsByTagNameNS(node, namespace, tagName)
Get an array of nodes below the specified node with the specific namespace and tag name.
<inner>  
getKeyValRepresentationOfNode(node, prefixResolver)
Looks at an element's direct children, and generates an object which is a flat key-value map from the child's ns:localName to it's text content.
<inner>  
getNodesInRange(range, nodeFilter, whatToShow)
Fetches all nodes within a supplied range that pass the required filter
<inner>  
getPositionInContainingNode(node, container)
Gets the unfiltered DOM 'offset' of a node within a container that may not be it's direct parent.
<inner>  
<inner>  
init(self)
<inner>  
mapKeyValObjOntoNode(node, properties, nsResolver)
Takes a flat object which is a key-value map of strings, and populates/modifies the node with child elements which have the key name as the node name (namespace prefix required in the key name) and the value as the text content.
<inner>  
mapObjOntoNode(node, properties, nsResolver)
Maps attributes and elements in the properties object over top of the node.
<inner>  
Returns the maximum available offset for the node.
<inner>  
mergeIntoParent(targetNode)
Merge all child nodes into the targetNode's parent and remove the targetNode entirely
<inner>  
mergeTextNodes(node, nextNode)
Merges the content of node with nextNode.
<inner>  
moveToNonRejectedNode(walker, root, nodeFilter)
Checks all nodes between the tree walker's current node and the defined root.
<inner>  
Attempts to normalize the node with any surrounding text nodes.
<inner>  
rangeContainsNode(limits, node)
Checks if the provided limits fully encompass the passed in node
<inner>  
rangeIntersection(range1, range2)
Returns the intersection of two ranges.
<inner>  
rangesIntersect(range1, range2)
Returns true if there is any intersection between range1 and range2
 
Removes all child nodes from the given node.
<inner>  
removeKeyElementsFromNode(node, propertyNames, nsResolver)
Takes an array of strings, which is a listing of properties to be removed (namespace required), and deletes the corresponding top-level child elements that represent those properties, from the supplied node.
<inner>  
removeUnwantedNodes(targetNode, nodeFilter)
Removes all unwanted nodes from targetNode includes itself.
<inner>  
If either the start or end boundaries of a range start within a text node, this function will split these text nodes and reset the range boundaries to select the new nodes.
 
translateRect(child, parent, zoomLevel)
Translate a given child client rectangle to be relative to the parent's rectangle.
Class Detail
core.DomUtilsImpl()
A collection of Dom utilities
Method Detail
<inner> {!number} adaptRangeDifferenceToZoomLevel(inputNumber, zoomLevel)
Scale the supplied number by the specified zoom transformation if the bowser does not transform range client rectangles correctly. In firefox, the span rectangle will be affected by the zoom, but the range is not. In most all other browsers, the range number is affected zoom. See http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface Section 10, getClientRects, "The transforms that apply to the ancestors are applied."
Parameters:
{!number} inputNumber
An input number to be scaled. This is expected to be the difference between a property on two range-sourced client rectangles (e.g., rect1.top - rect2.top)
{!number} zoomLevel
Current canvas zoom level
Returns:
{!number}

<inner> {!Event} cloneEvent(event)
Clones an event object. IE10 destructs event objects once the event handler is done: "The event object is only available during an event; that is, you can use it in event handlers but not in other code" (from http://msdn.microsoft.com/en-us/library/ie/aa703876(v=vs.85).aspx) This method can be used to create a copy of the event object, to work around that.
Parameters:
{!Event} event
Returns:
{!Event}

<inner> {!number} comparePoints(c1, o1, c2, o2)
Return a number > 0 when point 1 precedes point 2. Return 0 if the points are equal. Return < 0 when point 2 precedes point 1.
Parameters:
{!Node} c1
container of point 1
{!number} o1
offset in unfiltered DOM world of point 1
{!Node} c2
container of point 2
{!number} o2
offset in unfiltered DOM world of point 2
Returns:
{!number}

<inner> {!boolean} containsNode(parent, descendant)
Whether a node contains another node Wrapper around Node.contains http://www.w3.org/TR/domcore/#dom-node-contains
Parameters:
{!Node} parent
The node that should contain the other node
{?Node} descendant
The node to test presence of
Returns:
{!boolean}

<inner> {!boolean} containsNodeForBrokenWebKit(parent, descendant)
Whether a node contains another node
Parameters:
{!Node} parent
The node that should contain the other node
{?Node} descendant
The node to test presence of
Returns:
{!boolean}

<inner> {boolean} containsRange(container, insideRange)
Returns true if the container range completely contains the insideRange. Aligned boundaries are counted as inclusion
Parameters:
{!Range} container
{!Range} insideRange
Returns:
{boolean}

<inner> {{container: Node|offset: !number}} findStablePoint(container, offset)
Find the inner-most child point that is equivalent to the provided container and offset.
Parameters:
{!Node} container
{!number} offset
Returns:
{{container: Node|offset: !number}}

<inner> {?ClientRect} getBoundingClientRect(node)
Get the bounding client rect for the specified node. This function attempts to cope with various browser quirks, ideally returning a rectangle that can be used in conjunction with rectangles retrieved from ranges. Range & element client rectangles can only be mixed if both are transformed in the same way. See https://bugzilla.mozilla.org/show_bug.cgi?id=863618
Parameters:
{!Node} node
Returns:
{?ClientRect}

<inner> {!Array.} getElementsByTagName(node, tagName)
Get an array of nodes below the specified node with the specific name tag name. Use this function instead of node.getElementsByTagName when modifications are going to be made to the document content during iteration. For read-only uses, node.getElementsByTagName will perform faster and use less memory. See https://github.com/kogmbh/WebODF/issues/736 for further discussion.
Parameters:
{!Element|!Document} node
{!string} tagName
Returns:
{!Array.}

<inner> {!Array.} getElementsByTagNameNS(node, namespace, tagName)
Get an array of nodes below the specified node with the specific namespace and tag name. Use this function instead of node.getElementsByTagNameNS when modifications are going to be made to the document content during iteration. For read-only uses, node.getElementsByTagNameNS will perform faster and use less memory. See https://github.com/kogmbh/WebODF/issues/736 for further discussion.
Parameters:
{!Element|!Document} node
{!string} namespace
{!string} tagName
Returns:
{!Array.}

<inner> {!Object.} getKeyValRepresentationOfNode(node, prefixResolver)
Looks at an element's direct children, and generates an object which is a flat key-value map from the child's ns:localName to it's text content. Only those children that have a resolvable prefixed name will be taken into account for generating this map.
Parameters:
{!Element} node
{function(!string):?string} prefixResolver
Returns:
{!Object.}

<inner> {!Array.} getNodesInRange(range, nodeFilter, whatToShow)
Fetches all nodes within a supplied range that pass the required filter
Parameters:
{!Range} range
{!function(!Node) : number} nodeFilter
{!number} whatToShow
Returns:
{!Array.}

<inner> {!number} getPositionInContainingNode(node, container)
Gets the unfiltered DOM 'offset' of a node within a container that may not be it's direct parent.
Parameters:
{!Node} node
{!Node} container
Returns:
{!number}

<inner> {!Range} getSharedRange(doc)
Parameters:
{!Document} doc
Returns:
{!Range}

<inner> init(self)
Parameters:
{!core.DomUtilsImpl} self

<inner> mapKeyValObjOntoNode(node, properties, nsResolver)
Takes a flat object which is a key-value map of strings, and populates/modifies the node with child elements which have the key name as the node name (namespace prefix required in the key name) and the value as the text content. Example: mapKeyValObjOntoNode(node, {"dc:creator": "Bob"}, nsResolver); If a namespace prefix is unresolved with the nsResolver, that key will be ignored and not written to the node.
Parameters:
{!Element} node
{!Object.} properties
{!function(!string):?string} nsResolver

<inner> mapObjOntoNode(node, properties, nsResolver)
Maps attributes and elements in the properties object over top of the node. Supports recursion and deep mapping. Supported value types are: - string (mapped to an attribute string on node) - number (mapped to an attribute string on node) - object (deep mapped to a new child node on node)
Parameters:
{!Element} node
{!Object.} properties
{!function(!string):?string} nsResolver

<inner> {!number} maximumOffset(node)
Returns the maximum available offset for the node. If this is a text node, this will be node.length, or for an element node, childNodes.length
Parameters:
{!Node} node
Returns:
{!number}

<inner> {!Node} mergeIntoParent(targetNode)
Merge all child nodes into the targetNode's parent and remove the targetNode entirely
Parameters:
{!Node} targetNode
Returns:
{!Node} parent of targetNode

<inner> {?Node} mergeTextNodes(node, nextNode)
Merges the content of node with nextNode. If node is an empty text node, it will be removed in any case. If nextNode is an empty text node, it will be only removed if node is a text node.
Parameters:
{!Node} node
{!Node} nextNode
Returns:
{?Node} merged text node or null if there is no text node as result

<inner> {!Node} moveToNonRejectedNode(walker, root, nodeFilter)
Checks all nodes between the tree walker's current node and the defined root. If any nodes are rejected, the tree walker is moved to the highest rejected node below the root. Note, the root is excluded from this check. This logic is similar to PositionIterator.moveToAcceptedNode
Parameters:
{!TreeWalker} walker
{!Node} root
{!function(!Node) : number} nodeFilter
Returns:
{!Node} Returns the current node the walker is on

<inner> {undefined} normalizeTextNodes(node)
Attempts to normalize the node with any surrounding text nodes. No actions are performed if the node is undefined, has no siblings, or is not a text node
Parameters:
{Node} node
Returns:
{undefined}

<inner> {boolean} rangeContainsNode(limits, node)
Checks if the provided limits fully encompass the passed in node
Parameters:
{!Range|{startContainer: Node|startOffset: !number|endContainer: Node|endOffset: !number}} limits
{!Node} node
Returns:
{boolean} Returns true if the node is fully contained within the range

<inner> {!Range|undefined} rangeIntersection(range1, range2)
Returns the intersection of two ranges. If there is no intersection, this will return undefined.
Parameters:
{!Range} range1
{!Range} range2
Returns:
{!Range|undefined}

<inner> {boolean} rangesIntersect(range1, range2)
Returns true if there is any intersection between range1 and range2
Parameters:
{!Range} range1
{!Range} range2
Returns:
{boolean}

{undefined} removeAllChildNodes(node)
Removes all child nodes from the given node. To be used instead of e.g. `node.innerHTML = "";`
Parameters:
{!Node} node
Returns:
{undefined}

<inner> removeKeyElementsFromNode(node, propertyNames, nsResolver)
Takes an array of strings, which is a listing of properties to be removed (namespace required), and deletes the corresponding top-level child elements that represent those properties, from the supplied node. Example: removeKeyElementsFromNode(node, ["dc:creator"], nsResolver); If a namespace is not resolved with the nsResolver, that key element will be not removed. If a key element does not exist, it will be ignored.
Parameters:
{!Element} node
{!Array.} propertyNames
{!function(!string):?string} nsResolver

<inner> {?Node} removeUnwantedNodes(targetNode, nodeFilter)
Removes all unwanted nodes from targetNode includes itself. The nodeFilter defines which nodes should be removed (NodeFilter.FILTER_REJECT), should be skipped including the subtree (NodeFilter.FILTER_SKIP) or should be kept and their subtree checked further (NodeFilter.FILTER_ACCEPT).
Parameters:
{!Node} targetNode
{!function(!Node) : !number} nodeFilter
Returns:
{?Node} parent of targetNode

<inner> {!Array.} splitBoundaries(range)
If either the start or end boundaries of a range start within a text node, this function will split these text nodes and reset the range boundaries to select the new nodes. The end result is that there are no partially contained text nodes within the resulting range. E.g., the text node with selection: "A|BCD|E" would be split into 3 text nodes, with the range modified to maintain only the completely selected text node: "A" "|BCD|" "E"
Parameters:
{!Range} range
Returns:
{!Array.} Return a list of nodes modified as a result of this split operation. These are often processed through DomUtils.normalizeTextNodes after all processing has been complete.

{!ClientRect|{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} translateRect(child, parent, zoomLevel)
Translate a given child client rectangle to be relative to the parent's rectangle. Adapt to the provided zoom level as per adaptRangeDifferenceToZoomLevel. IMPORTANT: due to browser quirks, any element bounding client rect used with this function MUST be retrieved using DomUtils.getBoundingClientRect.
Parameters:
{!ClientRect|!Object.} child
{!ClientRect|!Object.} parent
{!number} zoomLevel
Returns:
{!ClientRect|{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}}

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Aug 06 2015 04:10:39 GMT+0200 (MESZ)