]> git.wh0rd.org - tt-rss.git/blobdiff - lib/dojo/io/script.js
update dojo to 1.7.3
[tt-rss.git] / lib / dojo / io / script.js
index a44e9f2ee7661bc9accb101d4ef0a10dd3666d67..03459fae1ebe30710fc6b3d26c63063728cc3957 100644 (file)
@@ -4,259 +4,5 @@
        see: http://dojotoolkit.org/license for details
 */
 
-
-if(!dojo._hasResource["dojo.io.script"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojo.io.script"] = true;
-dojo.provide("dojo.io.script");
-
-dojo.getObject("io", true, dojo);
-
-/*=====
-dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, {
-       constructor: function(){
-               //      summary:
-               //              All the properties described in the dojo.__ioArgs type, apply to this
-               //              type as well, EXCEPT "handleAs". It is not applicable to
-               //              dojo.io.script.get() calls, since it is implied by the usage of
-               //              "jsonp" (response will be a JSONP call returning JSON)
-               //              or the response is pure JavaScript defined in
-               //              the body of the script that was attached.
-               //      callbackParamName: String
-               //              Deprecated as of Dojo 1.4 in favor of "jsonp", but still supported for
-               //              legacy code. See notes for jsonp property.
-               //      jsonp: String
-               //              The URL parameter name that indicates the JSONP callback string.
-               //              For instance, when using Yahoo JSONP calls it is normally,
-               //              jsonp: "callback". For AOL JSONP calls it is normally
-               //              jsonp: "c".
-               //      checkString: String
-               //              A string of JavaScript that when evaluated like so:
-               //              "typeof(" + checkString + ") != 'undefined'"
-               //              being true means that the script fetched has been loaded.
-               //              Do not use this if doing a JSONP type of call (use callbackParamName instead).
-               //      frameDoc: Document
-               //              The Document object for a child iframe. If this is passed in, the script
-               //              will be attached to that document. This can be helpful in some comet long-polling
-               //              scenarios with Firefox and Opera.
-               this.callbackParamName = callbackParamName;
-               this.jsonp = jsonp;
-               this.checkString = checkString;
-               this.frameDoc = frameDoc;
-       }
-});
-=====*/
-(function(){
-       var loadEvent = dojo.isIE ? "onreadystatechange" : "load",
-               readyRegExp = /complete|loaded/;
-
-       dojo.io.script = {
-               get: function(/*dojo.io.script.__ioArgs*/args){
-                       //      summary:
-                       //              sends a get request using a dynamically created script tag.
-                       var dfd = this._makeScriptDeferred(args);
-                       var ioArgs = dfd.ioArgs;
-                       dojo._ioAddQueryToUrl(ioArgs);
-       
-                       dojo._ioNotifyStart(dfd);
-
-                       if(this._canAttach(ioArgs)){
-                               var node = this.attach(ioArgs.id, ioArgs.url, args.frameDoc);
-
-                               //If not a jsonp callback or a polling checkString case, bind
-                               //to load event on the script tag.
-                               if(!ioArgs.jsonp && !ioArgs.args.checkString){
-                                       var handle = dojo.connect(node, loadEvent, function(evt){
-                                               if(evt.type == "load" || readyRegExp.test(node.readyState)){
-                                                       dojo.disconnect(handle);
-                                                       ioArgs.scriptLoaded = evt;
-                                               }
-                                       });
-                               }
-                       }
-
-                       dojo._ioWatch(dfd, this._validCheck, this._ioCheck, this._resHandle);
-                       return dfd;
-               },
-       
-               attach: function(/*String*/id, /*String*/url, /*Document?*/frameDocument){
-                       //      summary:
-                       //              creates a new <script> tag pointing to the specified URL and
-                       //              adds it to the document.
-                       //      description:
-                       //              Attaches the script element to the DOM.  Use this method if you
-                       //              just want to attach a script to the DOM and do not care when or
-                       //              if it loads.
-                       var doc = (frameDocument || dojo.doc);
-                       var element = doc.createElement("script");
-                       element.type = "text/javascript";
-                       element.src = url;
-                       element.id = id;
-                       element.charset = "utf-8";
-                       return doc.getElementsByTagName("head")[0].appendChild(element);
-               },
-       
-               remove: function(/*String*/id, /*Document?*/frameDocument){
-                       //summary: removes the script element with the given id, from the given frameDocument.
-                       //If no frameDocument is passed, the current document is used.
-                       dojo.destroy(dojo.byId(id, frameDocument));
-                       
-                       //Remove the jsonp callback on dojo.io.script, if it exists.
-                       if(this["jsonp_" + id]){
-                               delete this["jsonp_" + id];
-                       }
-               },
-       
-               _makeScriptDeferred: function(/*Object*/args){
-                       //summary:
-                       //              sets up a Deferred object for an IO request.
-                       var dfd = dojo._ioSetArgs(args, this._deferredCancel, this._deferredOk, this._deferredError);
-       
-                       var ioArgs = dfd.ioArgs;
-                       ioArgs.id = dojo._scopeName + "IoScript" + (this._counter++);
-                       ioArgs.canDelete = false;
-       
-                       //Special setup for jsonp case
-                       ioArgs.jsonp = args.callbackParamName || args.jsonp;
-                       if(ioArgs.jsonp){
-                               //Add the jsonp parameter.
-                               ioArgs.query = ioArgs.query || "";
-                               if(ioArgs.query.length > 0){
-                                       ioArgs.query += "&";
-                               }
-                               ioArgs.query += ioArgs.jsonp
-                                       + "="
-                                       + (args.frameDoc ? "parent." : "")
-                                       + dojo._scopeName + ".io.script.jsonp_" + ioArgs.id + "._jsonpCallback";
-       
-                               ioArgs.frameDoc = args.frameDoc;
-       
-                               //Setup the Deferred to have the jsonp callback.
-                               ioArgs.canDelete = true;
-                               dfd._jsonpCallback = this._jsonpCallback;
-                               this["jsonp_" + ioArgs.id] = dfd;
-                       }
-                       return dfd; // dojo.Deferred
-               },
-               
-               _deferredCancel: function(/*Deferred*/dfd){
-                       //summary: canceller function for dojo._ioSetArgs call.
-       
-                       //DO NOT use "this" and expect it to be dojo.io.script.
-                       dfd.canceled = true;
-                       if(dfd.ioArgs.canDelete){
-                               dojo.io.script._addDeadScript(dfd.ioArgs);
-                       }
-               },
-       
-               _deferredOk: function(/*Deferred*/dfd){
-                       //summary: okHandler function for dojo._ioSetArgs call.
-       
-                       //DO NOT use "this" and expect it to be dojo.io.script.
-                       var ioArgs = dfd.ioArgs;
-       
-                       //Add script to list of things that can be removed.
-                       if(ioArgs.canDelete){
-                               dojo.io.script._addDeadScript(ioArgs);
-                       }
-       
-                       //Favor JSONP responses, script load events then lastly ioArgs.
-                       //The ioArgs are goofy, but cannot return the dfd since that stops
-                       //the callback chain in Deferred. The return value is not that important
-                       //in that case, probably a checkString case.
-                       return ioArgs.json || ioArgs.scriptLoaded || ioArgs;
-               },
-       
-               _deferredError: function(/*Error*/error, /*Deferred*/dfd){
-                       //summary: errHandler function for dojo._ioSetArgs call.
-       
-                       if(dfd.ioArgs.canDelete){
-                               //DO NOT use "this" and expect it to be dojo.io.script.
-                               if(error.dojoType == "timeout"){
-                                       //For timeouts, remove the script element immediately to
-                                       //avoid a response from it coming back later and causing trouble.
-                                       dojo.io.script.remove(dfd.ioArgs.id, dfd.ioArgs.frameDoc);
-                               }else{
-                                       dojo.io.script._addDeadScript(dfd.ioArgs);
-                               }
-                       }
-                       console.log("dojo.io.script error", error);
-                       return error;
-               },
-       
-               _deadScripts: [],
-               _counter: 1,
-       
-               _addDeadScript: function(/*Object*/ioArgs){
-                       //summary: sets up an entry in the deadScripts array.
-                       dojo.io.script._deadScripts.push({id: ioArgs.id, frameDoc: ioArgs.frameDoc});
-                       //Being extra paranoid about leaks:
-                       ioArgs.frameDoc = null;
-               },
-       
-               _validCheck: function(/*Deferred*/dfd){
-                       //summary: inflight check function to see if dfd is still valid.
-       
-                       //Do script cleanup here. We wait for one inflight pass
-                       //to make sure we don't get any weird things by trying to remove a script
-                       //tag that is part of the call chain (IE 6 has been known to
-                       //crash in that case).
-                       var _self = dojo.io.script;
-                       var deadScripts = _self._deadScripts;
-                       if(deadScripts && deadScripts.length > 0){
-                               for(var i = 0; i < deadScripts.length; i++){
-                                       //Remove the script tag
-                                       _self.remove(deadScripts[i].id, deadScripts[i].frameDoc);
-                                       deadScripts[i].frameDoc = null;
-                               }
-                               dojo.io.script._deadScripts = [];
-                       }
-       
-                       return true;
-               },
-       
-               _ioCheck: function(/*Deferred*/dfd){
-                       //summary: inflight check function to see if IO finished.
-                       var ioArgs = dfd.ioArgs;
-                       //Check for finished jsonp
-                       if(ioArgs.json || (ioArgs.scriptLoaded && !ioArgs.args.checkString)){
-                               return true;
-                       }
-       
-                       //Check for finished "checkString" case.
-                       var checkString = ioArgs.args.checkString;
-                       if(checkString && eval("typeof(" + checkString + ") != 'undefined'")){
-                               return true;
-                       }
-       
-                       return false;
-               },
-       
-               _resHandle: function(/*Deferred*/dfd){
-                       //summary: inflight function to handle a completed response.
-                       if(dojo.io.script._ioCheck(dfd)){
-                               dfd.callback(dfd);
-                       }else{
-                               //This path should never happen since the only way we can get
-                               //to _resHandle is if _ioCheck is true.
-                               dfd.errback(new Error("inconceivable dojo.io.script._resHandle error"));
-                       }
-               },
-       
-               _canAttach: function(/*Object*/ioArgs){
-                       //summary: A method that can be overridden by other modules
-                       //to control when the script attachment occurs.
-                       return true;
-               },
-               
-               _jsonpCallback: function(/*JSON Object*/json){
-                       //summary:
-                       //              generic handler for jsonp callback. A pointer to this function
-                       //              is used for all jsonp callbacks.  NOTE: the "this" in this
-                       //              function will be the Deferred object that represents the script
-                       //              request.
-                       this.ioArgs.json = json;
-               }
-       };
-})();
-
-}
+//>>built
+define("dojo/io/script",["../main"],function(_1){_1.getObject("io",true,_1);var _2=_1.isIE?"onreadystatechange":"load",_3=/complete|loaded/;_1.io.script={get:function(_4){var _5=this._makeScriptDeferred(_4);var _6=_5.ioArgs;_1._ioAddQueryToUrl(_6);_1._ioNotifyStart(_5);if(this._canAttach(_6)){var _7=this.attach(_6.id,_6.url,_4.frameDoc);if(!_6.jsonp&&!_6.args.checkString){var _8=_1.connect(_7,_2,function(_9){if(_9.type=="load"||_3.test(_7.readyState)){_1.disconnect(_8);_6.scriptLoaded=_9;}});}}_1._ioWatch(_5,this._validCheck,this._ioCheck,this._resHandle);return _5;},attach:function(id,_a,_b){var _c=(_b||_1.doc);var _d=_c.createElement("script");_d.type="text/javascript";_d.src=_a;_d.id=id;_d.async=true;_d.charset="utf-8";return _c.getElementsByTagName("head")[0].appendChild(_d);},remove:function(id,_e){_1.destroy(_1.byId(id,_e));if(this["jsonp_"+id]){delete this["jsonp_"+id];}},_makeScriptDeferred:function(_f){var dfd=_1._ioSetArgs(_f,this._deferredCancel,this._deferredOk,this._deferredError);var _10=dfd.ioArgs;_10.id=_1._scopeName+"IoScript"+(this._counter++);_10.canDelete=false;_10.jsonp=_f.callbackParamName||_f.jsonp;if(_10.jsonp){_10.query=_10.query||"";if(_10.query.length>0){_10.query+="&";}_10.query+=_10.jsonp+"="+(_f.frameDoc?"parent.":"")+_1._scopeName+".io.script.jsonp_"+_10.id+"._jsonpCallback";_10.frameDoc=_f.frameDoc;_10.canDelete=true;dfd._jsonpCallback=this._jsonpCallback;this["jsonp_"+_10.id]=dfd;}return dfd;},_deferredCancel:function(dfd){dfd.canceled=true;if(dfd.ioArgs.canDelete){_1.io.script._addDeadScript(dfd.ioArgs);}},_deferredOk:function(dfd){var _11=dfd.ioArgs;if(_11.canDelete){_1.io.script._addDeadScript(_11);}return _11.json||_11.scriptLoaded||_11;},_deferredError:function(_12,dfd){if(dfd.ioArgs.canDelete){if(_12.dojoType=="timeout"){_1.io.script.remove(dfd.ioArgs.id,dfd.ioArgs.frameDoc);}else{_1.io.script._addDeadScript(dfd.ioArgs);}}return _12;},_deadScripts:[],_counter:1,_addDeadScript:function(_13){_1.io.script._deadScripts.push({id:_13.id,frameDoc:_13.frameDoc});_13.frameDoc=null;},_validCheck:function(dfd){var _14=_1.io.script;var _15=_14._deadScripts;if(_15&&_15.length>0){for(var i=0;i<_15.length;i++){_14.remove(_15[i].id,_15[i].frameDoc);_15[i].frameDoc=null;}_1.io.script._deadScripts=[];}return true;},_ioCheck:function(dfd){var _16=dfd.ioArgs;if(_16.json||(_16.scriptLoaded&&!_16.args.checkString)){return true;}var _17=_16.args.checkString;return _17&&eval("typeof("+_17+") != 'undefined'");},_resHandle:function(dfd){if(_1.io.script._ioCheck(dfd)){dfd.callback(dfd);}else{dfd.errback(new Error("inconceivable dojo.io.script._resHandle error"));}},_canAttach:function(_18){return true;},_jsonpCallback:function(_19){this.ioArgs.json=_19;}};return _1.io.script;});
\ No newline at end of file