io-min.js revision f54bfd7ba78fe5943d443088e8e9b48e10191318
YUI.add("io-base",function(a){var h=a.Lang,k=["start","complete","end","success","failure"],g=["status","statusText","responseText","responseXML"],b="getAllResponseHeaders",d="getResponseHeader",i=a.config.win,j=i.XMLHttpRequest,e=i.XDomainRequest,f=0;function c(){var l=this;this._init(l);a.io._map[l._uid]=l;}c.prototype={_uid:"io:"+f++,_id:0,_headers:{"X-Requested-With":"XMLHttpRequest"},_timeout:{},_init:function(){var m=this,l;a.augment(m,a.EventTarget);for(l=0;l<5;l++){m.publish("io:"+k[l],{broadcast:1});m.publish("io-trn:"+k[l]);}},_create:function(q,m){var p=this,n={id:h.isNumber(m)?m:p._id++,uid:p._uid},l=q.xdr?q.xdr.use:q.form&&q.form.upload?"iframe":"xhr";switch(l){case"native":case"xhr":n.c=e?new e():j?new j():new ActiveXObject("Microsoft.XMLHTTP");n.t=e?true:false;break;default:n.c=p._transport?p._transport[l]:{};n.t=true;}return n;},_destroy:function(l){if(i){if(j&&l.t===true){l.c.onreadystatechange=null;}else{if(a.UA.ie){l.c.abort();}}}l.c=null;l=null;},_evt:function(p,l,r){var q=this,n=r.on?r.on[p]:null,s=r.context||a,u=r["arguments"],m,v;l.c=l.e?{status:0,statusText:l.e}:l.c;switch(p){case"start":case"end":m=u?q.fire("io:"+p,l.id,u):q.fire("io:"+p,l.id);if(n){p="io-trn:"+p;v=u?q.once(p,n,s,u):q.once(p,n,s);q.fire(p,l.id);}break;default:m=u?q.fire("io:"+p,l.id,l.c,u):q.fire("io:"+p,l.id,l.c);if(n){p="io-trn:"+p;v=u?q.once(p,n,s,u):q.once(p,n,s);q.fire(p,l.id,l.c);}}},start:function(l,m){this._evt(k[0],l,m);},complete:function(l,m){this._evt(k[1],l,m);},end:function(l,m){this._evt(k[2],l,m);this._destroy(l);},success:function(l,m){this._evt(k[3],l,m);this.end(l,m);},failure:function(l,m){this._evt(k[4],l,m);this.end(l,m);},_retry:function(m,l,n){this._destroy(m);n.xdr.use="flash";return this.send(l,n,m.id);},_concat:function(l,m){l+=(l.indexOf("?")===-1?"?":"&")+m;return l;},setHeader:function(m,n){if(n){this._headers[m]=n;}else{delete this._headers[m];}},_setHeaders:function(m,l){l=a.merge(this._headers,l);a.Object.each(l,function(n,o){if(n!=="disable"){m.setRequestHeader(o,l[o]);}});},_startTimeout:function(m,l){var n=this;n._timeout[m.id]=i.setTimeout(function(){n._abort(m,"timeout");},l);},_clearTimeout:function(l){i.clearTimeout(this._timeout[l]);delete this._timeout[l];},_result:function(m,n){var l=m.c.status;if(l>=200&&l<300||l===1223){this.success(m,n);}else{this.failure(m,n);}},_rS:function(l,n){var m=this;if(l.c.readyState===4){if(n.timeout){m._clearTimeout(l.id);}i.setTimeout(function(){m.complete(l,n);m._result(l,n);},0);}},_abort:function(m,l){if(m&&m.c){m.e=l;m.c.abort();}},send:function(p,z,t){var v,n,q,l,B,y,x=this,A=p;z=z?a.Object(z):{};n=x._create(z,t);q=z.method?z.method.toUpperCase():"GET";B=z.sync;y=z.data;if(h.isObject(y)){y=a.QueryString.stringify(y);}if(z.form){if(z.form.upload){return x.upload(n,p,z);}else{v=x._serialize(z.form,y);if(q==="POST"||q==="PUT"){y=v;}else{if(q==="GET"){A=x._concat(A,v);}}}}if(y){switch(q){case"GET":case"HEAD":case"DELETE":A=x._concat(A,y);y="";break;case"POST":case"PUT":z.headers=a.merge({"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},z.headers);break;}}if(n.t){return x.xdr(p,n,z);}if(!B){n.c.onreadystatechange=function(){x._rS(n,z);};}try{n.c.open(q,A,B?false:true,z.username||null,z.password||null);x._setHeaders(n.c,z.headers||{});x.start(n,z);if(z.xdr&&z.xdr.credentials){if(!a.UA.ie){n.c.withCredentials=true;}}n.c.send(y);if(B){l=a.mix({id:n.id,"arguments":z["arguments"]},n.c,false,g);l[b]=function(){return n.c[b]();};l[d]=function(m){return n.c[d](m);};x.complete(n,z);x._result(n,z);return l;}}catch(w){if(n.t){return x._retry(n,p,z);}else{x.complete(n,z);x._result(n,z);}}if(z.timeout){x._startTimeout(n,z.timeout);}return{id:n.id,abort:function(){return n.c?x._abort(n,"abort"):false;},isInProgress:function(){return n.c?n.c.readyState!==4&&n.c.readyState!==0:false;},io:x};}};a.io=function(l,n){var m=a.io._map["io:0"]||new c();return m.send.apply(m,[l,n]);};a.IO=c;a.io._map={};},"@VERSION@",{requires:["event-custom-base","querystring-stringify-simple"]});YUI.add("io-form",function(b){var a=encodeURIComponent;b.mix(b.IO.prototype,{_serialize:function(w,B){var q=[],y=w.useDisabled||false,A=0,g=(typeof w.id==="string")?w.id:w.id.getAttribute("id"),t,r,k,z,u,p,x,l,m,h;if(!g){g=b.guid("io:");w.id.setAttribute("id",g);}r=b.config.doc.getElementById(g);for(p=0,x=r.elements.length;p<x;++p){t=r.elements[p];u=t.disabled;k=t.name;if(y?k:k&&!u){k=a(k)+"=";z=a(t.value);switch(t.type){case"select-one":if(t.selectedIndex>-1){h=t.options[t.selectedIndex];q[A++]=k+a(h.attributes.value&&h.attributes.value.specified?h.value:h.text);}break;case"select-multiple":if(t.selectedIndex>-1){for(l=t.selectedIndex,m=t.options.length;l<m;++l){h=t.options[l];if(h.selected){q[A++]=k+a(h.attributes.value&&h.attributes.value.specified?h.value:h.text);}}}break;case"radio":case"checkbox":if(t.checked){q[A++]=k+z;}break;case"file":case undefined:case"reset":case"button":break;case"submit":default:q[A++]=k+z;}}}return B?q.join("&")+"&"+B:q.join("&");}},true);},"@VERSION@",{requires:["io-base","node-base"]});YUI.add("io-xdr",function(b){var l=b.publish("io:xdrReady",{fireOnce:true}),f={},h={},k=b.config.doc,m=b.config.win,g=m&&m.XDomainRequest;function i(d,q){var n='<object id="io_swf" type="application/x-shockwave-flash" data="'+d+'" width="0" height="0">'+'<param name="movie" value="'+d+'">'+'<param name="FlashVars" value="yid='+q+'">'+'<param name="allowScriptAccess" value="always">'+"</object>",p=k.createElement("div");k.body.appendChild(p);p.innerHTML=n;}function a(r,u){var s=this,n=r.id,q="xdrResponse",d="timeout";r.c.onprogress=function(){h[n]=3;};r.c.onload=function(){h[n]=4;s[q](r,u,"success");};r.c.onerror=function(){h[n]=4;s[q](r,u,"failure");};if(u.timeout){r.c.ontimeout=function(){h[n]=4;s[q](r,u,d);};r.c[d]=u[d];}}function c(q,n,p){if(n==="flash"){q.c.responseText=decodeURI(q.c.responseText);}if(p==="xml"){q.c.responseXML=b.DataType.XML.parse(q.c.responseXML);}return q;}function j(d,n){return d.c.abort(d.id,n);}function e(d){return g?h[d.id]!==4:d.c.isInProgress(d.id);
}b.mix(b.IO.prototype,{_transport:{},xdr:function(d,n,q){var p=this;if(q.xdr.use==="flash"){f[n.id]=q;m.setTimeout(function(){if(n.c.send){n.c.send(d,{id:n.id,uid:n.uid,method:q.method,data:q.data,headers:q.headers});}else{p.xdrResponse(n,q,"transport error");delete f[n.id];}},b.io.xdr.delay);}else{if(g){a(n,q);n.c.open(q.method||"GET",d);n.c.send(q.data);}else{n.c.send(d,n,q);}}return{id:n.id,abort:function(){return n.c?j(n,q):false;},isInProgress:function(){return n.c?e(n.id):false;},conn:p};},xdrResponse:function(q,s,v){v=f[s.id]?f[s.id]:v;var t=this,n=g?h:f,p=v.xdr.use,r=v.xdr.dataType;switch(q){case"start":t.start(s,v);break;case"success":t.success(c(s,p,r),v);delete n[s.id];break;case"timeout":case"abort":case"transport error":s.e=q;case"failure":t.failure(c(s,p,r),v);delete n[s.id];break;}},xdrReady:function(n,d){b.io.xdr.delay=0;b.fire(l,n);},transport:function(d){if(d.id==="flash"){i(b.UA.ie?d.src+"?d="+new Date().valueOf().toString():d.src,b.id);}this._transport[d.id]=(d.id==="flash")?k.getElementById("io_swf"):d.src;}});b.io.xdrResponse=function(d,n,q){var p=b.io._map[n.uid];p.xdrResponse.apply(p,[d,n,q]);};b.io.transport=function(n){var d=b.io._map["io:0"]||new b.IO();d.transport.apply(d,[n]);};b.io.xdr={delay:100};},"@VERSION@",{requires:["io-base","datatype-xml"]});YUI.add("io-upload-iframe",function(g){var b=g.config.win,f=g.config.doc,c=(f.documentMode&&f.documentMode>=8),a=decodeURIComponent;function e(h,k,j){var d=g.Node.create('<iframe id="io_iframe'+h.id+'" name="io_iframe'+h.id+'" />');d._node.style.position="absolute";d._node.style.top="-1000px";d._node.style.left="-1000px";g.one("body").appendChild(d);g.on("load",function(){j._uploadComplete(h,k);},"#io_iframe"+h.id);}g.mix(g.IO.prototype,{_addData:function(n,k){var p=[],d=k.split("="),j,h;for(j=0,h=d.length-1;j<h;j++){p[j]=f.createElement("input");p[j].type="hidden";p[j].name=a(d[j].substring(d[j].lastIndexOf("&")+1));p[j].value=(j+1===h)?a(d[j+1]):a(d[j+1].substring(0,(d[j+1].lastIndexOf("&"))));n.appendChild(p[j]);}return p;},_removeData:function(j,k){var h,d;for(h=0,d=k.length;h<d;h++){j.removeChild(k[h]);}},_setAttrs:function(h,i,d){h.setAttribute("action",d);h.setAttribute("method","POST");h.setAttribute("target","io_iframe"+i);h.setAttribute(g.UA.ie&&!c?"encoding":"enctype","multipart/form-data");},_resetAttrs:function(h,d){g.Object.each(d,function(i,j){if(i){h.setAttribute(j,i);}else{h.removeAttribute(j);}});},_startTimeout:function(d,i){var h=this;h._timeout[d.id]=b.setTimeout(function(){d.status=0;d.statusText="timeout";h.complete(d,i);h.end(d,i);},i.timeout);},_clearTimeout:function(h){var d=this;b.clearTimeout(d._timeout[h]);delete d._timeout[h];},_destroy:function(d){g.Event.purgeElement("#io_iframe"+d,false);g.one("body").removeChild(g.one("#io_iframe"+d));},_uploadComplete:function(k,m){var l=this,j=g.one("#io_iframe"+k.id).get("contentWindow.document"),h=j.one("body"),i;if(m.timeout){l._clearTimeout(k.id);}if(h){i=h.one("pre:first-child");k.c.responseText=i?i.get("text"):h.get("text");}else{k.c.responseXML=j._node;}l.complete(k,m);l.end(k,m);b.setTimeout(function(){l._destroy(k.id);},0);},_upload:function(k,i,m){var l=this,j=(typeof m.form.id==="string")?f.getElementById(m.form.id):m.form.id,h={action:j.getAttribute("action"),target:j.getAttribute("target")},d;l._setAttrs(j,k.id,i);if(m.data){d=l._addData(j,m.data);}if(m.timeout){l._startTimeout(k,m);}j.submit();l.start(k,m);if(m.data){l._removeData(j,d);}l._resetAttrs(j,h);return{id:k.id,abort:function(){k.status=0;k.statusText="abort";if(g.one("#io_iframe"+k.id)){l._destroy(k.id);l.complete(k,m);l.end(k,m);}else{return false;}},isInProgress:function(){return g.one("#io_iframe"+k.id)?true:false;},conn:l};},upload:function(h,d,i){e(h,i,this);return this._upload(h,d,i);}});},"@VERSION@",{requires:["io-base","node-base"]});YUI.add("io-queue",function(b){var c=b.io._map["io:0"]||new b.IO();b.mix(b.IO.prototype,{_q:new b.Queue(),_qActiveId:null,_qInit:false,_qState:1,_qShift:function(){var e=this,d=e._q.next();e._qActiveId=d.id;e._qState=0;e.send(d.uri,d.cfg,d.id);},queue:function(d,g){var f=this,e={uri:d,cfg:g,id:this._id++};if(!f._qInit){b.on("io:complete",function(i,h){f._qNext(i);},f);f._qInit=true;}f._q.add(e);if(f._qState===1){f._qShift();}return e;},_qNext:function(e){var d=this;d._qState=1;if(d._qActiveId===e&&d._q.size()>0){d._qShift();}},qPromote:function(d){this._q.promote(d);},qRemove:function(d){this._q.remove(d);},qStart:function(){var d=this;d._qState=1;if(d._q.size()>0){d._qShift();}},qStop:function(){this._qState=0;},qSize:function(){return this._q.size();}},true);function a(d,e){return c.queue.apply(c,[d,e]);}a.start=function(){c.qStart();};a.stop=function(){c.qStop();};a.promote=function(d){c.qPromote(d);};a.remove=function(d){c.qRemove(d);};a.size=function(){c.qSize();};b.io.queue=a;},"@VERSION@",{requires:["io-base","queue-promote"]});YUI.add("io",function(a){},"@VERSION@",{use:["io-base","io-form","io-xdr","io-upload-iframe","io-queue"]});