The goog.dom.browserrange.OperaRange Class

goog.dom.browserrange.OperaRange
> goog.dom.browserrange.W3cRange
> goog.dom.browserrange.AbstractRange

goog.dom.browserrange.OperaRange(range)

The constructor for Opera specific browser ranges.

range {Range}
The range object.

.__iterator__(opt_keys)

Inherited from goog.dom.browserrange.AbstractRange .

Returns a RangeIterator over the contents of the range. Regardless of the direction of the range, the iterator will move in document order.

opt_keys {boolean=}
Unused for this iterator.
returns {goog.dom.RangeIterator}
An iterator over tags in the range.

.clone()

Inherited from goog.dom.browserrange.W3cRange .

returns {goog.dom.browserrange.W3cRange}
A clone of this range.

.collapse(toStart)

Inherited from goog.dom.browserrange.W3cRange .

Collapses the range to one of its boundary points.

toStart {boolean}
Whether to collapse to the start of the range.

.compareBrowserRangeEndpoints(range, thisEndpoint, otherEndpoint)

Inherited from goog.dom.browserrange.W3cRange .

Compares one endpoint of this range with the endpoint of another browser native range object.

range {Range|TextRange}
The browser native range to compare against.
thisEndpoint {goog.dom.RangeEndpoint}
The endpoint of this range to compare with.
otherEndpoint {goog.dom.RangeEndpoint}
The endpoint of the other range to compare with.
returns {number}
0 if the endpoints are equal, negative if this range endpoint comes before the other range endpoint, and positive otherwise.

.containsNode(node, opt_allowPartial)

Inherited from goog.dom.browserrange.AbstractRange .

Tests if this range contains the given node.

node {Node}
The node to test.
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(abstractRange, opt_allowPartial)

Inherited from goog.dom.browserrange.AbstractRange .

Tests if this range contains the given range.

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

.createFromNodeContents(node)

Creates a range object that selects the given node's text.

node {Node}
The node to select.
returns {goog.dom.browserrange.OperaRange}
A Opera range wrapper object.

.createFromNodes(startNode, startOffset, endNode, endOffset)

Creates a range object that selects between the given nodes.

startNode {Node}
The node to start with.
startOffset {number}
The offset within the node to start.
endNode {Node}
The node to end with.
endOffset {number}
The offset within the node to end.
returns {goog.dom.browserrange.OperaRange}
A wrapper object.

.getBrowserRange()

Inherited from goog.dom.browserrange.W3cRange .

Returns the browser native implementation of the range. Please refrain from using this function - if you find you need the range please add wrappers for the functionality you need rather than just using the native range.

returns {Range|TextRange}
The browser native range object.

.getContainer()

Inherited from goog.dom.browserrange.W3cRange .

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

returns {Node}
The deepest node that contains the entire range.

.getEndNode()

Inherited from goog.dom.browserrange.W3cRange .

Returns the node the range ends in.

returns {Node}
The element or text node the range ends in.

.getEndOffset()

Inherited from goog.dom.browserrange.W3cRange .

Returns the offset into the node the range ends in.

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

.getHtmlFragment()

Inherited from goog.dom.browserrange.AbstractRange .

Returns the HTML fragment this range selects. This is slow on all browsers.

returns {string}
HTML fragment of the range, does not include context containing elements.

.getStartNode()

Inherited from goog.dom.browserrange.W3cRange .

Returns the node the range starts in.

returns {Node}
The element or text node the range starts in.

.getStartOffset()

Inherited from goog.dom.browserrange.W3cRange .

Returns the offset into the node the range starts in.

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

.getText()

Inherited from goog.dom.browserrange.W3cRange .

returns {string}
The text content of the range.

.getValidHtml()

Inherited from goog.dom.browserrange.W3cRange .

Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.

returns {string}
Valid HTML of the range, including context containing elements.

.insertNode(node, before)

Inherited from goog.dom.browserrange.W3cRange .

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()

Inherited from goog.dom.browserrange.W3cRange .

Tests if the selection is collapsed - i.e. is just a caret.

returns {boolean}
Whether the range is collapsed.

.removeContents()

Inherited from goog.dom.browserrange.W3cRange .

Removes the contents of the range from the document. As a side effect, the selection will be collapsed. The behavior of content removal is normalized across browsers. For instance, IE sometimes creates extra text nodes that a W3C browser does not. That behavior is corrected for.

.select(opt_reverse)

Inherited from goog.dom.browserrange.W3cRange .

Set this range as the selection in its window.

opt_reverse {boolean=}
Whether to select the range in reverse, if possible.

.surroundContents(element)

Inherited from goog.dom.browserrange.W3cRange .

Surrounds the text range with the specified element (on Mozilla) or with a clone of the specified element (on IE). Returns a reference to the surrounding element if the operation was successful; returns null if the operation failed.

element {Element}
The element with which the selection is to be surrounded.
returns {Element}
The surrounding element (same as the argument on Mozilla, but not on IE), or null if unsuccessful.

.surroundWithNodes(startNode, endNode)

Inherited from goog.dom.browserrange.W3cRange .

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.