autocomplete-sources-debug.js revision 753ef90e92d428310b4a07006e8850639c6faaad
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Mixes support for JSONP and YQL result sources into AutoCompleteBase.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * @module autocomplete
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * @submodule autocomplete-sources
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync// Add prototype properties and methods to AutoCompleteBase.
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync * Regular expression used to determine whether a String source is a YQL
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync * @property _YQL_SOURCE_REGEX
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync * @type RegExp
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * @protected
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * @for AutoCompleteBase
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * Runs before AutoCompleteBase's <code>_createObjectSource()</code> method
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * and augments it to support additional object-based source types.
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * @method _beforeCreateObjectSource
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * @param {String} source
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync * @protected
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * @for AutoCompleteBase
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync // If the object is a <select> node, use the options as the result
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync source.get('nodeName').toLowerCase() === 'select') {
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync // If the object is a JSONPRequest instance, try to use it as a JSONP
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync if (Y.JSONPRequest && source instanceof Y.JSONPRequest) {
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync // Fall back to a basic object source.
80096fb54d147045204dcc7e3ff273158de03f81vboxsync * Creates a DataSource-like object that uses <code>Y.io</code> as a source.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * See the <code>source</code> attribute for more details.
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync * @method _createIOSource
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync * @param {String} source URL.
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync * @return {Object} DataSource-like object.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @protected
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @for AutoCompleteBase
2043260aa6abeee8eb8cf0309cebb97ede45851evboxsync // Private internal _sendRequest method that will be assigned to
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync // ioSource.sendRequest once io-base and json-parse are available.
2043260aa6abeee8eb8cf0309cebb97ede45851evboxsync // Return immediately on a cached response.
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // Cancel any outstanding requests.
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync } catch (ex) {
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // Keep track of the most recent request in case there are multiple
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // requests while we're waiting for the IO module to load. Only the
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // most recent request will be sent.
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync if (loading) { return; }
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // Lazy-load the io-base and json-parse modules if necessary,
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // then overwrite the sendRequest method to bypass this check in
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync // the future.
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync * Creates a DataSource-like object that uses the specified JSONPRequest
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync * instance as a source. See the <code>source</code> attribute for more
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @method _createJSONPSource
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync * @param {JSONPRequest|String} source URL string or JSONPRequest instance.
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync * @return {Object} DataSource-like object.
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync * @protected
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync * @for AutoCompleteBase
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // Hack alert: JSONPRequest currently doesn't support
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // per-request callbacks, so we're reaching into the protected
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // _config object to make it happen.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // This limitation is mentioned in the following JSONP
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // enhancement ticket:
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // http://yuilibrary.com/projects/yui3/ticket/2529371
a4ab203fe0f52099fa53f52758e83d06f470ac04vboxsync // Keep track of the most recent request in case there are multiple
74959ba85f2898a152aed46b41cfe908638f2420vboxsync // requests while we're waiting for the JSONP module to load. Only
74959ba85f2898a152aed46b41cfe908638f2420vboxsync // the most recent request will be sent.
d2c66e0925a76b3636d86b2afb2487fd6f956aebvboxsync if (loading) { return; }
2043260aa6abeee8eb8cf0309cebb97ede45851evboxsync // Lazy-load the JSONP module if necessary, then overwrite the
2043260aa6abeee8eb8cf0309cebb97ede45851evboxsync // sendRequest method to bypass this check in the future.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // Turn the source into a JSONPRequest instance if it isn't
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // one already.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Creates a DataSource-like object that uses the specified <select>
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * node as a source.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @method _createSelectSource
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @param {Node} source YUI Node instance wrapping a <select> node.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @return {Object} DataSource-like object.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @protected
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @for AutoCompleteBase
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync var that = this;
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Creates a DataSource-like object that calls the specified URL or
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * executes the specified YQL query for results. If the string starts
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * with "select ", "use ", or "set " (case-insensitive), it's assumed to be
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * a YQL query; otherwise, it's assumed to be a URL (which may be absolute
b1ae8b1c40ec6bb82e7984b72712df5661332e2cvboxsync * or relative). URLs containing a "{callback}" placeholder are assumed to
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * be JSONP URLs; all others will use XHR. See the <code>source</code>
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * attribute for more details.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @method _createStringSource
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @param {String} source URL or YQL query.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @return {Object} DataSource-like object.
6831f283dbc5c27bde8a8f8bea179b84a5741697vboxsync * @protected
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * @for AutoCompleteBase
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync // Looks like a YQL query.
var cache = {},
that = this,
if (yqlRequest) {
if (env) {
if (!loading) {
loading = true;
return yqlSource;
results = [];
return results;
if (requestTemplate) {
if (requestTemplate) {
* Tables environment file (http://datatables.org/alltables.env).
yqlEnv: {
value: null
yqlProtocol: {