datasource-min.js revision 9593cd5be06a4d8436ea33c4ac3620c4c0243c91
YUI.add("datasource-base",function(C){var B=C.Lang,A=function(){A.superclass.constructor.apply(this,arguments);};C.mix(A,{NAME:"DataSource.Local",ATTRS:{source:{value:null}},_tId:0,issueCallback:function(E){if(E.callback){var F=E.callback.scope||window,D=(E.error&&E.callback.failure)||E.callback.success;if(D){D.apply(F,[E]);}}}});C.extend(A,C.Base,{_queue:null,initializer:function(){this._queue={interval:null,conn:null,requests:[]};this._initEvents();},destructor:function(){},_initEvents:function(){this.publish("request",{defaultFn:function(D,E){this._defRequestFn(D,E);}});this.publish("data",{defaultFn:function(D,E){this._defDataFn(D,E);}});this.publish("response",{defaultFn:function(D,E){this._defResponseFn(D,E);}});},_defRequestFn:function(E,F){var D=this.get("source");if(B.isUndefined(D)){F.error=true;}if(F.error){this.fire("error",null,F);}this.fire("data",null,C.mix(F,{data:D}));},_defDataFn:function(D,E){E.results=E.data;if(!E.results){E.results=[];}if(!E.meta){E.meta={};}this.fire("response",null,E);},_defResponseFn:function(D,E){A.issueCallback(E);},sendRequest:function(D,F){var E=A._tId++;this.fire("request",null,{tId:E,request:D,callback:F});return E;}});C.namespace("DataSource");C.DataSource.Local=A;},"@VERSION@",{requires:["base"]});YUI.add("datasource-xhr",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NAME:"DataSource.XHR",ATTRS:{io:{value:B.io}}});B.extend(A,B.DataSource.Local,{_defRequestFn:function(E,F){var D=this.get("source"),C={on:{success:function(I,G,H){this.fire("data",null,B.mix(H,{data:G}));},failure:function(I,G,H){H.error=true;this.fire("error",null,B.mix(H,{data:G}));this.fire("data",null,B.mix(H,{data:G}));}},context:this,arguments:{tId:F.tId,request:F.request,callback:F.callback}};this.get("io")(D,C);return F.tId;}});B.DataSource.XHR=A;},"@VERSION@",{requires:["datasource-base"]});YUI.add("datasource-cache",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"cache",NAME:"DataSourceCache",ATTRS:{}});B.extend(A,B.Cache,{initializer:function(C){this.doBefore("_defRequestFn",this._beforeDefRequestFn);this.doBefore("_defResponseFn",this._beforeDefResponseFn);},_beforeDefRequestFn:function(D,E){var C=(this.retrieve(E.request))||null;if(C&&C.response){this._owner.fire("response",null,B.mix(E,C.response));return new B.Do.Halt("DataSourceCache plugin halted _defRequestFn");}},_beforeDefResponseFn:function(C,D){this.add(D.request,D,(D.callback&&D.callback.argument));}});B.namespace("plugin");B.plugin.DataSourceCache=A;},"@VERSION@",{requires:["plugin","datasource-base","cache"]});YUI.add("datasource-jsonparser",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"parser",NAME:"DataSourceJSONParser",ATTRS:{parser:{readOnly:true,value:B.DataParser.JSON,useRef:true},schema:{}}});B.extend(A,B.Plugin,{initializer:function(C){this.doBefore("_defDataFn",this._beforeDefDataFn);},_beforeDefDataFn:function(D,E){var C=(this.get("parser").parse(this.get("schema"),E.data));if(!C){C={meta:{},results:E.data};}this._owner.fire("response",null,B.mix(E,C));return new B.Do.Halt("DataSourceJSONParser plugin halted _defDataFn");}});B.namespace("plugin");B.plugin.DataSourceJSONParser=A;},"@VERSION@",{requires:["plugin","datasource-base","dataparser-json"]});YUI.add("datasource-polling",function(C){var A=C.Lang,B=function(){};B.prototype={_intervals:null,setInterval:function(F,E,H){if(A.isNumber(F)&&(F>=0)){var D=this,G=setInterval(function(){D.sendRequest(E,H);},F);if(!this._intervals){this._intervals=[];}this._intervals.push(G);return G;}else{}},clearInterval:function(F){var E=this._intervals||[],D=E.length-1;for(;D>-1;D--){if(E[D]===F){E.splice(D,1);clearInterval(F);}}}};C.Base.build(C.DataSource.Local.NAME,C.DataSource.Local,[B],{dynamic:false});},"@VERSION@",{requires:["datasource-base"]});YUI.add("datasource",function(A){},"@VERSION@",{use:["datasource-base","datasource-xhr","datasource-cache","datasource-jsonparser","datasource-polling"]});