io-base-min.js revision f4f43ea0d6d226d7be3099b3a68389c221a35139
YUI.add("io-base",function(D){var f="io:start",R="io:complete",B="io:success",H="io:failure",g="io:end",a=0,Q={"X-Requested-With":"XMLHttpRequest"},b={},M=D.config.win;function d(i,p){var h,j,p=p||{},n=Z((arguments.length===3)?arguments[2]:null,p),Y=(p.method)?p.method.toUpperCase():"GET",l=(p.data)?p.data:null;n.abort=function(){p.xdr?n.c.abort(n.id,p):P(n,"abort");};n.isInProgress=function(){var m=(p.xdr)?n.c.readyState(n.id):(n.c.readyState!==4&&n.c.readyState!==0);return m;};if(p.form){if(p.form.upload){h=D.io._upload(n,i,p);return h;}j=D.io._serialize(p.form);if(l){j+="&"+l;}if(Y==="POST"){l=j;X("Content-Type","application/x-www-form-urlencoded");}else{if(Y==="GET"){i=S(i,j);}}}else{if(l&&Y==="GET"){i=S(i,p.data);}else{if(l&&Y==="POST"){X("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");}}}if(p.xdr){D.io._xdr(i,n,p);return n;}if(p.timeout){T(n,p.timeout);}n.c.onreadystatechange=function(){e(n,p);};try{E(n.c,Y,i);}catch(k){}C(n.c,(p.headers||{}));W(n,(l||""),p);return n;}function A(h,i){var Y=new D.Event.Target().publish("transaction:"+h);Y.subscribe(i.on[h],(i.context||this),i.arguments);return Y;}function U(k,j){var Y=D.io._fn||{},h=(Y&&Y[k])?Y[k]:null,i;j.on=j.on||{};if(h){j.on.start=h.start;}D.fire(f,k);if(j.on.start){i=A("start",j);i.fire(k);}}function I(i,j){var h,Y;j.on=j.on||{};h=(i.status)?G(i.status):i.c;D.fire(R,i.id,h);if(j.on.complete){Y=A("complete",j);Y.fire(i.id,h);}}function V(j,k){var Y=D.io._fn||{},h=(Y&&Y[j.id])?Y[j.id]:null,i;k.on=k.on||{};if(h){k.on.success=h.success;j.c.responseText=decodeURI(j.c.responseText);}D.fire(B,j.id,j.c);if(k.on.success){i=A("success",k);i.fire(j.id,j.c);}L(j,k);}function K(k,l){var Y=D.io._fn||{},h=(Y&&Y[k.id])?Y[k.id]:null,j,i;l.on=l.on||{};if(h){l.on.failure=h.failure;k.c.responseText=decodeURI(k.c.responseText);}j=(k.status)?G(k.status):k.c;D.fire(H,k.id,j);if(l.on.failure){i=A("failure",l);i.fire(k.id,j);}L(k,l);}function L(j,k){var Y=D.io._fn||{},h=(Y&&Y[j.id])?Y[j.id]:null,i;k.on=k.on||{};if(h){k.on.end=h.end;delete Y[j.id];}D.fire(g,j.id);if(k.on.end){i=A("end",k);i.fire(j.id,k);}J(j,(k.xdr)?true:false);}function P(h,Y){if(h&&h.c){h.status=Y;h.c.abort();}}function G(Y){return{status:0,statusText:Y};}function F(){var Y=a;a++;return Y;}function Z(Y,j){var h={};h.id=D.Lang.isNumber(Y)?Y:F();if(j.xdr){h.c=D.io._transport[j.xdr.use];}else{if(j.form&&j.form.upload){h.c={};}else{h.c=N();}}return h;}function N(){return(M.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");}function S(Y,h){Y+=((Y.indexOf("?")==-1)?"?":"&")+h;return Y;}function X(Y,h){if(h){Q[Y]=h;}else{delete Q[Y];}}function C(j,Y){var i;for(i in Q){if(Q.hasOwnProperty(i)){if(Y[i]){break;}else{Y[i]=Q[i];}}}for(i in Y){if(Y.hasOwnProperty(i)){j.setRequestHeader(i,Y[i]);}}}function E(i,Y,h){i.open(Y,h,true);}function W(h,Y,i){h.c.send(Y);U(h.id,i);}function T(h,Y){b[h.id]=M.setTimeout(function(){P(h,"timeout");},Y);}function O(Y){M.clearTimeout(b[Y]);delete b[Y];}function e(Y,h){if(Y.c.readyState===4){if(h.timeout){O(Y.id);}M.setTimeout(function(){I(Y,h);c(Y,h);},0);}}function c(i,j){var Y;try{if(i.c.status&&i.c.status!==0){Y=i.c.status;}else{Y=0;}}catch(h){Y=0;}if(Y>=200&&Y<300||Y===1223){V(i,j);}else{K(i,j);}}function J(h,Y){if(M.XMLHttpRequest&&!Y){if(h.c){h.c.onreadystatechange=null;}}h.c=null;h=null;}d.start=U;d.complete=I;d.success=V;d.failure=K;d._id=F;d.header=X;D.io=d;D.io.http=d;},"@VERSION@");