jsonp-min.js revision 2c1ca08d7e82859835cdb7daa00651db86c7cbd4
YUI.add("jsonp",function(E){var B=E.Lang,A=B.isObject,D=B.isFunction;function C(){this._init.apply(this,arguments);}C._pattern=/\bcallback=(.*?)(?=&|$)/i;C._template="callback={callback}";C.prototype={_init:function(F,H){this.url=F;H=(D(H))?{on:{success:H}}:H||{};var G=H.on||{};if(!G.success){G=E.mix({success:this._getCallbackFromUrl(F)},H);}this._config=E.merge({context:this,args:[],format:this._format},H,{on:G});},_getCallbackFromUrl:function(G){var F=G.match(C._pattern),K,I,J,H;if(F){I=E.config.win;J=F[1].split(/\./).reverse();K=J.shift();for(H=J.length-1;H>=0;--H){I=I[J[H]];if(!A(I)){return null;}}if(A(I)&&D(I[K])){return E.bind(I[K],I);}}return null;},send:function(J){if(!this._config.on.success){return this;}var H=E.guid().replace(/-/g,"_"),G=this._config,F=G.format.call(this,this.url,"YUI.Env.JSONP."+H);function I(K){return(D(K))?function(L){delete YUI.Env.JSONP[H];K.apply(G.context,[L].concat(G.args));}:null;}YUI.Env.JSONP[H]=I(G.on.success);E.Get.script(F,{onFailure:I(G.on.failure),onTimeout:I(G.on.timeout||G.on.failure),timeout:G.timeout});return this;},_format:function(F,H){var I=C._template.replace(/\{callback\}/,H),G;if(C._pattern.test(F)){return F.replace(C._pattern,I);}else{G=F.slice(-1);if(G!=="&"&&G!=="?"){F+=(F.indexOf("?")>-1)?"&":"?";}return F+I;}}};E.JSONPRequest=C;E.jsonp=function(F,G){return new E.JSONPRequest(F,G).send();};YUI.Env.JSONP={};},"@VERSION@",{requires:["get","oop"]});