Permalink
Browse files

Added yql-jsonp module to help with loading in other environments

  • Loading branch information...
1 parent 4de358b commit 2cda518db909e496cbbf6c267bbb60ea51bb00ce @davglass committed Jan 7, 2013
Showing with 48 additions and 17 deletions.
  1. +5 −0 src/yql/build.json
  2. +24 −0 src/yql/js/yql-jsonp.js
  3. +2 −13 src/yql/js/yql.js
  4. +6 −0 src/yql/meta/jsonp.js
  5. +11 −4 src/yql/meta/yql.json
View
@@ -11,6 +11,11 @@
"yql-winjs.js"
]
},
+ "yql-jsonp": {
+ "jsfiles": [
+ "yql-jsonp.js"
+ ]
+ },
"yql-nodejs": {
"jsfiles": [
"yql-nodejs.js"
View
@@ -0,0 +1,24 @@
+/**
+* Plugin for YQL to use JSONP to make YQL requests. This is the default method,
+* when loaded in nodejs or winjs this will not load. The new module is needed
+* to make sure that JSONP is not loaded in the environments that it is not needed.
+* @module yql
+* @submodule yql-jsonp
+*/
+
+//Over writes Y.YQLRequest._send to use IO instead of JSONP
+Y.YQLRequest.prototype._send = function (url, o) {
+ if (o.allowCache !== false) {
+ o.allowCache = true;
+ }
+ if (!this._jsonp) {
+ this._jsonp = Y.jsonp(url, o);
+ } else {
+ this._jsonp.url = url;
+ if (o.on && o.on.success) {
+ this._jsonp._config.on.success = o.on.success;
+ }
+ this._jsonp.send();
+ }
+};
+
View
@@ -117,19 +117,8 @@ YQLRequest.prototype = {
* @param {String} url The URL to request
* @param {Object} o The config object
*/
- _send: function(url, o) {
- if (o.allowCache !== false) {
- o.allowCache = true;
- }
- if (!this._jsonp) {
- this._jsonp = Y.jsonp(url, o);
- } else {
- this._jsonp.url = url;
- if (o.on && o.on.success) {
- this._jsonp._config.on.success = o.on.success;
- }
- this._jsonp.send();
- }
+ _send: function() {
+ //Overwritten in plugins
}
};
View
@@ -0,0 +1,6 @@
+function (Y) {
+ /* Only load the JSONP module when not in nodejs or winjs
+ TODO Make the winjs module a CORS module
+ */
+ return (!Y.UA.nodejs && !Y.UA.winjs);
+}
View
@@ -1,10 +1,17 @@
{
"yql": {
- "requires": [
- "jsonp",
- "jsonp-url"
- ],
"plugins": {
+ "yql-jsonp": {
+ "condition": {
+ "trigger": "yql",
+ "test": "jsonp.js",
+ "when": "after"
+ },
+ "requires": [
+ "jsonp",
+ "jsonp-url"
+ ]
+ },
"yql-winjs": {
"condition": {
"trigger": "yql",

0 comments on commit 2cda518

Please sign in to comment.