jsonp-min.js revision 85d2d33f7ddef4ec0abb9158d36275151660764a
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.success=this._getCallbackFromUrl(F);}this._config=E.merge({context:this,args:[],format:this._format},H,{on:G});},_getCallbackFromUrl:function(H){var G=H.match(C._pattern),F={},J=0,M,I,K,L;if(G){K=G[1].replace(/\[(?:(['"])([^\]\1]+)\1|(\d+))\]/g,function(P,O,N){F[J]=O||N;var R=(RegExp.rightContext||".").charAt(0),Q=".@"+(++J);if(R!=="."&&R!=="["){Q+=".";}return Q;}).split(/\./).reverse();M=K.shift();I=E.config.win;for(J=K.length-1;J>=0;--J){L=K[J];if(L.charAt(0)==="@"){L=F[L.slice(1)];}I=I[L];if(!A(I)){return null;}}if(A(I)){return E.bind(M,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"]});