autocomplete-base-debug.js revision 221103f45ef4ea2c4caacb9f367f88cac34b8299
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Provides automatic input completion or suggestions for text input fields and
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * textareas.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @module autocomplete
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @main autocomplete
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @since 3.3.0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>Y.Base</code> extension that provides core autocomplete logic (but no
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * UI implementation) for a text input field or textarea. Must be mixed into a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>Y.Base</code>-derived class to be useful.
5ecb8c8b041752f6b716054ff5cfc2c9992365c6Tripp * @submodule autocomplete-base
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Extension that provides core autocomplete logic (but no UI implementation)
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * for a text input field or textarea.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The <code>AutoCompleteBase</code> class provides events and attributes that
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * abstract away core autocomplete logic and configuration, but does not provide
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * a widget implementation or suggestion UI. For a prepackaged autocomplete
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * widget, see <code>AutoCompleteList</code>.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * This extension cannot be instantiated directly, since it doesn't provide an
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * actual implementation. It's intended to be mixed into a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>Y.Base</code>-based class or widget.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>Y.Widget</code>-based example:
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * YUI().use('autocomplete-base', 'widget', function (Y) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * var MyAC = Y.Base.create('myAC', Y.Widget, [Y.AutoCompleteBase], {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * // Custom prototype methods and properties.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * }, {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * // Custom static methods and properties.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * });
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * // Custom implementation code.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>Y.Base</code>-based example:
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * YUI().use('autocomplete-base', function (Y) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * var MyAC = Y.Base.create('myAC', Y.Base, [Y.AutoCompleteBase], {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * initializer: function () {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * this._bindUIACBase();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * this._syncUIACBase();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * // Custom prototype methods and properties.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * }, {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * // Custom static methods and properties.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * });
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * // Custom implementation code.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @class AutoCompleteBase
828c58761d90445b8b9d20a82d85dc1479317f71Tripp YObject = Y.Object,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // AOP bindings.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // -- Public Events --------------------------------------------------------
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Fires after the query has been completely cleared or no longer meets the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * minimum query length requirement.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @event clear
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {EventFacade} e Event facade with the following additional
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * properties:
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>prevVal (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Value of the query before it was cleared.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @preventable _defClearFn
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Fires when the contents of the input field have changed and the input
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * value meets the criteria necessary to generate an autocomplete query.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @event query
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {EventFacade} e Event facade with the following additional
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * properties:
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * <dt>inputValue (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Full contents of the text input field or textarea that generated
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the query.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>query (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Autocomplete query. This is the string that will be used to
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * request completion results. It may or may not be the same as
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>inputValue</code>.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @preventable _defQueryFn
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Fires after query results are received from the <code>source</code>. If
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * no source has been set, this event will not fire.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @event results
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {EventFacade} e Event facade with the following additional
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * properties:
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>data (Array|Object)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Raw, unfiltered result data (if available).
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * <dt>query (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Query that generated these results.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>results (Array)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Array of filtered, formatted, and highlighted results. Each item in
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * the array is an object with the following properties:
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>display (Node|HTMLElement|String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Formatted result HTML suitable for display to the user. If no
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * custom formatter is set, this will be an HTML-escaped version of
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the string in the <code>text</code> property.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * <dt>highlighted (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Highlighted (but not formatted) result text. This property will
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * only be set if a highlighter is in use.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>raw (mixed)</dt>
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Raw, unformatted result in whatever form it was provided by the
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * <code>source</code>.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>text (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Plain text version of the result, suitable for being inserted
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * into the value of a text input field or textarea when the result
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * is selected by a user. This value is not HTML-escaped and should
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * not be inserted into the page using innerHTML.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @preventable _defResultsFn
828c58761d90445b8b9d20a82d85dc1479317f71Tripp// -- Public Static Properties -------------------------------------------------
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Whether or not to enable the browser's built-in autocomplete
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * functionality for input fields.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @attribute allowBrowserAutocomplete
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @type Boolean
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @default false
080b31a43c2a1d068c28eaa3e243bdd6e8a89ffaTripp * When a <code>queryDelimiter</code> is set, trailing delimiters will
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * automatically be stripped from the input value by default when the
080b31a43c2a1d068c28eaa3e243bdd6e8a89ffaTripp * input node loses focus. Set this to <code>true</code> to allow trailing
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * delimiters.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute allowTrailingDelimiter
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Boolean
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @default false
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Node to monitor for changes, which will generate <code>query</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * events when appropriate. May be either an input field or a textarea.
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp * @attribute inputNode
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp * @type Node|HTMLElement|String
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @writeonce
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Maximum number of results to return. A value of <code>0</code> or less
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * will allow an unlimited number of results.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute maxResults
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @default 0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Minimum number of characters that must be entered before a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>query</code> event will be fired. A value of <code>0</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * allows empty queries; a negative value will effectively disable all
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>query</code> events.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute minQueryLength
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @default 1
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Current query, or <code>null</code> if there is no current query.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * The query might not be the same as the current value of the input
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * node, both for timing reasons (due to <code>queryDelay</code>) and
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * because when one or more <code>queryDelimiter</code> separators are
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * in use, only the last portion of the delimited input string will be
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * used as the query value.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @attribute query
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type String|null
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @default null
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @readonly
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Number of milliseconds to delay after input before triggering a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>query</code> event. If new input occurs before this delay is
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * over, the previous input event will be ignored and a new delay will
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * This can be useful both to throttle queries to a remote data source
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * and to avoid distracting the user by showing them less relevant
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp * results before they've paused their typing.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute queryDelay
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Number
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @default 100
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Query delimiter string. When a delimiter is configured, the input value
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * will be split on the delimiter, and only the last portion will be used in
b08d5c81743759d32bccaf4bec55aa102491026eTripp * autocomplete queries and updated when the <code>query</code> attribute is
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * modified.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @attribute queryDelimiter
b08d5c81743759d32bccaf4bec55aa102491026eTripp * @type String|null
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @default null
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Source request template. This can be a function that accepts a query as a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * parameter and returns a request string, or it can be a string containing
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the placeholder "{query}", which will be replaced with the actual
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * URI-encoded query. In either case, the resulting string will be appended
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * to the request URL when the <code>source</code> attribute is set to a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * remote DataSource, JSONP URL, or XHR URL (it will not be appended to YQL
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * While <code>requestTemplate</code> may be set to either a function or
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * a string, it will always be returned as a function that accepts a
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * query argument and returns a string.
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * @attribute requestTemplate
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * @type Function|String|null
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * @default null
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Array of local result filter functions. If provided, each filter
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * will be called with two arguments when results are received: the query
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * and an array of result objects. See the documentation for the
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * <code>results</code> event for a list of the properties available on each
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * result object.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Each filter is expected to return a filtered or modified version of the
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * results array, which will then be passed on to subsequent filters, then
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * the <code>resultHighlighter</code> function (if set), then the
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * <code>resultFormatter</code> function (if set), and finally to
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * subscribers to the <code>results</code> event.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * If no <code>source</code> is set, result filters will not be called.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Prepackaged result filters provided by the autocomplete-filters and
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * autocomplete-filters-accentfold modules can be used by specifying the
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * filter name as a string, such as <code>'phraseMatch'</code> (assuming
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * the necessary filters module is loaded).
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @attribute resultFilters
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @type Array
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @default []
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Function which will be used to format results. If provided, this function
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * will be called with two arguments after results have been received and
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * filtered: the query and an array of result objects. The formatter is
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * expected to return an array of HTML strings or Node instances containing
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * the desired HTML for each result.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * See the documentation for the <code>results</code> event for a list of
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the properties available on each result object.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * If no <code>source</code> is set, the formatter will not be called.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute resultFormatter
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Function|null
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Function which will be used to highlight results. If provided, this
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * function will be called with two arguments after results have been
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * received and filtered: the query and an array of filtered result objects.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The highlighter is expected to return an array of highlighted result
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * text in the form of HTML strings.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * See the documentation for the <code>results</code> event for a list of
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * the properties available on each result object.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * If no <code>source</code> is set, the highlighter will not be called.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @attribute resultHighlighter
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @type Function|null
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * Locator that should be used to extract an array of results from a
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * non-array response.
9cc2c5945426b2b79c0a258026d750be74795924Tripp * By default, no locator is applied, and all responses are assumed to be
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * arrays by default. If all responses are already arrays, you don't need to
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * define a locator.
9cc2c5945426b2b79c0a258026d750be74795924Tripp * The locator may be either a function (which will receive the raw response
9cc2c5945426b2b79c0a258026d750be74795924Tripp * as an argument and must return an array) or a string representing an
9cc2c5945426b2b79c0a258026d750be74795924Tripp * object path, such as "foo.bar.baz" (which would return the value of
9cc2c5945426b2b79c0a258026d750be74795924Tripp * <code>result.foo.bar.baz</code> if the response is an object).
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * While <code>resultListLocator</code> may be set to either a function or a
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * string, it will always be returned as a function that accepts a response
9cc2c5945426b2b79c0a258026d750be74795924Tripp * argument and returns an array.
9cc2c5945426b2b79c0a258026d750be74795924Tripp * @attribute resultListLocator
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Function|String|null
9cc2c5945426b2b79c0a258026d750be74795924Tripp * Current results, or an empty array if there are no results.
9cc2c5945426b2b79c0a258026d750be74795924Tripp * @attribute results
9cc2c5945426b2b79c0a258026d750be74795924Tripp * @type Array
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @default []
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @readonly
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Locator that should be used to extract a plain text string from a
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * non-string result item. The resulting text value will typically be the
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * value that ends up being inserted into an input field or textarea when
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * the user of an autocomplete implementation selects a result.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * By default, no locator is applied, and all results are assumed to be
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * plain text strings. If all results are already plain text strings, you
9cc2c5945426b2b79c0a258026d750be74795924Tripp * don't need to define a locator.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The locator may be either a function (which will receive the raw result
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * as an argument and must return a string) or a string representing an
9cc2c5945426b2b79c0a258026d750be74795924Tripp * object path, such as "foo.bar.baz" (which would return the value of
9cc2c5945426b2b79c0a258026d750be74795924Tripp * <code>result.foo.bar.baz</code> if the result is an object).
9cc2c5945426b2b79c0a258026d750be74795924Tripp * While <code>resultTextLocator</code> may be set to either a function or a
9cc2c5945426b2b79c0a258026d750be74795924Tripp * string, it will always be returned as a function that accepts a result
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * argument and returns a string.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute resultTextLocator
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @type Function|String|null
9cc2c5945426b2b79c0a258026d750be74795924Tripp * Source for autocomplete results. The following source types are
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * supported:
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * <dt>Array</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <i>Example:</i> <code>['first result', 'second result', 'etc']</code>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The full array will be provided to any configured filters for each
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * query. This is an easy way to create a fully client-side autocomplete
9cc2c5945426b2b79c0a258026d750be74795924Tripp * implementation.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>DataSource</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * A <code>DataSource</code> instance or other object that provides a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * DataSource-like <code>sendRequest</code> method. See the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>DataSource</code> documentation for details.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>Function</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <i>Example (synchronous):</i> <code>function (query) { return ['foo', 'bar']; }</code><br>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp <i>Example (async):</i> <code>function (query, callback) { callback(['foo', 'bar']); }</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * A function source will be called with the current query and a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * callback function as parameters, and should either return an array of
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * results (for synchronous operation) or return nothing and pass an
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * array of results to the provided callback (for asynchronous
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * operation).
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>Object</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <i>Example:</i> <code>{foo: ['foo result 1', 'foo result 2'], bar: ['bar result']}</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * An object will be treated as a query hashmap. If a property on the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * object matches the current query, the value of that property will be
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * used as the response.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The response is assumed to be an array of results by default. If the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * response is not an array, provide a <code>resultListLocator</code> to
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * process the response and return an array.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * If the optional <code>autocomplete-sources</code> module is loaded, then
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * the following additional source types will be supported as well:
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt><select> Node</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * You may provide a YUI Node instance wrapping a <select>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * element, and the options in the list will be used as results. You
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * will also need to specify a <code>resultTextLocator</code> of 'text'
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * or 'value', depending on what you want to use as the text of the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Each result will be an object with the following properties:
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <dt>html (String)</dt>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <p>HTML content of the <option> element.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>index (Number)</dt>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <p>Index of the <option> element in the list.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>node (Y.Node)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <p>Node instance referring to the original <option> element.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>selected (Boolean)</dt>
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * <p>Whether or not this item is currently selected in the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <select> list.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>text (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <p>Text content of the <option> element.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>value (String)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <p>Value of the <option> element.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>String (JSONP URL)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <i>Example:</i> <code>'http://example.com/search?q={query}&callback={callback}'</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * If a URL with a <code>{callback}</code> placeholder is provided, it
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * will be used to make a JSONP request. The <code>{query}</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * placeholder will be replaced with the current query, and the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>{callback}</code> placeholder will be replaced with an
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * internally-generated JSONP callback name. Both placeholders must
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * appear in the URL, or the request will fail. An optional
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>{maxResults}</code> placeholder may also be provided, and will
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * be replaced with the value of the maxResults attribute (or 1000 if
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the maxResults attribute is 0 or less).
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The response is assumed to be an array of results by default. If the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * response is not an array, provide a <code>resultListLocator</code> to
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * process the response and return an array.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <strong>The <code>jsonp</code> module must be loaded in order for
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * JSONP URL sources to work.</strong> If the <code>jsonp</code> module
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * is not already loaded, it will be loaded on demand if possible.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>String (XHR URL)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <i>Example:</i> <code>'http://example.com/search?q={query}'</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * If a URL without a <code>{callback}</code> placeholder is provided,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * it will be used to make a same-origin XHR request. The
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>{query}</code> placeholder will be replaced with the current
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * query. An optional <code>{maxResults}</code> placeholder may also be
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * provided, and will be replaced with the value of the maxResults
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * attribute (or 1000 if the maxResults attribute is 0 or less).
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The response is assumed to be a JSON array of results by default. If
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the response is a JSON object and not an array, provide a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>resultListLocator</code> to process the response and return an
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * array. If the response is in some form other than JSON, you will
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * need to use a custom DataSource instance as the source.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <strong>The <code>io-base</code> and <code>json-parse</code> modules
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * must be loaded in order for XHR URL sources to work.</strong> If
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * these modules are not already loaded, they will be loaded on demand
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * if possible.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>String (YQL query)</dt>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <i>Example:</i> <code>'select * from search.suggest where query="{query}"'</code>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * If a YQL query is provided, it will be used to make a YQL request.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The <code>{query}</code> placeholder will be replaced with the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * current autocomplete query. This placeholder must appear in the YQL
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * query, or the request will fail. An optional
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <code>{maxResults}</code> placeholder may also be provided, and will
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * be replaced with the value of the maxResults attribute (or 1000 if
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * the maxResults attribute is 0 or less).
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <strong>The <code>yql</code> module must be loaded in order for YQL
a89ad754cce3cfc8aee71760e10217b54020360dTripp * sources to work.</strong> If the <code>yql</code> module is not
a89ad754cce3cfc8aee71760e10217b54020360dTripp * already loaded, it will be loaded on demand if possible.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * As an alternative to providing a source, you could simply listen for
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp * <code>query</code> events and handle them any way you see fit. Providing
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp * a source is optional, but will usually be simpler.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @attribute source
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @type Array|DataSource|Function|Node|Object|String|null
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * May be used to force a specific source type, overriding the automatic
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * source type detection. It should almost never be necessary to do this,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * but as they taught us in the Boy Scouts, one should always be prepared,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * so it's here if you need it. Be warned that if you set this attribute and
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * something breaks, it's your own fault.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Supported <code>sourceType</code> values are: 'array', 'datasource',
a89ad754cce3cfc8aee71760e10217b54020360dTripp * 'function', and 'object'.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * If the <code>autocomplete-sources</code> module is loaded, the following
a89ad754cce3cfc8aee71760e10217b54020360dTripp * additional source types are supported: 'io', 'jsonp', 'select',
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * 'string', 'yql'
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @attribute sourceType
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type String
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * If the <code>inputNode</code> specified at instantiation time has a
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <code>node-tokeninput</code> plugin attached to it, this attribute will
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * be a reference to the <code>Y.Plugin.TokenInput</code> instance.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @attribute tokenInput
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Plugin.TokenInput
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @readonly
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Current value of the input node.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @attribute value
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type String
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @default ''
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // Why duplicate this._inputNode.get('value')? Because we need a
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // reliable way to track the source of value changes. We want to perform
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // completion when the user changes the value, but not when we change
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // the value.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippAutoCompleteBase.UI_SRC = (Y.Widget && Y.Widget.UI_SRC) || 'ui';
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Mapping of built-in source types to their setter functions. DataSource
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * instances and DataSource-like objects are handled natively, so are not
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * mapped here.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property SOURCE_TYPES
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type {Object}
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // -- Public Prototype Methods ---------------------------------------------
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Sends a request to the configured source. If no source is configured,
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * this method won't do anything.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Usually there's no reason to call this method manually; it will be
a89ad754cce3cfc8aee71760e10217b54020360dTripp * called automatically when user input causes a <code>query</code> event to
a89ad754cce3cfc8aee71760e10217b54020360dTripp * be fired. The only time you'll need to call this method manually is if
a89ad754cce3cfc8aee71760e10217b54020360dTripp * you want to force a request to be sent when no user input has occurred.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method sendRequest
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @param {String} query (optional) Query to send. If specified, the
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <code>query</code> attribute will be set to this query. If not
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * specified, the current value of the <code>query</code> attribute will
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Function} requestTemplate (optional) Request template function.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * If not specified, the current value of the <code>requestTemplate</code>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * attribute will be used.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @chainable
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp Y.log('sendRequest: ' + request, 'info', 'autocomplete-base');
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp return this;
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp // -- Protected Lifecycle Methods ------------------------------------------
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * Attaches event listeners and behaviors.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method _bindUIACBase
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * @protected
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp _bindUIACBase: function () {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // If the inputNode has a node-tokeninput plugin attached, bind to the
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp // plugin's inputNode instead.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // This is the valueChange event on the inputNode, provided by the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // event-valuechange module, not our own valueChange.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp inputNode.on(VALUE_CHANGE, this._onInputValueChange, this),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.after(ALLOW_BROWSER_AC + 'Change', this._syncBrowserAutocomplete),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.after('sourceTypeChange', this._afterSourceTypeChange),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Detaches AutoCompleteBase event listeners.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _destructorACBase
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @protected
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _destructorACBase: function () {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Synchronizes the UI state of the <code>inputNode</code>.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _syncUIACBase
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @protected
c093c1aed867e18aa4778708592e1ceb45d18cffTripp _syncUIACBase: function () {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // -- Protected Prototype Methods ------------------------------------------
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Creates a DataSource-like object that simply returns the specified array
e7c7565d9550eaa87043aef0df77125ada996deaTripp * as a response. See the <code>source</code> attribute for more details.
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @method _createArraySource
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Array} source
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return {Object} DataSource-like object.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @protected
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var that = this;
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Creates a DataSource-like object that passes the query to a
e7c7565d9550eaa87043aef0df77125ada996deaTripp * custom-defined function, which is expected to call the provided callback
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * with an array of results. See the <code>source</code> attribute for more
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _createFunctionSource
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Function} source Function that accepts a query and a callback as
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * parameters, and calls the callback with an array of results.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return {Object} DataSource-like object.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @protected
c093c1aed867e18aa4778708592e1ceb45d18cffTripp var that = this;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Allow both synchronous and asynchronous functions. If we get
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // a truthy return value, assume the function is synchronous.
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Creates a DataSource-like object that looks up queries as properties on
e7c7565d9550eaa87043aef0df77125ada996deaTripp * the specified object, and returns the found value (if any) as a response.
e7c7565d9550eaa87043aef0df77125ada996deaTripp * See the <code>source</code> attribute for more details.
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @method _createObjectSource
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @param {Object} source
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @return {Object} DataSource-like object.
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @protected
e7c7565d9550eaa87043aef0df77125ada996deaTripp var that = this;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Returns <code>true</code> if <i>value</i> is either a function or
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <code>null</code>.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _functionValidator
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Function|null} value Value to validate.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @protected
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Faster and safer alternative to Y.Object.getValue(). Doesn't bother
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * casting the path to an array (since we already know it's an array) and
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * doesn't throw an error if a value in the middle of the object hierarchy
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * is neither <code>undefined</code> nor an object.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _getObjectValue
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Object} obj
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Array} path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return {mixed} Located value, or <code>undefined</code> if the value was
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * not found at the specified path.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @protected
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for (var i = 0, len = path.length; obj && i < len; i++) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Parses result responses, performs filtering and highlighting, and fires
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * the <code>results</code> event.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _parseResponse
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} query Query that generated these results.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Object} response Response containing results.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Object} data Raw response data.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @protected
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Create a lightweight result object for each result to make them
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // easier to work with. The various properties on the object
if (!results) {
if (highlighter) {
if (!highlighted) {
if (formatter) {
if (!formatted) {
if (delim) {
return locator;
var that = this;
return function (result) {
return template;
return function (query) {
if (filters === null) {
return filter;
var acHighlighters;
return highlighter;
return INVALID_VALUE;
|| source === null
return source;
return INVALID_VALUE;
_syncBrowserAutocomplete: function () {
len,
if (delim) {
_afterSourceTypeChange: function (e) {
if (this._rawSource) {
_afterValueChange: function (e) {
var delay,
fire,
that;
that = this;
fire = function () {
if (delay) {
fire();
_onInputBlur: function (e) {
if (delim) {
_onInputValueChange: function (e) {
_defClearFn: function () {
_defQueryFn: function (e) {
_defResultsFn: function (e) {