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