diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/build/datasource-get/datasource-get-debug.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/build/datasource-get/datasource-get-debug.js Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,220 @@ +/* +YUI 3.10.3 (build 2fb5187) +Copyright 2013 Yahoo! Inc. All rights reserved. +Licensed under the BSD License. +http://yuilibrary.com/license/ +*/ + +YUI.add('datasource-get', function (Y, NAME) { + +/** + * Provides a DataSource implementation which can be used to retrieve data via the Get Utility. + * + * @module datasource + * @submodule datasource-get + */ + +/** + * Get Utility subclass for the DataSource Utility. + * @class DataSource.Get + * @extends DataSource.Local + * @constructor + */ +var DSGet = function() { + DSGet.superclass.constructor.apply(this, arguments); +}; + + +Y.DataSource.Get = Y.extend(DSGet, Y.DataSource.Local, { + /** + * Passes query string to Get Utility. Fires response event when + * response is received asynchronously. + * + * @method _defRequestFn + * @param e {Event.Facade} Event Facade with the following properties: + *
+ *
tId (Number)
Unique transaction ID.
+ *
request (Object)
The request.
+ *
callback (Object)
The callback object with the following properties: + *
+ *
success (Function)
Success handler.
+ *
failure (Function)
Failure handler.
+ *
+ *
+ *
cfg (Object)
Configuration object.
+ *
+ * @protected + */ + _defRequestFn: function(e) { + var uri = this.get("source"), + get = this.get("get"), + guid = Y.guid().replace(/\-/g, '_'), + generateRequest = this.get( "generateRequestCallback" ), + payload = e.details[0], + self = this; + + /** + * Stores the most recent request id for validation against stale + * response handling. + * + * @property _last + * @type {String} + * @protected + */ + this._last = guid; + + // Dynamically add handler function with a closure to the callback stack + // for access to guid + YUI.Env.DataSource.callbacks[guid] = function(response) { + delete YUI.Env.DataSource.callbacks[guid]; + delete Y.DataSource.Local.transactions[e.tId]; + + var process = self.get('asyncMode') !== "ignoreStaleResponses" || + self._last === guid; + + if (process) { + payload.data = response; + + self.fire("data", payload); + } else { + Y.log("DataSource ignored stale response for id " + e.tId + "(" + e.request + ")", "info", "datasource-get"); + } + + }; + + // Add the callback param to the request url + uri += e.request + generateRequest.call( this, guid ); + + Y.log("DataSource is querying URL " + uri, "info", "datasource-get"); + + Y.DataSource.Local.transactions[e.tId] = get.script(uri, { + autopurge: true, + // Works in Firefox only.... + onFailure: function (o) { + delete YUI.Env.DataSource.callbacks[guid]; + delete Y.DataSource.Local.transactions[e.tId]; + + payload.error = new Error(o.msg || "Script node data failure"); + + Y.log("Script node data failure", "error", "datasource-get"); + + self.fire("data", payload); + }, + onTimeout: function(o) { + delete YUI.Env.DataSource.callbacks[guid]; + delete Y.DataSource.Local.transactions[e.tId]; + + payload.error = new Error(o.msg || "Script node data timeout"); + + Y.log("Script node data timeout", "error", "datasource-get"); + + self.fire("data", payload); + } + }); + + return e.tId; + }, + + + /** + * Default method for adding callback param to url. See + * generateRequestCallback attribute. + * + * @method _generateRequest + * @param guid {String} unique identifier for callback function wrapper + * @protected + */ + _generateRequest: function (guid) { + return "&" + this.get("scriptCallbackParam") + + "=YUI.Env.DataSource.callbacks." + guid; + } + +}, { + + /** + * Class name. + * + * @property NAME + * @type String + * @static + * @final + * @value "dataSourceGet" + */ + NAME: "dataSourceGet", + + + //////////////////////////////////////////////////////////////////////////// + // + // DataSource.Get Attributes + // + //////////////////////////////////////////////////////////////////////////// + ATTRS: { + /** + * Pointer to Get Utility. + * + * @attribute get + * @type Y.Get + * @default Y.Get + */ + get: { + value: Y.Get, + cloneDefaultValue: false + }, + + /** + * Defines request/response management in the following manner: + *
+ * + *
ignoreStaleResponses
+ *
Send all requests, but handle only the response for the most + * recently sent request.
+ *
allowAll
+ *
Send all requests and handle all responses.
+ *
+ * + * @attribute asyncMode + * @type String + * @default "allowAll" + */ + asyncMode: { + value: "allowAll" + }, + + /** + * Callback string parameter name sent to the remote script. By default, + * requests are sent to + * <URI>?<scriptCallbackParam>=callbackFunction + * + * @attribute scriptCallbackParam + * @type String + * @default "callback" + */ + scriptCallbackParam : { + value: "callback" + }, + + /** + * Accepts the DataSource instance and a callback ID, and returns a callback + * param/value string that gets appended to the script URI. Implementers + * can customize this string to match their server's query syntax. + * + * @attribute generateRequestCallback + * @type Function + */ + generateRequestCallback : { + value: function () { + return this._generateRequest.apply(this, arguments); + } + } + } +}); + +YUI.namespace("Env.DataSource.callbacks"); + + +}, '3.10.3', {"requires": ["datasource-local", "get"]});