The goog.dom.ControlRange Class

goog.dom.ControlRange
> goog.dom.AbstractMultiRange
> goog.dom.AbstractRange

goog.dom.ControlRange()

Create a new control selection with no properties. Do not use this constructor: use one of the goog.dom.Range.createFrom* methods instead.

.__iterator__()

.clone()

.collapse()

.containsNode(node, opt_allowPartial)

Inherited from goog.dom.AbstractRange .

Tests if this range contains the given node.

node {Node}
The node to test for.
opt_allowPartial {boolean=}
If not set or false, the node must be entirely contained in the selection for this function to return true.
returns {boolean}
Whether this range contains the given node.

.containsRange(range, opt_allowPartial)

Inherited from goog.dom.AbstractMultiRange .

Tests if this range contains the given range.

range {goog.dom.AbstractRange}
The range to test.
opt_allowPartial {boolean=}
If true, the range can be partially contained in the selection, otherwise the range must be entirely contained.
returns {boolean}
Whether this range contains the given range.

.createFromBrowserRange(controlRange)

Create a new range wrapper from the given browser range object. Do not use this method directly - please use goog.dom.Range.createFrom* instead.

controlRange {Object}
The browser range object.
returns {goog.dom.ControlRange}
A range wrapper object.

.createFromElements(var_args)

Create a new range wrapper that selects the given element. Do not use this method directly - please use goog.dom.Range.createFrom* instead.

var_args {...Element}
The element(s) to select.
returns {goog.dom.ControlRange}
A range wrapper object.

.getAnchorNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range is anchored at.

.getAnchorOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range is anchored at. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getBrowserRangeObject()

.getContainer()

.getContainerElement()

Inherited from goog.dom.AbstractRange .

Returns the deepest element in the tree that contains the entire range.

returns {Element}
The deepest element that contains the entire range.

.getDocument()

Inherited from goog.dom.AbstractRange .

returns {Document}
The document this selection is a part of.

.getElements()

returns {Array.<Element>}
Array of elements in the control range.

.getEndNode()

.getEndOffset()

.getFocusNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range is focused at - i.e. where the cursor is.

.getFocusOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range is focused at - i.e. where the cursor is. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getHtmlFragment()

.getPastableHtml

.getSortedElements()

returns {Array.<Element>}
Array of elements comprising the control range, sorted by document order.

.getStartNode()

.getStartOffset()

.getText()

.getTextRange()

.getTextRangeCount()

.getTextRanges()

Inherited from goog.dom.AbstractRange .

Gets an array of all text ranges this range is comprised of. For non-multi ranges, returns a single element array containing this.

returns {Array.<goog.dom.TextRange>}
Array of text ranges.

.getType()

.getValidHtml()

.getWindow()

Inherited from goog.dom.AbstractRange .

returns {Window}
The window this selection is a part of.

.insertNode(node, before)

Inherited from goog.dom.AbstractMultiRange .

Inserts a node before (or after) the range. The range may be disrupted beyond recovery because of the way this splits nodes.

node {Node}
The node to insert.
before {boolean}
True to insert before, false to insert after.
returns {Node}
The node added to the document. This may be different than the node parameter because on IE we have to clone it.

.isCollapsed()

.isRangeInDocument()

.isReversed()

Inherited from goog.dom.AbstractRange .

returns {boolean}
Whether the selection is reversed.

.removeContents()

.replaceContentsWithNode()

.saveUsingCarets()

Inherited from goog.dom.AbstractRange .

Saves the range using HTML carets. As long as the carets remained in the HTML, the range can be restored...even when the HTML is copied across documents.

returns {goog.dom.SavedCaretRange?}
A range representation that can be restored as long as carets are not removed. Returns null if carets could not be created.

.saveUsingDom()

.select()

.setBrowserRangeObject()

.surroundWithNodes(startNode, endNode)

Inherited from goog.dom.AbstractMultiRange .

Surrounds this range with the two given nodes. The range may be disrupted beyond recovery because of the way this splits nodes.

startNode {Element}
The node to insert at the start.
endNode {Element}
The node to insert at the end.