selection.js
No description.

File Location

/goog/dom/selection.js


Public Protected Private

Global Functions

goog.dom.selection.canonicalizePositionIe_(textfieldpos) number
Helper function for canonicalizing a position inside a textfield in IE. Deals with the issue that \r\n counts as 2 characters, but move('character', n) passes over both characters in one move.
Arguments:
textfield : Element
The text element.
pos : number
The position desired in that element.
Returns: number  The canonicalized position that will work properly with move('character', pos).
code »
goog.dom.selection.getEnd(textfield) number
Returns the place where the selection ends inside a textarea or a text input
Arguments:
textfield : Element
A textarea or text input.
Returns: number  The position where the selection ends or 0 if it was unable to find the position or no selection exists.
code »
goog.dom.selection.getEndPoints(textfield) !Array.<number>
Returns the start and end points of the selection inside a textarea or a text input.
Arguments:
textfield : Element
A textarea or text input.
Returns: !Array.<number>  An array with the start and end positions where the selection starts and ends or [0,0] if it was unable to find the positions or no selection exists. Note that we can't reliably tell the difference between an element that has no selection and one where it starts and ends at 0.
code »
goog.dom.selection.getEndPointsTextareaIe_(rangeselRangegetOnlyStart) !Array.<number>
Returns the start and end points of the selection within a textarea in IE. IE treats newline characters as \r\n characters, and we need to check for these characters at the edge of our selection, to ensure that we return the right cursor position.
Arguments:
range : TextRange
Complete range object, e.g., "Hello\r\n".
selRange : TextRange
Selected range object.
getOnlyStart : boolean
Value indicating if only start cursor position is to be returned. In IE, obtaining the end position involves extra work, hence we have this parameter for calls which need only start position.
Returns: !Array.<number>  An array with the start and end positions where the selection starts and ends or [0,0] if it was unable to find the positions or no selection exists. Note that we can't reliably tell the difference between an element that has no selection and one where it starts and ends at 0. If getOnlyStart was true, we return -1 as end offset.
code »
goog.dom.selection.getEndPoints_(textfieldgetOnlyStart) !Array.<number>
Returns the start and end points of the selection inside a textarea or a text input.
Arguments:
textfield : Element
A textarea or text input.
getOnlyStart : boolean
Value indicating if only start cursor position is to be returned. In IE, obtaining the end position involves extra work, hence we have this parameter. In FF, there is not much extra effort involved.
Returns: !Array.<number>  An array with the start and end positions where the selection starts and ends or [0,0] if it was unable to find the positions or no selection exists. Note that we can't reliably tell the difference between an element that has no selection and one where it starts and ends at 0. If getOnlyStart was true, we return -1 as end offset.
code »
goog.dom.selection.getRangeIe_(el) !Array.<TextRange>
Helper function for returning the range for an object as well as the selection range
Arguments:
el : Element
The element to get the range for.
Returns: !Array.<TextRange>  Range of object and selection range in two element array.
code »
goog.dom.selection.getSelectionRangeText_(selRange) string
Returns the selected text within a textarea in IE. IE treats newline characters as \r\n characters, and we need to check for these characters at the edge of our selection, to ensure that we return the right string.
Arguments:
selRange : TextRange
Selected range object.
Returns: string  Selected text in the textarea.
code »
goog.dom.selection.getStart(textfield) number
Return the place where the selection starts inside a textarea or a text input
Arguments:
textfield : Element
A textarea or text input.
Returns: number  The position where the selection starts or 0 if it was unable to find the position or no selection exists. Note that we can't reliably tell the difference between an element that has no selection and one where it starts at 0.
code »
goog.dom.selection.getText(textfield) string
Returns the selected text inside a textarea or a text input
Arguments:
textfield : Element
A textarea or text input.
Returns: string  The selected text.
code »
goog.dom.selection.setCursorPosition(textfieldpos)
Sets the cursor position within a textfield.
Arguments:
textfield : Element
A textarea or text input.
pos : number
The position within the text field.
code »
goog.dom.selection.setEnd(textfieldpos)
Sets the place where the selection should end inside a text area or a text input
Arguments:
textfield : Element
A textarea or text input.
pos : number
The position to end the selection at.
code »
goog.dom.selection.setStart(textfieldpos)
Sets the place where the selection should start inside a textarea or a text input
Arguments:
textfield : Element
A textarea or text input.
pos : number
The position to set the start of the selection at.
code »
goog.dom.selection.setText(textfieldtext)
Sets the selected text inside a textarea or a text input
Arguments:
textfield : Element
A textarea or text input.
text : string
The text to change the selection to.
code »
goog.dom.selection.useSelectionProperties_(el) boolean
Helper function to determine whether it's okay to use selectionStart/selectionEnd.
Arguments:
el : Element
The element to check for.
Returns: boolean  Whether it's okay to use the selectionStart and selectionEnd properties on el.
code »

Directory dom

File Reference