Class: InputHandler

InputHandler

new InputHandler(element, opt_multi)

This class is heavily based on goog.ui.ac.InputHandler to provide the SelectionHandler interface required by goog.ui.ac.AutoComplete. It differs in a few ways, chief amongst them that it only supports a single input element instead of multiple ones. Thus, there's no juggling between active elements :) It also only uses a timer to monitor the input if the user non-left-clicked on the input, e.g. to paste text. The monitoring stops as soon as the user left clicks or types a character. We also removed the tight coupling to the goog.ui.ac.AutoComplete component, by dispatching events from here, rather than keeping a reference to the autocomplete component. Finally, we maintain a map of input entries to their server objects, in case the server returned an object instead of simple strings
Parameters:
Name Type Argument Description
element HTMLInputElement The input element to use with the autocomplete control
opt_multi boolean <optional>
<nullable>
Whether to allow multiple entries (Default: false)
Source:

Extends

  • goog.events.EventTarget

Members

<static> EventType :string

List of events dispatched by this class
Type:
  • string
Properties:
Name Type Description
TEXT_CHANGED string the event dispatched if the input text changed. Could be as a result of keypresses, or by pasting text
DISMISS string the event dispatched if the input element looses focus and we should dimiss the autocomplete
SELECT_HIGHLIGHTED string the event dispatched if a match was selected and the autocomplete model needs updating
Source:

<static, constant> STANDARD_LIST_SEPARATORS :string

Standard list separators.
Type:
  • string
Source:

Methods

areStringsEqual(str1, str2) → {boolean}

This function checks if two strings are equal with the current setting for case sensitive behaviour
Parameters:
Name Type Description
str1 string The string to compare
str2 string The string to compare str1 to
Source:
Returns:
Type
boolean

disposeInternal()

Cleanup.
Source:

getCaseInsensitive() → {boolean}

Getter for the flag whether this component handles strings case-insensitive
Source:
Returns:
Type
boolean

getCurrentToken() → {string}

This function returns the current token (trimmed) at the position of the cursor
Source:
Returns:
Type
string

getCurrentTokenIndex(entries) → {number}

This function returns the index of the token the current cursor is at in the input. For multi-token inputs, this is the index of the array that corresponds to the token in which the current cursor is at. For non-multi token inputs this returns -1. If the cursor is after the last word in the input, it returns the index of the last item
Parameters:
Name Type Description
entries Array.<string> The list of tokens entered, split by the default delimiters
Source:
Returns:
Type
number

getEntries() → {Array.<string>}

This function returns an array of tokens in the text input
Source:
Returns:
Type
Array.<string>

getInput() → {HTMLInputElement}

Getter for the HTML input element
Source:
Returns:
Type
HTMLInputElement

getMatchedObjects() → {Array.<(Object|string)>}

This function returns a copy of the list of matched server objects
Source:
Returns:
Type
Array.<(Object|string)>

getValue() → {string}

This function returns the value of the text input
Source:
Returns:
Type
string

selectRow(row)

This function implements the seletionhandler interface. It updates the input value based on the value of the selected row.
Parameters:
Name Type Description
row plana.ui.ac.RemoteObject
Source:

setCaseInsensitive(newValue)

This function sets whether string comparisons in this class are case-insensitive
Parameters:
Name Type Description
newValue boolean Whether we should ignore case for strings
Source:

setMatchedObjects(matches)

This function initializes the input with a set of matched objects
Parameters:
Name Type Description
matches Array.<(Object|string)>
Source:

setSeparator(separators, opt_defaultSeparator)

Setter for the separator characters to use for multi-token inputs
Parameters:
Name Type Argument Description
separators string The list of separator characters used to split tokens in the input
opt_defaultSeparator string <optional>
The default character to use during autocomplete events, i.e. the character that is appended by default when a user selects a match
Source:

setSeparatorCompletes(newValue)

Sets whether separators perform autocomplete.
Parameters:
Name Type Description
newValue boolean Whether to autocomplete on separators.
Source:

setSeparatorSelects(newValue)

Sets whether separators perform autocomplete.
Parameters:
Name Type Description
newValue boolean Whether to autocomplete on separators.
Source:

setUpdateInterval(interval)

Setter for chaning the interval when checking for changes to the input that were not handled by the keyhandler
Parameters:
Name Type Description
interval number The value to set
Source:

update(opt_force)

This function implements the seletionhandler interface. It dispatches a change notification to the autocomplete, which in turns updates the token
Parameters:
Name Type Argument Description
opt_force boolean <optional>
Whether we should force sending an update to set the token
Source: