]> git.wh0rd.org - tt-rss.git/blobdiff - lib/dojo/rpc/JsonpService.js
build custom layer of Dojo to speed up loading of tt-rss (refs #293)
[tt-rss.git] / lib / dojo / rpc / JsonpService.js
index 68c971207035f62d1194238b582a3e5e934dbd2a..31e95077b1d1e74ae82c7364b608f1b402b4cce4 100644 (file)
@@ -5,28 +5,68 @@
 */
 
 
-if(!dojo._hasResource["dojo.rpc.JsonpService"]){
-dojo._hasResource["dojo.rpc.JsonpService"]=true;
+if(!dojo._hasResource["dojo.rpc.JsonpService"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojo.rpc.JsonpService"] = true;
 dojo.provide("dojo.rpc.JsonpService");
 dojo.require("dojo.rpc.RpcService");
 dojo.require("dojo.io.script");
-dojo.declare("dojo.rpc.JsonpService",dojo.rpc.RpcService,{constructor:function(_1,_2){
-if(this.required){
-if(_2){
-dojo.mixin(this.required,_2);
-}
-dojo.forEach(this.required,function(_3){
-if(_3==""||_3==undefined){
-throw new Error("Required Service Argument not found: "+_3);
-}
+
+dojo.declare("dojo.rpc.JsonpService", dojo.rpc.RpcService, {
+       // summary:
+       //      Generic JSONP service.  Minimally extends RpcService to allow 
+       //      easy definition of nearly any JSONP style service. Example
+       //      SMD files exist in dojox.data
+
+       constructor: function(args, requiredArgs){
+               if(this.required) {
+                       if(requiredArgs){
+                               dojo.mixin(this.required, requiredArgs);
+                       }
+
+                       dojo.forEach(this.required, function(req){
+                               if(req=="" || req==undefined){
+                                       throw new Error("Required Service Argument not found: "+req); 
+                               }
+                       });
+               }               
+       },
+
+       strictArgChecks: false,
+
+       bind: function(method, parameters, deferredRequestHandler, url){
+               //summary:
+               //              JSONP bind method. Takes remote method, parameters,
+               //              deferred, and a url, calls createRequest to make a JSON-RPC
+               //              envelope and passes that off with bind.
+               //      method: string
+               //              The name of the method we are calling
+               //      parameters: array
+               //              The parameters we are passing off to the method
+               //      deferredRequestHandler: deferred
+               //              The Deferred object for this particular request
+
+               var def = dojo.io.script.get({
+                       url: url||this.serviceUrl,
+                       callbackParamName: this.callbackParamName||"callback",
+                       content: this.createRequest(parameters),
+                       timeout: this.timeout,
+                       handleAs: "json",       
+                       preventCache: true
+               });
+               def.addCallbacks(this.resultCallback(deferredRequestHandler), this.errorCallback(deferredRequestHandler));
+       },
+
+       createRequest: function(parameters){
+               // summary:
+               //      create a JSONP req
+               //      params: array
+               //              The array of parameters for this request;
+
+               var params = (dojo.isArrayLike(parameters) && parameters.length==1) ?
+                               parameters[0] : {};
+               dojo.mixin(params,this.required);
+               return params;
+       }
 });
-}
-},strictArgChecks:false,bind:function(_4,_5,_6,_7){
-var _8=dojo.io.script.get({url:_7||this.serviceUrl,callbackParamName:this.callbackParamName||"callback",content:this.createRequest(_5),timeout:this.timeout,handleAs:"json",preventCache:true});
-_8.addCallbacks(this.resultCallback(_6),this.errorCallback(_6));
-},createRequest:function(_9){
-var _a=(dojo.isArrayLike(_9)&&_9.length==1)?_9[0]:{};
-dojo.mixin(_a,this.required);
-return _a;
-}});
+
 }