Created
November 21, 2010 07:31
-
-
Save rgrove/708539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Default resultListLocator used when a string-based YQL source is set and | |
* the implementer hasn't already specified one. | |
* | |
* @method _defaultYQLLocator | |
* @param {Object} response YQL response object. | |
* @return {Array} | |
* @protected | |
* @for AutoCompleteBase | |
*/ | |
_defaultYQLLocator: function (response) { | |
var results = response && response.query && response.query.results, | |
values; | |
if (results && Lang.isObject(results)) { | |
// If there's only a single value on YQL's results object, that | |
// value almost certainly contains the array of results we want. If | |
// there are 0 or 2+ values, then the values themselves are most | |
// likely the results we want. | |
values = Y.Object.values(results) || []; | |
results = values.length === 1 ? values[0] : values; | |
if (!Lang.isArray(results)) { | |
results = [results]; | |
} | |
} else { | |
results = []; | |
} | |
return results; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment